Skip to content
Merged
2 changes: 2 additions & 0 deletions compiler/rustc_data_structures/src/fx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub type FxIndexSet<V> = indexmap::IndexSet<V, BuildHasherDefault<FxHasher>>;
pub type IndexEntry<'a, K, V> = indexmap::map::Entry<'a, K, V>;
pub type IndexOccupiedEntry<'a, K, V> = indexmap::map::OccupiedEntry<'a, K, V>;

pub use indexmap::set::MutableValues;

#[macro_export]
macro_rules! define_id_collections {
($map_name:ident, $set_name:ident, $entry_name:ident, $key:ty) => {
Expand Down
202 changes: 110 additions & 92 deletions compiler/rustc_mir_transform/src/gvn.rs

Large diffs are not rendered by default.

38 changes: 0 additions & 38 deletions compiler/rustc_mir_transform/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ pub(super) struct SsaLocals {
borrowed_locals: DenseBitSet<Local>,
}

pub(super) enum AssignedValue<'a, 'tcx> {
Arg,
Rvalue(&'a mut Rvalue<'tcx>),
Terminator,
}

impl SsaLocals {
pub(super) fn new<'tcx>(
tcx: TyCtxt<'tcx>,
Expand Down Expand Up @@ -152,38 +146,6 @@ impl SsaLocals {
})
}

pub(super) fn for_each_assignment_mut<'tcx>(
&self,
basic_blocks: &mut IndexSlice<BasicBlock, BasicBlockData<'tcx>>,
mut f: impl FnMut(Local, AssignedValue<'_, 'tcx>, Location),
) {
for &local in &self.assignment_order {
match self.assignments[local] {
Set1::One(DefLocation::Argument) => f(
local,
AssignedValue::Arg,
Location { block: START_BLOCK, statement_index: 0 },
),
Set1::One(DefLocation::Assignment(loc)) => {
let bb = &mut basic_blocks[loc.block];
// `loc` must point to a direct assignment to `local`.
let stmt = &mut bb.statements[loc.statement_index];
let StatementKind::Assign(box (target, ref mut rvalue)) = stmt.kind else {
bug!()
};
assert_eq!(target.as_local(), Some(local));
f(local, AssignedValue::Rvalue(rvalue), loc)
}
Set1::One(DefLocation::CallReturn { call, .. }) => {
let bb = &mut basic_blocks[call];
let loc = Location { block: call, statement_index: bb.statements.len() };
f(local, AssignedValue::Terminator, loc)
}
_ => {}
}
}
}

/// Compute the equivalence classes for locals, based on copy statements.
///
/// The returned vector maps each local to the one it copies. In the following case:
Expand Down
2 changes: 0 additions & 2 deletions tests/codegen/clone_as_copy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//@ revisions: DEBUGINFO NODEBUGINFO
//@ compile-flags: -Zunsound-mir-opts
// FIXME: see <https://github.com/rust-lang/rust/issues/132353>
//@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes
//@ [DEBUGINFO] compile-flags: -Cdebuginfo=full

Expand Down
38 changes: 24 additions & 14 deletions tests/codegen/try_question_mark_nop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ use std::ptr::NonNull;
#[no_mangle]
pub fn option_nop_match_32(x: Option<u32>) -> Option<u32> {
// CHECK: start:
// TWENTY-NEXT: %[[IS_SOME:.+]] = trunc nuw i32 %0 to i1
// TWENTY-NEXT: %[[PAYLOAD:.+]] = select i1 %[[IS_SOME]], i32 %1, i32 undef
// CHECK-NEXT: [[REG1:%.*]] = insertvalue { i32, i32 } poison, i32 %0, 0
// NINETEEN-NEXT: [[REG2:%.*]] = insertvalue { i32, i32 } [[REG1]], i32 %1, 1
// TWENTY-NEXT: [[REG2:%.*]] = insertvalue { i32, i32 } [[REG1]], i32 %[[PAYLOAD]], 1
// CHECK-NEXT: ret { i32, i32 } [[REG2]]
// CHECK-NEXT: [[TRUNC:%.*]] = trunc nuw i32 %0 to i1

// NINETEEN-NEXT: [[SELECT:%.*]] = select i1 [[TRUNC]], i32 %0, i32 0
// NINETEEN-NEXT: [[REG2:%.*]] = insertvalue { i32, i32 } poison, i32 [[SELECT]], 0
// NINETEEN-NEXT: [[REG3:%.*]] = insertvalue { i32, i32 } [[REG2]], i32 %1, 1

// TWENTY-NEXT: [[SELECT:%.*]] = select i1 [[TRUNC]], i32 %1, i32 undef
// TWENTY-NEXT: [[REG2:%.*]] = insertvalue { i32, i32 } poison, i32 %0, 0
// TWENTY-NEXT: [[REG3:%.*]] = insertvalue { i32, i32 } [[REG2]], i32 [[SELECT]], 1

// CHECK-NEXT: ret { i32, i32 } [[REG3]]
match x {
Some(x) => Some(x),
None => None,
Expand Down Expand Up @@ -90,12 +95,17 @@ pub fn control_flow_nop_traits_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32,
#[no_mangle]
pub fn option_nop_match_64(x: Option<u64>) -> Option<u64> {
// CHECK: start:
// TWENTY-NEXT: %[[TRUNC:[0-9]+]] = trunc nuw i64 %0 to i1
// TWENTY-NEXT: %[[SEL:\.[0-9]+]] = select i1 %[[TRUNC]], i64 %1, i64 undef
// CHECK-NEXT: [[REG1:%[0-9a-zA-Z_.]+]] = insertvalue { i64, i64 } poison, i64 %0, 0
// NINETEEN-NEXT: [[REG2:%[0-9a-zA-Z_.]+]] = insertvalue { i64, i64 } [[REG1]], i64 %1, 1
// TWENTY-NEXT: [[REG2:%[0-9a-zA-Z_.]+]] = insertvalue { i64, i64 } [[REG1]], i64 %[[SEL]], 1
// CHECK-NEXT: ret { i64, i64 } [[REG2]]
// CHECK-NEXT: [[TRUNC:%.*]] = trunc nuw i64 %0 to i1

// NINETEEN-NEXT: [[SELECT:%.*]] = select i1 [[TRUNC]], i64 %0, i64 0
// NINETEEN-NEXT: [[REG2:%.*]] = insertvalue { i64, i64 } poison, i64 [[SELECT]], 0
// NINETEEN-NEXT: [[REG3:%.*]] = insertvalue { i64, i64 } [[REG2]], i64 %1, 1

// TWENTY-NEXT: [[SELECT:%.*]] = select i1 [[TRUNC]], i64 %1, i64 undef
// TWENTY-NEXT: [[REG2:%.*]] = insertvalue { i64, i64 } poison, i64 %0, 0
// TWENTY-NEXT: [[REG3:%.*]] = insertvalue { i64, i64 } [[REG2]], i64 [[SELECT]], 1

// CHECK-NEXT: ret { i64, i64 } [[REG3]]
match x {
Some(x) => Some(x),
None => None,
Expand Down Expand Up @@ -164,8 +174,8 @@ pub fn control_flow_nop_traits_64(x: ControlFlow<i64, u64>) -> ControlFlow<i64,
#[no_mangle]
pub fn result_nop_match_128(x: Result<i128, u128>) -> Result<i128, u128> {
// CHECK: start:
// CHECK-NEXT: getelementptr inbounds {{(nuw )?}}i8
// CHECK-NEXT: store i128
// CHECK-NEXT: getelementptr inbounds {{(nuw )?}}i8
// CHECK-NEXT: store i128
// CHECK-NEXT: ret void
match x {
Expand All @@ -189,8 +199,8 @@ pub fn result_nop_traits_128(x: Result<i128, u128>) -> Result<i128, u128> {
#[no_mangle]
pub fn control_flow_nop_match_128(x: ControlFlow<i128, u128>) -> ControlFlow<i128, u128> {
// CHECK: start:
// CHECK-NEXT: getelementptr inbounds {{(nuw )?}}i8
// CHECK-NEXT: store i128
// CHECK-NEXT: getelementptr inbounds {{(nuw )?}}i8
// CHECK-NEXT: store i128
// CHECK-NEXT: ret void
match x {
Expand Down
163 changes: 67 additions & 96 deletions tests/coverage/issue-84561.cov-map
Original file line number Diff line number Diff line change
Expand Up @@ -59,109 +59,80 @@ Number of file 0 mappings: 1
Highest counter ID seen: c0

Function name: issue_84561::test3
Raw bytes (315): 0x[01, 01, 1b, 1d, 21, 25, 29, 21, 25, 2d, 31, 21, 17, 25, 2d, 41, 45, 49, 4d, 51, 55, 33, 51, 49, 4d, 33, 37, 49, 4d, 51, 59, 55, 59, 55, 59, 47, 5d, 55, 59, 61, 65, 71, 75, 69, 6d, 69, 6d, 69, 6d, 63, 79, 71, 75, 79, 7d, 7d, 81, 01, 33, 01, 08, 01, 03, 0f, 05, 04, 09, 01, 0f, 09, 02, 05, 04, 0f, 0d, 05, 05, 00, 0f, 11, 01, 05, 00, 0f, 15, 01, 09, 01, 0f, 19, 02, 05, 00, 0f, 1d, 01, 05, 00, 0f, 02, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 25, 03, 20, 00, 30, 29, 00, 33, 00, 41, 06, 00, 4b, 00, 5a, 0a, 01, 05, 00, 0f, 2d, 05, 09, 03, 10, 31, 05, 0d, 00, 1b, 0e, 02, 0d, 00, 1c, 12, 04, 09, 02, 0f, 35, 06, 05, 00, 0f, 39, 04, 05, 00, 0f, 3d, 04, 09, 01, 0f, 41, 05, 08, 00, 0f, 45, 01, 09, 00, 13, 1a, 05, 09, 00, 13, 33, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 22, 03, 0d, 00, 1d, 26, 03, 09, 00, 13, 2e, 03, 0d, 00, 1d, 47, 03, 05, 00, 0f, 47, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 42, 02, 0d, 00, 13, 61, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 4a, 02, 0d, 00, 13, 63, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 00, 17, 71, 04, 0d, 00, 13, 5a, 02, 0d, 00, 17, 5a, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 5a, 02, 15, 00, 1b, 75, 04, 0d, 00, 13, 5e, 03, 09, 00, 19, 79, 02, 05, 00, 0f, 66, 03, 09, 00, 22, 7d, 02, 05, 00, 0f, 6a, 03, 09, 00, 2c, 81, 01, 02, 01, 00, 02]
Raw bytes (279): 0x[01, 01, 0a, 0d, 11, 0d, 15, 0d, 19, 1d, 21, 29, 2d, 25, 29, 25, 29, 25, 29, 27, 31, 29, 2d, 33, 01, 08, 01, 03, 0f, 05, 04, 09, 01, 0f, 09, 02, 05, 04, 0f, 09, 05, 05, 00, 0f, 09, 01, 05, 00, 0f, 09, 01, 09, 01, 0f, 0d, 02, 05, 00, 0f, 0d, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 0d, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 0d, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 0d, 04, 09, 02, 0f, 0d, 06, 05, 00, 0f, 0d, 04, 05, 00, 0f, 0d, 04, 09, 01, 0f, 0d, 05, 08, 00, 0f, 11, 01, 09, 00, 13, 02, 05, 09, 00, 13, 0d, 05, 08, 00, 0f, 15, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 06, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 0d, 03, 05, 00, 0f, 0d, 01, 0c, 00, 13, 19, 01, 0d, 00, 13, 0a, 02, 0d, 00, 13, 1d, 04, 05, 02, 13, 21, 03, 0d, 00, 13, 0e, 02, 0d, 00, 13, 27, 03, 05, 00, 0f, 25, 01, 0c, 00, 13, 29, 01, 0d, 00, 17, 29, 04, 0d, 00, 13, 1e, 02, 0d, 00, 17, 1e, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 1e, 02, 15, 00, 1b, 2d, 04, 0d, 00, 13, 22, 03, 09, 00, 19, 31, 02, 05, 00, 0f, 31, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 27
- expression 0 operands: lhs = Counter(7), rhs = Counter(8)
- expression 1 operands: lhs = Counter(9), rhs = Counter(10)
- expression 2 operands: lhs = Counter(8), rhs = Counter(9)
- expression 3 operands: lhs = Counter(11), rhs = Counter(12)
- expression 4 operands: lhs = Counter(8), rhs = Expression(5, Add)
- expression 5 operands: lhs = Counter(9), rhs = Counter(11)
- expression 6 operands: lhs = Counter(16), rhs = Counter(17)
- expression 7 operands: lhs = Counter(18), rhs = Counter(19)
- expression 8 operands: lhs = Counter(20), rhs = Counter(21)
- expression 9 operands: lhs = Expression(12, Add), rhs = Counter(20)
- expression 10 operands: lhs = Counter(18), rhs = Counter(19)
- expression 11 operands: lhs = Expression(12, Add), rhs = Expression(13, Add)
- expression 12 operands: lhs = Counter(18), rhs = Counter(19)
- expression 13 operands: lhs = Counter(20), rhs = Counter(22)
- expression 14 operands: lhs = Counter(21), rhs = Counter(22)
- expression 15 operands: lhs = Counter(21), rhs = Counter(22)
- expression 16 operands: lhs = Expression(17, Add), rhs = Counter(23)
- expression 17 operands: lhs = Counter(21), rhs = Counter(22)
- expression 18 operands: lhs = Counter(24), rhs = Counter(25)
- expression 19 operands: lhs = Counter(28), rhs = Counter(29)
- expression 20 operands: lhs = Counter(26), rhs = Counter(27)
- expression 21 operands: lhs = Counter(26), rhs = Counter(27)
- expression 22 operands: lhs = Counter(26), rhs = Counter(27)
- expression 23 operands: lhs = Expression(24, Add), rhs = Counter(30)
- expression 24 operands: lhs = Counter(28), rhs = Counter(29)
- expression 25 operands: lhs = Counter(30), rhs = Counter(31)
- expression 26 operands: lhs = Counter(31), rhs = Counter(32)
Number of expressions: 10
- expression 0 operands: lhs = Counter(3), rhs = Counter(4)
- expression 1 operands: lhs = Counter(3), rhs = Counter(5)
- expression 2 operands: lhs = Counter(3), rhs = Counter(6)
- expression 3 operands: lhs = Counter(7), rhs = Counter(8)
- expression 4 operands: lhs = Counter(10), rhs = Counter(11)
- expression 5 operands: lhs = Counter(9), rhs = Counter(10)
- expression 6 operands: lhs = Counter(9), rhs = Counter(10)
- expression 7 operands: lhs = Counter(9), rhs = Counter(10)
- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(12)
- expression 9 operands: lhs = Counter(10), rhs = Counter(11)
Number of file 0 mappings: 51
- Code(Counter(0)) at (prev + 8, 1) to (start + 3, 15)
- Code(Counter(1)) at (prev + 4, 9) to (start + 1, 15)
- Code(Counter(2)) at (prev + 2, 5) to (start + 4, 15)
- Code(Counter(3)) at (prev + 5, 5) to (start + 0, 15)
- Code(Counter(4)) at (prev + 1, 5) to (start + 0, 15)
- Code(Counter(5)) at (prev + 1, 9) to (start + 1, 15)
- Code(Counter(6)) at (prev + 2, 5) to (start + 0, 15)
- Code(Counter(7)) at (prev + 1, 5) to (start + 0, 15)
- Code(Expression(0, Sub)) at (prev + 0, 32) to (start + 0, 48)
- Code(Counter(2)) at (prev + 5, 5) to (start + 0, 15)
- Code(Counter(2)) at (prev + 1, 5) to (start + 0, 15)
- Code(Counter(2)) at (prev + 1, 9) to (start + 1, 15)
- Code(Counter(3)) at (prev + 2, 5) to (start + 0, 15)
- Code(Counter(3)) at (prev + 1, 5) to (start + 0, 15)
- Code(Zero) at (prev + 0, 32) to (start + 0, 48)
- Code(Counter(3)) at (prev + 1, 5) to (start + 3, 15)
- Code(Zero) at (prev + 3, 32) to (start + 0, 48)
- Code(Zero) at (prev + 0, 51) to (start + 0, 65)
- Code(Zero) at (prev + 0, 75) to (start + 0, 90)
- Code(Counter(3)) at (prev + 1, 5) to (start + 0, 15)
- Code(Zero) at (prev + 5, 9) to (start + 3, 16)
- Code(Zero) at (prev + 5, 13) to (start + 0, 27)
- Code(Zero) at (prev + 2, 13) to (start + 0, 28)
- Code(Counter(3)) at (prev + 4, 9) to (start + 2, 15)
- Code(Counter(3)) at (prev + 6, 5) to (start + 0, 15)
- Code(Counter(3)) at (prev + 4, 5) to (start + 0, 15)
- Code(Counter(3)) at (prev + 4, 9) to (start + 1, 15)
- Code(Counter(3)) at (prev + 5, 8) to (start + 0, 15)
- Code(Counter(4)) at (prev + 1, 9) to (start + 0, 19)
- Code(Expression(0, Sub)) at (prev + 5, 9) to (start + 0, 19)
= (c3 - c4)
- Code(Counter(3)) at (prev + 5, 8) to (start + 0, 15)
- Code(Counter(5)) at (prev + 1, 9) to (start + 0, 19)
- Code(Zero) at (prev + 3, 13) to (start + 0, 29)
- Code(Expression(1, Sub)) at (prev + 3, 9) to (start + 0, 19)
= (c3 - c5)
- Code(Zero) at (prev + 3, 13) to (start + 0, 29)
- Code(Counter(3)) at (prev + 3, 5) to (start + 0, 15)
- Code(Counter(3)) at (prev + 1, 12) to (start + 0, 19)
- Code(Counter(6)) at (prev + 1, 13) to (start + 0, 19)
- Code(Expression(2, Sub)) at (prev + 2, 13) to (start + 0, 19)
= (c3 - c6)
- Code(Counter(7)) at (prev + 4, 5) to (start + 2, 19)
- Code(Counter(8)) at (prev + 3, 13) to (start + 0, 19)
- Code(Expression(3, Sub)) at (prev + 2, 13) to (start + 0, 19)
= (c7 - c8)
- Code(Counter(8)) at (prev + 1, 5) to (start + 3, 15)
- Code(Counter(9)) at (prev + 3, 32) to (start + 0, 48)
- Code(Counter(10)) at (prev + 0, 51) to (start + 0, 65)
- Code(Expression(1, Sub)) at (prev + 0, 75) to (start + 0, 90)
- Code(Expression(9, Add)) at (prev + 3, 5) to (start + 0, 15)
= (c10 + c11)
- Code(Counter(9)) at (prev + 1, 12) to (start + 0, 19)
- Code(Counter(10)) at (prev + 1, 13) to (start + 0, 23)
- Code(Counter(10)) at (prev + 4, 13) to (start + 0, 19)
- Code(Expression(7, Sub)) at (prev + 2, 13) to (start + 0, 23)
= (c9 - c10)
- Code(Expression(7, Sub)) at (prev + 1, 20) to (start + 0, 27)
= (c9 - c10)
- Code(Expression(2, Sub)) at (prev + 1, 5) to (start + 0, 15)
= (c8 - c9)
- Code(Counter(11)) at (prev + 5, 9) to (start + 3, 16)
- Code(Counter(12)) at (prev + 5, 13) to (start + 0, 27)
- Code(Expression(3, Sub)) at (prev + 2, 13) to (start + 0, 28)
= (c11 - c12)
- Code(Expression(4, Sub)) at (prev + 4, 9) to (start + 2, 15)
= (c8 - (c9 + c11))
- Code(Counter(13)) at (prev + 6, 5) to (start + 0, 15)
- Code(Counter(14)) at (prev + 4, 5) to (start + 0, 15)
- Code(Counter(15)) at (prev + 4, 9) to (start + 1, 15)
- Code(Counter(16)) at (prev + 5, 8) to (start + 0, 15)
- Code(Counter(17)) at (prev + 1, 9) to (start + 0, 19)
- Code(Expression(6, Sub)) at (prev + 5, 9) to (start + 0, 19)
= (c16 - c17)
- Code(Expression(12, Add)) at (prev + 5, 8) to (start + 0, 15)
= (c18 + c19)
- Code(Counter(20)) at (prev + 1, 9) to (start + 0, 19)
- Code(Expression(8, Sub)) at (prev + 3, 13) to (start + 0, 29)
= (c20 - c21)
- Code(Expression(9, Sub)) at (prev + 3, 9) to (start + 0, 19)
= ((c18 + c19) - c20)
- Code(Expression(11, Sub)) at (prev + 3, 13) to (start + 0, 29)
= ((c18 + c19) - (c20 + c22))
- Code(Expression(17, Add)) at (prev + 3, 5) to (start + 0, 15)
= (c21 + c22)
- Code(Expression(17, Add)) at (prev + 1, 12) to (start + 0, 19)
= (c21 + c22)
- Code(Counter(23)) at (prev + 1, 13) to (start + 0, 19)
- Code(Expression(16, Sub)) at (prev + 2, 13) to (start + 0, 19)
= ((c21 + c22) - c23)
- Code(Counter(24)) at (prev + 4, 5) to (start + 2, 19)
- Code(Counter(25)) at (prev + 3, 13) to (start + 0, 19)
- Code(Expression(18, Sub)) at (prev + 2, 13) to (start + 0, 19)
= (c24 - c25)
- Code(Expression(24, Add)) at (prev + 3, 5) to (start + 0, 15)
= (c28 + c29)
- Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19)
- Code(Counter(27)) at (prev + 1, 13) to (start + 0, 23)
- Code(Counter(28)) at (prev + 4, 13) to (start + 0, 19)
- Code(Expression(22, Sub)) at (prev + 2, 13) to (start + 0, 23)
= (c26 - c27)
- Code(Expression(22, Sub)) at (prev + 1, 20) to (start + 0, 27)
= (c26 - c27)
- Code(Zero) at (prev + 1, 21) to (start + 0, 27)
- Code(Expression(22, Sub)) at (prev + 2, 21) to (start + 0, 27)
= (c26 - c27)
- Code(Counter(29)) at (prev + 4, 13) to (start + 0, 19)
- Code(Expression(23, Sub)) at (prev + 3, 9) to (start + 0, 25)
= ((c28 + c29) - c30)
- Code(Counter(30)) at (prev + 2, 5) to (start + 0, 15)
- Code(Expression(25, Sub)) at (prev + 3, 9) to (start + 0, 34)
= (c30 - c31)
- Code(Counter(31)) at (prev + 2, 5) to (start + 0, 15)
- Code(Expression(26, Sub)) at (prev + 3, 9) to (start + 0, 44)
= (c31 - c32)
- Code(Counter(32)) at (prev + 2, 1) to (start + 0, 2)
Highest counter ID seen: c32
- Code(Expression(7, Sub)) at (prev + 2, 21) to (start + 0, 27)
= (c9 - c10)
- Code(Counter(11)) at (prev + 4, 13) to (start + 0, 19)
- Code(Expression(8, Sub)) at (prev + 3, 9) to (start + 0, 25)
= ((c10 + c11) - c12)
- Code(Counter(12)) at (prev + 2, 5) to (start + 0, 15)
- Code(Counter(12)) at (prev + 3, 9) to (start + 0, 34)
- Code(Zero) at (prev + 2, 5) to (start + 0, 15)
- Code(Zero) at (prev + 3, 9) to (start + 0, 44)
- Code(Zero) at (prev + 2, 1) to (start + 0, 2)
Highest counter ID seen: c12

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

bb0: {
StorageLive(_1);
_1 = const <bool as NeedsDrop>::NEEDS;
- _1 = const <bool as NeedsDrop>::NEEDS;
- switchInt(move _1) -> [0: bb2, otherwise: bb1];
+ _1 = const false;
+ switchInt(const false) -> [0: bb2, otherwise: bb1];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

bb0: {
StorageLive(_1);
_1 = const <bool as NeedsDrop>::NEEDS;
- _1 = const <bool as NeedsDrop>::NEEDS;
- switchInt(move _1) -> [0: bb2, otherwise: bb1];
+ _1 = const false;
+ switchInt(const false) -> [0: bb2, otherwise: bb1];
}

Expand Down
14 changes: 9 additions & 5 deletions tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@

bb0: {
StorageLive(_1);
StorageLive(_2);
- StorageLive(_2);
- StorageLive(_3);
+ nop;
+ nop;
_3 = const {ALLOC0: &u8};
_2 = copy (*_3);
- _2 = copy (*_3);
+ _2 = const 2_u8;
StorageLive(_4);
StorageLive(_5);
_5 = const {ALLOC0: &u8};
- _4 = copy (*_5);
+ _4 = copy (*_3);
_1 = Add(move _2, move _4);
- _1 = Add(move _2, move _4);
+ _4 = const 2_u8;
+ _1 = const 4_u8;
StorageDead(_4);
StorageDead(_2);
- StorageDead(_2);
+ nop;
StorageDead(_5);
- StorageDead(_3);
+ nop;
Expand Down
3 changes: 1 addition & 2 deletions tests/mir-opt/const_prop/read_immutable_static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ static FOO: u8 = 2;
fn main() {
// CHECK-LABEL: fn main(
// CHECK: debug x => [[x:_.*]];
// Disabled due to <https://github.com/rust-lang/rust/issues/130853>
// COM: CHECK: [[x]] = const 4_u8;
// CHECK: [[x]] = const 4_u8;
let x = FOO + FOO;
}
3 changes: 2 additions & 1 deletion tests/mir-opt/const_prop/ref_deref.main.GVN.diff
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
StorageLive(_2);
_4 = const main::promoted[0];
_2 = &(*_4);
_1 = copy (*_2);
- _1 = copy (*_2);
+ _1 = const 4_i32;
StorageDead(_2);
_0 = const ();
StorageDead(_1);
Expand Down
3 changes: 2 additions & 1 deletion tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
StorageLive(_2);
_4 = const main::promoted[0];
_2 = &((*_4).1: i32);
_1 = copy (*_2);
- _1 = copy (*_2);
+ _1 = const 5_i32;
StorageDead(_2);
_0 = const ();
StorageDead(_1);
Expand Down
Loading
Loading