Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix variable debuginfo being optimized away at mir-opt-level=2 #103657

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test case
  • Loading branch information
wesleywiser committed Oct 27, 2022
commit bebe274272011a39eacb8d14f98697ee1c57604e
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// compile-flags: -Zmir-opt-level=2
// mir-opt-level is fixed at 2 because that's the max level that can be set on stable
// EMIT_MIR constant_local_debuginfo.main.DeadStoreElimination.diff
fn main() {
let a = 1;
let b = 4;

foo(a + b);
}

#[inline(never)]
fn foo(x: i32) {
std::process::exit(x);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
- // MIR for `main` before DeadStoreElimination
+ // MIR for `main` after DeadStoreElimination

fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/constant-local-debuginfo.rs:+0:11: +0:11
let _1: i32; // in scope 0 at $DIR/constant-local-debuginfo.rs:+1:9: +1:10
let _3: (); // in scope 0 at $DIR/constant-local-debuginfo.rs:+4:5: +4:15
let mut _4: i32; // in scope 0 at $DIR/constant-local-debuginfo.rs:+4:9: +4:14
let mut _5: i32; // in scope 0 at $DIR/constant-local-debuginfo.rs:+4:9: +4:10
let mut _6: i32; // in scope 0 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
scope 1 {
debug a => _1; // in scope 1 at $DIR/constant-local-debuginfo.rs:+1:9: +1:10
let _2: i32; // in scope 1 at $DIR/constant-local-debuginfo.rs:+2:9: +2:10
scope 2 {
debug b => _2; // in scope 2 at $DIR/constant-local-debuginfo.rs:+2:9: +2:10
}
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/constant-local-debuginfo.rs:+1:9: +1:10
- _1 = const 1_i32; // scope 0 at $DIR/constant-local-debuginfo.rs:+1:13: +1:14
+ nop; // scope 0 at $DIR/constant-local-debuginfo.rs:+1:13: +1:14
StorageLive(_2); // scope 1 at $DIR/constant-local-debuginfo.rs:+2:9: +2:10
- _2 = const 4_i32; // scope 1 at $DIR/constant-local-debuginfo.rs:+2:13: +2:14
+ nop; // scope 1 at $DIR/constant-local-debuginfo.rs:+2:13: +2:14
StorageLive(_3); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:5: +4:15
StorageLive(_4); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:9: +4:14
StorageLive(_5); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:9: +4:10
- _5 = const 1_i32; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:9: +4:10
+ nop; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:9: +4:10
StorageLive(_6); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
- _6 = const 4_i32; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
+ nop; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
_4 = const 5_i32; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:9: +4:14
StorageDead(_6); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
StorageDead(_5); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
_3 = foo(move _4) -> bb1; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:5: +4:15
// mir::Constant
// + span: $DIR/constant-local-debuginfo.rs:8:5: 8:8
// + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) }
}

bb1: {
StorageDead(_4); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:14: +4:15
StorageDead(_3); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:15: +4:16
nop; // scope 0 at $DIR/constant-local-debuginfo.rs:+0:11: +5:2
StorageDead(_2); // scope 1 at $DIR/constant-local-debuginfo.rs:+5:1: +5:2
StorageDead(_1); // scope 0 at $DIR/constant-local-debuginfo.rs:+5:1: +5:2
return; // scope 0 at $DIR/constant-local-debuginfo.rs:+5:2: +5:2
}
}