File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ extension Function {
2727 func verify( _ context: FunctionPassContext ) {
2828 for block in blocks {
2929 for inst in block. instructions {
30+
31+ inst. checkForwardingConformance ( )
32+
3033 if let verifyableInst = inst as? VerifyableInstruction {
3134 verifyableInst. verify ( context)
3235 }
@@ -35,6 +38,16 @@ extension Function {
3538 }
3639}
3740
41+ private extension Instruction {
42+ func checkForwardingConformance( ) {
43+ if bridged. shouldBeForwarding ( ) {
44+ require ( self is ForwardingInstruction , " instruction \( self ) \n should conform to ForwardingInstruction " )
45+ } else {
46+ require ( !( self is ForwardingInstruction ) , " instruction \( self ) \n should not conform to ForwardingInstruction " )
47+ }
48+ }
49+ }
50+
3851func registerVerifier( ) {
3952 BridgedUtilities . registerVerifier (
4053 { ( bridgedCtxt: BridgedPassContext , bridgedFunction: BridgedFunction ) in
Original file line number Diff line number Diff line change @@ -770,6 +770,7 @@ struct BridgedInstruction {
770770 bool mayLoadWeakOrUnowned () const ;
771771 bool maySynchronize () const ;
772772 bool mayBeDeinitBarrierNotConsideringSideEffects () const ;
773+ BRIDGED_INLINE bool shouldBeForwarding () const ;
773774
774775 // =========================================================================//
775776 // Generalized instruction subclasses
Original file line number Diff line number Diff line change @@ -846,6 +846,12 @@ bool BridgedInstruction::maySuspend() const {
846846 return unbridged ()->maySuspend ();
847847}
848848
849+ bool BridgedInstruction::shouldBeForwarding () const {
850+ return llvm::isa<swift::OwnershipForwardingSingleValueInstruction>(unbridged ()) ||
851+ llvm::isa<swift::OwnershipForwardingTermInst>(unbridged ()) ||
852+ llvm::isa<swift::OwnershipForwardingMultipleValueInstruction>(unbridged ());
853+ }
854+
849855SwiftInt BridgedInstruction::MultipleValueInstruction_getNumResults () const {
850856 return getAs<swift::MultipleValueInstruction>()->getNumResults ();
851857}
You can’t perform that action at this time.
0 commit comments