]> git.lizzy.rs Git - rust.git/blob - tests/codegen/lifetime_start_end.rs
Rollup merge of #107248 - erikdesjardins:addrspace, r=oli-obk
[rust.git] / tests / codegen / lifetime_start_end.rs
1 // compile-flags: -O -C no-prepopulate-passes -Zmir-opt-level=0
2
3 #![crate_type = "lib"]
4
5 // CHECK-LABEL: @test
6 #[no_mangle]
7 pub fn test() {
8     let a = 0u8;
9     &a; // keep variable in an alloca
10
11 // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{i8\*|ptr}} %a)
12
13     {
14         let b = &Some(a);
15         &b; // keep variable in an alloca
16
17 // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{.*}})
18
19 // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{.*}})
20
21 // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{.*}})
22
23 // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{.*}})
24     }
25
26     let c = 1u8;
27     &c; // keep variable in an alloca
28
29 // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{i8\*|ptr}} %c)
30
31 // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{i8\*|ptr}} %c)
32
33 // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{i8\*|ptr}} %a)
34 }