Skip to content

Commit

Permalink
Disable the constant debuginfo promotion pass by default
Browse files Browse the repository at this point in the history
It doesn't work correctly on *-pc-windows-gnu
  • Loading branch information
wesleywiser committed Dec 15, 2020
1 parent 01aec8d commit 0b18ed8
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 14 deletions.
6 changes: 5 additions & 1 deletion compiler/rustc_mir/src/transform/const_debuginfo.rs
Expand Up @@ -15,7 +15,11 @@ use rustc_index::{bit_set::BitSet, vec::IndexVec};
pub struct ConstDebugInfo;

impl<'tcx> MirPass<'tcx> for ConstDebugInfo {
fn run_pass(&self, _tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
if !tcx.sess.opts.debugging_opts.unsound_mir_opts {
return;
}

trace!("running ConstDebugInfo on {:?}", body.source);

for (local, constant) in find_optimization_oportunities(body) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/incremental/hashes/let_expressions.rs
Expand Up @@ -86,7 +86,7 @@ pub fn change_mutability_of_slot() {

#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2",
except="hir_owner_nodes,typeck")]
except="hir_owner_nodes,typeck,optimized_mir")]
#[rustc_clean(cfg="cfail3")]
pub fn change_mutability_of_slot() {
let _x: u64 = 0;
Expand Down Expand Up @@ -166,7 +166,7 @@ pub fn change_mutability_of_binding_in_pattern() {

#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2",
except="hir_owner_nodes,typeck")]
except="hir_owner_nodes,typeck,optimized_mir")]
#[rustc_clean(cfg="cfail3")]
pub fn change_mutability_of_binding_in_pattern() {
let (mut _a, _b) = (99u8, 'q');
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/const_debuginfo.rs
@@ -1,4 +1,4 @@
// compile-flags: -C overflow-checks=no
// compile-flags: -C overflow-checks=no -Zunsound-mir-opts

struct Point {
x: u32,
Expand Down
Expand Up @@ -2,18 +2,30 @@

fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11
let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
scope 1 {
debug x => const 4_i32; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10
let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
scope 2 {
debug y => const 3_i32; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10
debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10
let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
scope 3 {
debug z => const 42_u32; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10
debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10
}
}
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
_1 = const 4_i32; // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
_2 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
_3 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38
_0 = const (); // scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2
return; // scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2
}
}
Expand Up @@ -2,18 +2,30 @@

fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11
let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
scope 1 {
debug x => const 4_i32; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10
let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
scope 2 {
debug y => const 3_i32; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10
debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10
let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
scope 3 {
debug z => const 42_u32; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10
debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10
}
}
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
_1 = const 4_i32; // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
_2 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
_3 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38
_0 = const (); // scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2
return; // scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2
}
}
Expand Up @@ -11,8 +11,9 @@ fn main() -> () {
debug f => _1; // in scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:5:9: 5:10
scope 2 (inlined main::{closure#0}) { // at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
debug x => _5; // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
let _6: (); // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
scope 3 {
debug y => const (); // in scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
debug y => _6; // in scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
}
}
}
Expand All @@ -26,7 +27,10 @@ fn main() -> () {
(_3.0: ()) = move _4; // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
StorageLive(_5); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
_5 = move (_3.0: ()); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
StorageLive(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
_6 = const (); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
_0 = const (); // scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
StorageDead(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
StorageDead(_5); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
StorageDead(_4); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:9: 6:10
StorageDead(_3); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:9: 6:10
Expand Down
Expand Up @@ -3,7 +3,7 @@
fn f_u64() -> () {
let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:34:16: 34:16
scope 1 (inlined f_dispatch::<u64>) { // at $DIR/lower_intrinsics.rs:35:5: 35:21
debug t => const 0_u64; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
debug t => _2; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
let _1: (); // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
let mut _2: u64; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21
scope 2 (inlined std::mem::size_of::<u64>) { // at $DIR/lower_intrinsics.rs:35:5: 35:21
Expand Down
Expand Up @@ -2,12 +2,16 @@

fn change_loop_body() -> () {
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:5:27: 5:27
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
scope 1 {
debug _x => const 0_i32; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:6:18: 6:19
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:11:1: 11:2
return; // scope 0 at $DIR/while_let_loops.rs:11:2: 11:2
}
}
Expand Up @@ -2,12 +2,16 @@

fn change_loop_body() -> () {
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:5:27: 5:27
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
scope 1 {
debug _x => const 0_i32; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:6:18: 6:19
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:11:1: 11:2
return; // scope 0 at $DIR/while_let_loops.rs:11:2: 11:2
}
}

0 comments on commit 0b18ed8

Please sign in to comment.