Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(super) struct SimplifyComparisonIntegral;

impl<'tcx> crate::MirPass<'tcx> for SimplifyComparisonIntegral {
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
sess.mir_opt_level() > 0
sess.mir_opt_level() > 0 && sess.opts.unstable_opts.unsound_mir_opts
}

fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen-llvm/hint/likely.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn test4(x: u64) {
}

// CHECK-LABEL: @test4(
// CHECK: br i1 %0, label %bb3, label %bb2, !prof ![[NUM2:[0-9]+]]
// CHECK: br i1 %_2.not, label %bb3, label %bb2, !prof ![[NUM2:[0-9]+]]
// CHECK: bb3:
// CHECK: path_a
// CHECK: bb2:
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen-llvm/hint/unlikely.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn test4(x: u64) {
}

// CHECK-LABEL: @test4(
// CHECK: br i1 %0, label %bb4, label %bb2, !prof ![[NUM2:[0-9]+]]
// CHECK: br i1 %_2.not, label %bb4, label %bb2, !prof ![[NUM2:[0-9]+]]
// CHECK: bb4:
// CHECK: path_a
// CHECK: bb2:
Expand Down
2 changes: 1 addition & 1 deletion tests/debuginfo/dummy_span.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ min-lldb-version: 310

//@ compile-flags:-g
//@ compile-flags:-g -Zunsound-mir-opts
//@ ignore-backends: gcc

// === GDB TESTS ===================================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
debug precision => _8;
let _8: usize;
scope 5 (inlined Formatter::<'_>::precision) {
let mut _22: u32;
let mut _22: bool;
let mut _23: u32;
let mut _24: usize;
let mut _25: u16;
let mut _24: u32;
let mut _25: usize;
let mut _26: u16;
}
}
}
Expand Down Expand Up @@ -71,10 +72,12 @@
StorageLive(_6);
StorageLive(_22);
StorageLive(_23);
_23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32);
_22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG);
StorageDead(_23);
switchInt(move _22) -> [0: bb10, otherwise: bb11];
StorageLive(_24);
_24 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32);
_23 = BitAnd(move _24, const core::fmt::flags::PRECISION_FLAG);
StorageDead(_24);
_22 = Eq(move _23, const 0_u32);
switchInt(move _22) -> [0: bb10, otherwise: bb9];
}

bb4: {
Expand Down Expand Up @@ -142,26 +145,27 @@
}

bb9: {
_7 = discriminant(_6);
switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb12];
StorageDead(_23);
_6 = const Option::<usize>::None;
goto -> bb11;
}

bb10: {
StorageDead(_22);
_6 = const Option::<usize>::None;
goto -> bb9;
StorageDead(_23);
StorageLive(_25);
StorageLive(_26);
_26 = copy (((*_1).0: std::fmt::FormattingOptions).2: u16);
_25 = move _26 as usize (IntToInt);
StorageDead(_26);
_6 = Option::<usize>::Some(move _25);
StorageDead(_25);
goto -> bb11;
}

bb11: {
StorageDead(_22);
StorageLive(_24);
StorageLive(_25);
_25 = copy (((*_1).0: std::fmt::FormattingOptions).2: u16);
_24 = move _25 as usize (IntToInt);
StorageDead(_25);
_6 = Option::<usize>::Some(move _24);
StorageDead(_24);
goto -> bb9;
_7 = discriminant(_6);
switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb12];
}

bb12: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
debug precision => _8;
let _8: usize;
scope 5 (inlined Formatter::<'_>::precision) {
let mut _22: u32;
let mut _22: bool;
let mut _23: u32;
let mut _24: usize;
let mut _25: u16;
let mut _24: u32;
let mut _25: usize;
let mut _26: u16;
}
}
}
Expand Down Expand Up @@ -71,10 +72,12 @@
StorageLive(_6);
StorageLive(_22);
StorageLive(_23);
_23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32);
_22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG);
StorageDead(_23);
switchInt(move _22) -> [0: bb10, otherwise: bb11];
StorageLive(_24);
_24 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32);
_23 = BitAnd(move _24, const core::fmt::flags::PRECISION_FLAG);
StorageDead(_24);
_22 = Eq(move _23, const 0_u32);
switchInt(move _22) -> [0: bb10, otherwise: bb9];
}

bb4: {
Expand Down Expand Up @@ -142,26 +145,27 @@
}

bb9: {
_7 = discriminant(_6);
switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb12];
StorageDead(_23);
_6 = const Option::<usize>::None;
goto -> bb11;
}

bb10: {
StorageDead(_22);
_6 = const Option::<usize>::None;
goto -> bb9;
StorageDead(_23);
StorageLive(_25);
StorageLive(_26);
_26 = copy (((*_1).0: std::fmt::FormattingOptions).2: u16);
_25 = move _26 as usize (IntToInt);
StorageDead(_26);
_6 = Option::<usize>::Some(move _25);
StorageDead(_25);
goto -> bb11;
}

bb11: {
StorageDead(_22);
StorageLive(_24);
StorageLive(_25);
_25 = copy (((*_1).0: std::fmt::FormattingOptions).2: u16);
_24 = move _25 as usize (IntToInt);
StorageDead(_25);
_6 = Option::<usize>::Some(move _24);
StorageDead(_24);
goto -> bb9;
_7 = discriminant(_6);
switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb12];
}

bb12: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
debug precision => _8;
let _8: usize;
scope 5 (inlined Formatter::<'_>::precision) {
let mut _22: u32;
let mut _22: bool;
let mut _23: u32;
let mut _24: usize;
let mut _25: u16;
let mut _24: u32;
let mut _25: usize;
let mut _26: u16;
}
}
}
Expand Down Expand Up @@ -71,10 +72,12 @@
StorageLive(_6);
StorageLive(_22);
StorageLive(_23);
_23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32);
_22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG);
StorageDead(_23);
switchInt(move _22) -> [0: bb10, otherwise: bb11];
StorageLive(_24);
_24 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32);
_23 = BitAnd(move _24, const core::fmt::flags::PRECISION_FLAG);
StorageDead(_24);
_22 = Eq(move _23, const 0_u32);
switchInt(move _22) -> [0: bb10, otherwise: bb9];
}

bb4: {
Expand Down Expand Up @@ -142,26 +145,27 @@
}

bb9: {
_7 = discriminant(_6);
switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb12];
StorageDead(_23);
_6 = const Option::<usize>::None;
goto -> bb11;
}

bb10: {
StorageDead(_22);
_6 = const Option::<usize>::None;
goto -> bb9;
StorageDead(_23);
StorageLive(_25);
StorageLive(_26);
_26 = copy (((*_1).0: std::fmt::FormattingOptions).2: u16);
_25 = move _26 as usize (IntToInt);
StorageDead(_26);
_6 = Option::<usize>::Some(move _25);
StorageDead(_25);
goto -> bb11;
}

bb11: {
StorageDead(_22);
StorageLive(_24);
StorageLive(_25);
_25 = copy (((*_1).0: std::fmt::FormattingOptions).2: u16);
_24 = move _25 as usize (IntToInt);
StorageDead(_25);
_6 = Option::<usize>::Some(move _24);
StorageDead(_24);
goto -> bb9;
_7 = discriminant(_6);
switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb12];
}

bb12: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
debug precision => _8;
let _8: usize;
scope 5 (inlined Formatter::<'_>::precision) {
let mut _22: u32;
let mut _22: bool;
let mut _23: u32;
let mut _24: usize;
let mut _25: u16;
let mut _24: u32;
let mut _25: usize;
let mut _26: u16;
}
}
}
Expand Down Expand Up @@ -71,10 +72,12 @@
StorageLive(_6);
StorageLive(_22);
StorageLive(_23);
_23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32);
_22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG);
StorageDead(_23);
switchInt(move _22) -> [0: bb10, otherwise: bb11];
StorageLive(_24);
_24 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32);
_23 = BitAnd(move _24, const core::fmt::flags::PRECISION_FLAG);
StorageDead(_24);
_22 = Eq(move _23, const 0_u32);
switchInt(move _22) -> [0: bb10, otherwise: bb9];
}

bb4: {
Expand Down Expand Up @@ -142,26 +145,27 @@
}

bb9: {
_7 = discriminant(_6);
switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb12];
StorageDead(_23);
_6 = const Option::<usize>::None;
goto -> bb11;
}

bb10: {
StorageDead(_22);
_6 = const Option::<usize>::None;
goto -> bb9;
StorageDead(_23);
StorageLive(_25);
StorageLive(_26);
_26 = copy (((*_1).0: std::fmt::FormattingOptions).2: u16);
_25 = move _26 as usize (IntToInt);
StorageDead(_26);
_6 = Option::<usize>::Some(move _25);
StorageDead(_25);
goto -> bb11;
}

bb11: {
StorageDead(_22);
StorageLive(_24);
StorageLive(_25);
_25 = copy (((*_1).0: std::fmt::FormattingOptions).2: u16);
_24 = move _25 as usize (IntToInt);
StorageDead(_25);
_6 = Option::<usize>::Some(move _24);
StorageDead(_24);
goto -> bb9;
_7 = discriminant(_6);
switchInt(move _7) -> [1: bb4, 0: bb6, otherwise: bb12];
}

bb12: {
Expand Down
1 change: 1 addition & 0 deletions tests/mir-opt/issue_76432.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// Check that we do not insert StorageDead at each target if StorageDead was never seen
//@ compile-flags: -Zunsound-mir-opts

use std::fmt::Debug;

Expand Down
Loading
Loading