Skip to content

Commit 8685234

Browse files
committed
Add test cases for salvageDebugInfo.
Ensure that SILGenCleanup creates the correct debug-value for both arguments and stack locations. Arguments require a 'deref' expression. Stack locations weirdly do not. They are special-cased in IRGen. (cherry picked from commit 4737090)
1 parent 57c39f8 commit 8685234

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// RUN: %target-sil-opt -opt-mode=none -silgen-cleanup -sil-print-debuginfo -sil-verify-all %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDEB
2+
3+
// TODO: add -opt-mode=speed after calling salvageLoadDebugInfo() from salvageDebugInfo().
4+
5+
import Builtin
6+
7+
sil_stage raw
8+
9+
struct Int {
10+
var _value : Builtin.Int32
11+
}
12+
13+
// rdar://104700920 (At -Onone preserve debug info after splitting loads)
14+
//
15+
// loadFromArg checks that a new debug_value is inserted with "expr op_deref".
16+
//
17+
// loadFromStack checks that a new debug_value is insert without op_deref.
18+
19+
sil_scope 10 { loc "./loadFromArg.swift":1:1 parent @loadFromArg : $@convention(thin) (@inout Int) -> Builtin.Int32 }
20+
sil_scope 11 { loc "./loadFromArg.swift":1:1 parent 10 }
21+
// CHECK: sil_scope [[ARGSCOPE1:[0-9]+]] { loc "./loadFromArg.swift":1:1 parent @loadFromArg : $@convention(thin) (@inout Int) -> Builtin.Int32 }
22+
// CHECK: sil_scope [[ARGSCOPE2:[0-9]+]] { loc "./loadFromArg.swift":1:1 parent [[ARGSCOPE1]] }
23+
24+
// CHECK-LABEL: sil [ossa] @loadFromArg : $@convention(thin) (@inout Int) -> Builtin.Int32 {
25+
// CHECK: bb0(%0 : $*Int):
26+
// CHECK: [[ACCESS:%.*]] = begin_access [read] [unknown] %0 : $*Int
27+
// CHECK: struct_element_addr [[ACCESS]] : $*Int, #Int._value
28+
// CHECK: load [trivial] %{{.*}} : $*Builtin.Int32, loc "./loadFromArg.swift":2:1, scope [[ARGSCOPE1]]
29+
// CHECK: debug_value [[ACCESS]] : $*Int, let, name "sVar", expr op_deref, loc "./loadFromArg.swift":3:1, scope [[ARGSCOPE2]]
30+
// CHECK-LABEL: } // end sil function 'loadFromArg'
31+
sil [ossa] @loadFromArg : $@convention(thin) (@inout Int) -> Builtin.Int32 {
32+
bb0(%0 : $*Int):
33+
%2 = begin_access [read] [unknown] %0 : $*Int
34+
%3 = load [trivial] %2 : $*Int, loc "./loadFromArg.swift":2:1, scope 10
35+
end_access %2 : $*Int
36+
debug_value %3 : $Int, let, name "sVar", loc "./loadFromArg.swift":3:1, scope 11
37+
%6 = struct_extract %3 : $Int, #Int._value
38+
return %6 : $Builtin.Int32
39+
}
40+
41+
sil @storeToStack : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0
42+
43+
sil_scope 20 { loc "./loadFromStack.swift":1:1 parent @loadFromStack : $@convention(thin) (Int) -> Builtin.Int32 }
44+
sil_scope 21 { loc "./loadFromStack.swift":1:1 parent 20 }
45+
// CHECK: sil_scope [[STACKSCOPE1:[0-9]+]] { loc "./loadFromStack.swift":1:1 parent @loadFromStack : $@convention(thin) (Int) -> Builtin.Int32 }
46+
// CHECK: sil_scope [[STACKSCOPE2:[0-9]+]] { loc "./loadFromStack.swift":1:1 parent [[STACKSCOPE1]] }
47+
48+
// CHECK-LABEL: sil [ossa] @loadFromStack : $@convention(thin) (Int) -> Builtin.Int32 {
49+
// CHECK: bb0(%0 : $Int):
50+
// CHECK: [[STACK:%.*]] = alloc_stack $Int
51+
// CHECK: struct_element_addr [[STACK]] : $*Int, #Int._value
52+
// CHECK: load [trivial] %{{.*}} : $*Builtin.Int32, loc "./loadFromStack.swift":2:1, scope [[STACKSCOPE1]]
53+
// CHECK: debug_value [[STACK]] : $*Int, let, name "sVar", loc "./loadFromStack.swift":3:1, scope [[STACKSCOPE2]]
54+
// CHECK-LABEL: } // end sil function 'loadFromStack'
55+
sil [ossa] @loadFromStack : $@convention(thin) (Int) -> Builtin.Int32 {
56+
bb0(%0 : $Int):
57+
debug_value %0 : $Int, let, name "s", argno 1
58+
%2 = alloc_stack $Int
59+
%3 = alloc_stack $Int
60+
store %0 to [trivial] %3 : $*Int
61+
%5 = function_ref @storeToStack : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0
62+
%6 = apply %5<Int>(%2, %3) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0
63+
dealloc_stack %3 : $*Int
64+
%8 = load [trivial] %2 : $*Int, loc "./loadFromStack.swift":2:1, scope 20
65+
debug_value %8 : $Int, let, name "sVar", loc "./loadFromStack.swift":3:1, scope 21
66+
dealloc_stack %2 : $*Int
67+
%11 = struct_extract %8 : $Int, #Int._value
68+
return %11 : $Builtin.Int32
69+
}

0 commit comments

Comments
 (0)