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 {
27
27
func verify( _ context: FunctionPassContext ) {
28
28
for block in blocks {
29
29
for inst in block. instructions {
30
+
31
+ inst. checkForwardingConformance ( )
32
+
30
33
if let verifyableInst = inst as? VerifyableInstruction {
31
34
verifyableInst. verify ( context)
32
35
}
@@ -35,6 +38,16 @@ extension Function {
35
38
}
36
39
}
37
40
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
+
38
51
func registerVerifier( ) {
39
52
BridgedUtilities . registerVerifier (
40
53
{ ( bridgedCtxt: BridgedPassContext , bridgedFunction: BridgedFunction ) in
Original file line number Diff line number Diff line change @@ -770,6 +770,7 @@ struct BridgedInstruction {
770
770
bool mayLoadWeakOrUnowned () const ;
771
771
bool maySynchronize () const ;
772
772
bool mayBeDeinitBarrierNotConsideringSideEffects () const ;
773
+ BRIDGED_INLINE bool shouldBeForwarding () const ;
773
774
774
775
// =========================================================================//
775
776
// Generalized instruction subclasses
Original file line number Diff line number Diff line change @@ -846,6 +846,12 @@ bool BridgedInstruction::maySuspend() const {
846
846
return unbridged ()->maySuspend ();
847
847
}
848
848
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
+
849
855
SwiftInt BridgedInstruction::MultipleValueInstruction_getNumResults () const {
850
856
return getAs<swift::MultipleValueInstruction>()->getNumResults ();
851
857
}
You can’t perform that action at this time.
0 commit comments