diff options
| author | Wesley Wiser <wesleywiser@microsoft.com> | 2022-12-08 19:06:27 -0500 |
|---|---|---|
| committer | Wesley Wiser <wesleywiser@microsoft.com> | 2022-12-08 20:38:18 -0500 |
| commit | 34246f89e268bd3741e51d21253951e3ffd53d74 (patch) | |
| tree | 3cb97825a23e72ba954cbf8146b36ac319236b5b /src/test | |
| parent | 7632db0e87d8adccc9a83a47795c9411b1455855 (diff) | |
| download | rust-34246f89e268bd3741e51d21253951e3ffd53d74.tar.gz rust-34246f89e268bd3741e51d21253951e3ffd53d74.zip | |
Add test case for ub in generated LLVM IR
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/codegen/issue-105386-ub-in-debuginfo.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/codegen/issue-105386-ub-in-debuginfo.rs b/src/test/codegen/issue-105386-ub-in-debuginfo.rs new file mode 100644 index 00000000000..e30f373a793 --- /dev/null +++ b/src/test/codegen/issue-105386-ub-in-debuginfo.rs @@ -0,0 +1,22 @@ +// compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes +// min-llvm-version: 15.0 # this test uses opaque pointer notation +#![feature(stmt_expr_attributes)] + +pub struct S([usize; 8]); + +#[no_mangle] +pub fn outer_function(x: S, y: S) -> usize { + (#[inline(always)]|| { + let _z = x; + y.0[0] + })() +} + +// Check that we do not attempt to load from the spilled arg before it is assigned to +// when generating debuginfo. +// CHECK-LABEL: @outer_function +// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:9:23: 9:25]" +// CHECK: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:9:23: 9:25]", ptr [[spill]] +// CHECK: [[load:%.*]] = load ptr, ptr [[ptr_tmp]] +// CHECK: call void @llvm.lifetime.start{{.*}}({{.*}}, ptr [[spill]]) +// CHECK: call void @llvm.memcpy{{.*}}(ptr {{align .*}} [[spill]], ptr {{align .*}} %x |
