-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix variable debuginfo being optimized away at
mir-opt-level=2
The `DeadStoreElmination` pass was removing the uses of these locals because the are never used in the MIR body except for debuginfo. I've updated the pass to consider locals referenced by debuginfo as always alive unless a higher MIR opt level is requested by the user.
- Loading branch information
1 parent
bebe274
commit daf2968
Showing
4 changed files
with
59 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// compile-flags: -g -O | ||
|
||
// Check that simple constant values are preserved in debuginfo across both MIR opts and LLVM opts | ||
|
||
#![crate_type = "lib"] | ||
|
||
#[no_mangle] | ||
pub fn check_it() { | ||
let a = 1; | ||
let b = 42; | ||
|
||
foo(a + b); | ||
} | ||
|
||
#[inline(never)] | ||
fn foo(x: i32) { | ||
std::process::exit(x); | ||
} | ||
|
||
// CHECK-LABEL: @check_it | ||
// CHECK: call void @llvm.dbg.value(metadata i32 1, metadata ![[a_metadata:[0-9]+]], metadata !DIExpression()) | ||
// CHECK: call void @llvm.dbg.value(metadata i32 42, metadata ![[b_metadata:[0-9]+]], metadata !DIExpression()) | ||
|
||
// CHECK: ![[a_metadata]] = !DILocalVariable(name: "a" | ||
// CHECK-SAME: line: 9 | ||
|
||
// CHECK: ![[b_metadata]] = !DILocalVariable(name: "b" | ||
// CHECK-SAME: line: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters