File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -975,3 +975,39 @@ let interiorLivenessTest = FunctionTest("interior_liveness_swift") {
975
975
defer { boundary. deinitialize ( ) }
976
976
print ( boundary)
977
977
}
978
+
979
+ // Print the uses of an address.
980
+ struct AddressUsePrinter : AddressUseVisitor {
981
+ let _context : Context
982
+
983
+ mutating func leafUse( address: Operand ) -> WalkResult {
984
+ print ( " Leaf use: \( address) " )
985
+ return . continueWalk
986
+ }
987
+
988
+ mutating func pointerEscape( address: Operand ) -> WalkResult {
989
+ print ( " Pointer escape: \( address) " )
990
+ return . continueWalk
991
+ }
992
+
993
+ mutating func unknown( address: Operand ) -> WalkResult {
994
+ print ( " Unknown: \( address) " )
995
+ return . continueWalk
996
+ }
997
+
998
+ mutating func dependent( value: Value , dependsOn address: Operand )
999
+ -> WalkResult {
1000
+ print ( " Dependent: \( value) on \( address) " )
1001
+ return . continueWalk
1002
+ }
1003
+ }
1004
+
1005
+ let addressUseTest = FunctionTest ( " address_use_test " ) {
1006
+ function, arguments, context in
1007
+ let address = arguments. takeValue ( )
1008
+ assert ( address. type. isAddress)
1009
+ print ( function)
1010
+ print ( " Uses of address: \( address) " )
1011
+ var printer = AddressUsePrinter ( _context: context)
1012
+ printer. walkDownUses ( ofAddress: address)
1013
+ }
You can’t perform that action at this time.
0 commit comments