File tree 3 files changed +34
-1
lines changed
SwiftCompilerSources/Sources/Optimizer/TestPasses
lib/SILOptimizer/Analysis
3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,8 @@ private extension Instruction {
71
71
is LoadInst ,
72
72
is StoreInst ,
73
73
is CopyAddrInst ,
74
- is BuiltinInst :
74
+ is BuiltinInst ,
75
+ is DebugValueInst :
75
76
return true
76
77
default :
77
78
return false
Original file line number Diff line number Diff line change @@ -176,6 +176,7 @@ class MemoryBehaviorVisitor
176
176
MemBehavior visitDestroyValueInst (DestroyValueInst *DVI);
177
177
MemBehavior visitSetDeallocatingInst (SetDeallocatingInst *BI);
178
178
MemBehavior visitBeginCOWMutationInst (BeginCOWMutationInst *BCMI);
179
+ MemBehavior visitDebugValueInst (DebugValueInst *dv);
179
180
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
180
181
MemBehavior visit##Name##ReleaseInst(Name##ReleaseInst *BI);
181
182
#include " swift/AST/ReferenceStorage.def"
@@ -374,6 +375,15 @@ visitBeginCOWMutationInst(BeginCOWMutationInst *BCMI) {
374
375
return MemBehavior::None;
375
376
}
376
377
378
+ MemBehavior MemoryBehaviorVisitor::
379
+ visitDebugValueInst (DebugValueInst *dv) {
380
+ SILValue op = dv->getOperand ();
381
+ if (op->getType ().isAddress () && mayAlias (op)) {
382
+ return MemBehavior::MayRead;
383
+ }
384
+ return MemBehavior::None;
385
+ }
386
+
377
387
// ===----------------------------------------------------------------------===//
378
388
// Top Level Entrypoint
379
389
// ===----------------------------------------------------------------------===//
Original file line number Diff line number Diff line change @@ -1002,3 +1002,25 @@ bb0(%0 : $Builtin.RawPointer):
1002
1002
%6 = tuple ()
1003
1003
return %6 : $()
1004
1004
}
1005
+
1006
+
1007
+ // CHECK-LABEL: @test_debug_value
1008
+ // CHECK: PAIR #0.
1009
+ // CHECK-NEXT: debug_value %0 : $*Int, let, name "x"
1010
+ // CHECK-NEXT: %0 = alloc_stack $Int
1011
+ // CHECK-NEXT: r=1,w=0
1012
+ // CHECK: PAIR #1.
1013
+ // CHECK-NEXT: debug_value %0 : $*Int, let, name "x"
1014
+ // CHECK-NEXT: %1 = alloc_stack $Int
1015
+ // CHECK-NEXT: r=0,w=0
1016
+ sil @test_debug_value : $@convention(thin) () -> () {
1017
+ bb0:
1018
+ %0 = alloc_stack $Int
1019
+ %1 = alloc_stack $Int
1020
+ debug_value %0 : $*Int, let, name "x"
1021
+ dealloc_stack %1 : $*Int
1022
+ dealloc_stack %0 : $*Int
1023
+ %r = tuple ()
1024
+ return %r : $()
1025
+ }
1026
+
You can’t perform that action at this time.
0 commit comments