diff options
| author | Wesley Wiser <wesleywiser@microsoft.com> | 2022-12-07 13:48:34 -0500 |
|---|---|---|
| committer | Wesley Wiser <wesleywiser@microsoft.com> | 2022-12-08 20:38:23 -0500 |
| commit | 7253057887b6de77e6847844311da517d2ada1eb (patch) | |
| tree | f0fa2e56c5451afb1edcf4488162aefa1d5e7aa1 /src/test/codegen | |
| parent | b33d1e26b220062e23bb202c6765663c157d971b (diff) | |
| download | rust-7253057887b6de77e6847844311da517d2ada1eb.tar.gz rust-7253057887b6de77e6847844311da517d2ada1eb.zip | |
Don't generate pointer loads to spills unless necessary
In order for LLVM to correctly generate debuginfo for msvc, we sometimes need to spill arguments to the stack and perform some direct & indirect offsets into the value. Previously, this code always performed those actions, even when not required as LLVM would clean it up during optimization. However, when MIR inlining is enabled, this can cause problems as the operations occur prior to the spilled value being initialized. To solve this, we first calculate the necessary offsets using just the type which is side-effect free and does not alter the LLVM IR. Then, if we are in a situation which requires us to generate the LLVM IR (and this situation only occurs for arguments, not local variables) then we perform the same calculation again, this time generating the appropriate LLVM IR as we go.
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/issue-105386-ub-in-debuginfo.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/test/codegen/issue-105386-ub-in-debuginfo.rs b/src/test/codegen/issue-105386-ub-in-debuginfo.rs index e30f373a793..d54ac9e33bc 100644 --- a/src/test/codegen/issue-105386-ub-in-debuginfo.rs +++ b/src/test/codegen/issue-105386-ub-in-debuginfo.rs @@ -16,7 +16,7 @@ pub fn outer_function(x: S, y: S) -> usize { // 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-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:9:23: 9:25]", ptr [[spill]] +// CHECK-NOT: [[load:%.*]] = load ptr, ptr // CHECK: call void @llvm.lifetime.start{{.*}}({{.*}}, ptr [[spill]]) // CHECK: call void @llvm.memcpy{{.*}}(ptr {{align .*}} [[spill]], ptr {{align .*}} %x |
