Skip to content

Commit d9ba9f3

Browse files
committed
Add a SIL test case for a dead alloc_stack with debug variable.
1 parent 6794bba commit d9ba9f3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/DebugInfo/debug_value_addr.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,17 @@ func test<T>(_ t : T) {
2222
let a = S(a: t)
2323
a.foo()
2424
}
25+
26+
func use<T>(_ t : T) {}
27+
28+
// CHECK-SIL: sil hidden @$s16debug_value_addr11GenericSelfV1xACyxGx_tcfC : $@convention(method) <T> (@in T, @thin GenericSelf<T>.Type) -> GenericSelf<T> {
29+
// CHECK-SIL: bb0(%0 : $*T, %1 : $@thin GenericSelf<T>.Type):
30+
// CHECK-SIL-NEXT: alloc_stack [lexical] $GenericSelf<T>, var, name "self", implicit, loc {{.*}}
31+
// CHECK-SIL-NEXT: debug_value %0 : $*T, let, name "x", argno 1, expr op_deref, loc {{.*}}
32+
struct GenericSelf<T> {
33+
init(x: T) {
34+
// 'self' is a valid debug variable here even though there is
35+
// nothing to initialize (the dead alloc_stack cannot be removed).
36+
use(x)
37+
}
38+
}

0 commit comments

Comments
 (0)