Skip to content

Commit 34246f8

Browse files
committed
Add test case for ub in generated LLVM IR
1 parent 7632db0 commit 34246f8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes
2+
// min-llvm-version: 15.0 # this test uses opaque pointer notation
3+
#![feature(stmt_expr_attributes)]
4+
5+
pub struct S([usize; 8]);
6+
7+
#[no_mangle]
8+
pub fn outer_function(x: S, y: S) -> usize {
9+
(#[inline(always)]|| {
10+
let _z = x;
11+
y.0[0]
12+
})()
13+
}
14+
15+
// Check that we do not attempt to load from the spilled arg before it is assigned to
16+
// when generating debuginfo.
17+
// CHECK-LABEL: @outer_function
18+
// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:9:23: 9:25]"
19+
// CHECK: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:9:23: 9:25]", ptr [[spill]]
20+
// CHECK: [[load:%.*]] = load ptr, ptr [[ptr_tmp]]
21+
// CHECK: call void @llvm.lifetime.start{{.*}}({{.*}}, ptr [[spill]])
22+
// CHECK: call void @llvm.memcpy{{.*}}(ptr {{align .*}} [[spill]], ptr {{align .*}} %x

0 commit comments

Comments
 (0)