Add a SIL test case for a dead alloc_stack with debug variable.

This commit is contained in:
Andrew Trick
2022-02-16 12:43:18 -08:00
parent 6794bbae46
commit d9ba9f3d67

View File

@@ -22,3 +22,17 @@ func test<T>(_ t : T) {
let a = S(a: t)
a.foo()
}
func use<T>(_ t : T) {}
// CHECK-SIL: sil hidden @$s16debug_value_addr11GenericSelfV1xACyxGx_tcfC : $@convention(method) <T> (@in T, @thin GenericSelf<T>.Type) -> GenericSelf<T> {
// CHECK-SIL: bb0(%0 : $*T, %1 : $@thin GenericSelf<T>.Type):
// CHECK-SIL-NEXT: alloc_stack [lexical] $GenericSelf<T>, var, name "self", implicit, loc {{.*}}
// CHECK-SIL-NEXT: debug_value %0 : $*T, let, name "x", argno 1, expr op_deref, loc {{.*}}
struct GenericSelf<T> {
init(x: T) {
// 'self' is a valid debug variable here even though there is
// nothing to initialize (the dead alloc_stack cannot be removed).
use(x)
}
}