Skip to content

Commit 259a7a7

Browse files
committed
Added test for const arg lifetimes suggested by erikdesjardins.
1 parent 8f529ab commit 259a7a7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This test checks that temporaries for indirectly-passed arguments get lifetime markers.
2+
3+
// compile-flags: -O -C no-prepopulate-passes -Zmir-opt-level=0
4+
5+
#![crate_type = "lib"]
6+
7+
extern "Rust" {
8+
fn f(x: [u8; 1024]);
9+
}
10+
11+
const A: [u8; 1024] = [0; 1024];
12+
13+
// CHECK-LABEL: @const_arg_indirect
14+
#[no_mangle]
15+
pub unsafe fn const_arg_indirect() {
16+
// Ensure that the live ranges for the two argument temporaries don't overlap.
17+
18+
// CHECK: call void @llvm.lifetime.start
19+
// CHECK: call void @f
20+
// CHECK: call void @llvm.lifetime.end
21+
// CHECK: call void @llvm.lifetime.start
22+
// CHECK: call void @f
23+
// CHECK: call void @llvm.lifetime.end
24+
25+
f(A);
26+
f(A);
27+
}

0 commit comments

Comments
 (0)