diff options
| author | bors <bors@rust-lang.org> | 2025-07-24 20:38:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-07-24 20:38:53 +0000 |
| commit | b56aaec52bc0fa35591a872fb4aac81f606e265c (patch) | |
| tree | 6265c613fe25072d6dbe81c96c8421d7fe774bf5 /tests/mir-opt/building | |
| parent | 246733a3d978de41c5b77b8120ba8f41592df9f1 (diff) | |
| parent | 01524abb05a4a60d0015972811b8bbb9bd2a73d3 (diff) | |
| download | rust-b56aaec52bc0fa35591a872fb4aac81f606e265c.tar.gz rust-b56aaec52bc0fa35591a872fb4aac81f606e265c.zip | |
Auto merge of #144389 - scottmcm:no-more-mir-cast-assume, r=davidtwco
MIR-build: No longer emit assumes in enum-as casting This just uses the `valid_range` from the backend, so it's duplicating the range metadata that now we include on parameters and loads, and thus no longer seems to be useful -- notably there's no codegen test failures from removing it. (Because it's using data from the same source as the backend annotations, it doesn't do anything to mitigate things like rust-lang/rust#144388 where the range in the layout is more permissive than the actual possible discriminants. A variant of this that actually checked the discriminants more specifically might be useful, so could potentially be added in future, but I don't think the *current* checks are actually providing value.) r? mir Randomly turns out that this Fixes https://github.com/rust-lang/rust/issues/121097
Diffstat (limited to 'tests/mir-opt/building')
6 files changed, 7 insertions, 33 deletions
diff --git a/tests/mir-opt/building/enum_cast.bar.built.after.mir b/tests/mir-opt/building/enum_cast.bar.built.after.mir index 72d0cf5d1e8..0dc6448ffad 100644 --- a/tests/mir-opt/building/enum_cast.bar.built.after.mir +++ b/tests/mir-opt/building/enum_cast.bar.built.after.mir @@ -5,16 +5,11 @@ fn bar(_1: Bar) -> usize { let mut _0: usize; let _2: Bar; let mut _3: isize; - let mut _4: u8; - let mut _5: bool; bb0: { StorageLive(_2); _2 = move _1; _3 = discriminant(_2); - _4 = copy _3 as u8 (IntToInt); - _5 = Le(copy _4, const 1_u8); - assume(move _5); _0 = move _3 as usize (IntToInt); StorageDead(_2); return; diff --git a/tests/mir-opt/building/enum_cast.boo.built.after.mir b/tests/mir-opt/building/enum_cast.boo.built.after.mir index 91e06dc8862..3540a2b1e2e 100644 --- a/tests/mir-opt/building/enum_cast.boo.built.after.mir +++ b/tests/mir-opt/building/enum_cast.boo.built.after.mir @@ -5,16 +5,11 @@ fn boo(_1: Boo) -> usize { let mut _0: usize; let _2: Boo; let mut _3: u8; - let mut _4: u8; - let mut _5: bool; bb0: { StorageLive(_2); _2 = move _1; _3 = discriminant(_2); - _4 = copy _3 as u8 (IntToInt); - _5 = Le(copy _4, const 1_u8); - assume(move _5); _0 = move _3 as usize (IntToInt); StorageDead(_2); return; diff --git a/tests/mir-opt/building/enum_cast.far.built.after.mir b/tests/mir-opt/building/enum_cast.far.built.after.mir index 14eaf344190..da34b7ba6c2 100644 --- a/tests/mir-opt/building/enum_cast.far.built.after.mir +++ b/tests/mir-opt/building/enum_cast.far.built.after.mir @@ -5,16 +5,11 @@ fn far(_1: Far) -> isize { let mut _0: isize; let _2: Far; let mut _3: i16; - let mut _4: u16; - let mut _5: bool; bb0: { StorageLive(_2); _2 = move _1; _3 = discriminant(_2); - _4 = copy _3 as u16 (IntToInt); - _5 = Le(copy _4, const 1_u16); - assume(move _5); _0 = move _3 as isize (IntToInt); StorageDead(_2); return; diff --git a/tests/mir-opt/building/enum_cast.offsetty.built.after.mir b/tests/mir-opt/building/enum_cast.offsetty.built.after.mir index 1c2acbe3023..b84ce0de9a0 100644 --- a/tests/mir-opt/building/enum_cast.offsetty.built.after.mir +++ b/tests/mir-opt/building/enum_cast.offsetty.built.after.mir @@ -5,20 +5,11 @@ fn offsetty(_1: NotStartingAtZero) -> u32 { let mut _0: u32; let _2: NotStartingAtZero; let mut _3: isize; - let mut _4: u8; - let mut _5: bool; - let mut _6: bool; - let mut _7: bool; bb0: { StorageLive(_2); _2 = move _1; _3 = discriminant(_2); - _4 = copy _3 as u8 (IntToInt); - _5 = Ge(copy _4, const 4_u8); - _6 = Le(copy _4, const 8_u8); - _7 = BitAnd(move _5, move _6); - assume(move _7); _0 = move _3 as u32 (IntToInt); StorageDead(_2); return; diff --git a/tests/mir-opt/building/enum_cast.rs b/tests/mir-opt/building/enum_cast.rs index 4fb9a27e309..eaf5537e0ab 100644 --- a/tests/mir-opt/building/enum_cast.rs +++ b/tests/mir-opt/building/enum_cast.rs @@ -4,6 +4,13 @@ // EMIT_MIR enum_cast.boo.built.after.mir // EMIT_MIR enum_cast.far.built.after.mir +// Previously MIR building included range `Assume`s in the MIR statements, +// which these tests demonstrated, but now that we have range metadata on +// parameters in LLVM (in addition to !range metadata on loads) the impact +// of the extra volume of MIR is worse than its value. +// Thus these are now about the discriminant type and the cast type, +// both of which might be different from the backend type of the tag. + enum Foo { A, } diff --git a/tests/mir-opt/building/enum_cast.signy.built.after.mir b/tests/mir-opt/building/enum_cast.signy.built.after.mir index 39b6dfaf005..503c506748f 100644 --- a/tests/mir-opt/building/enum_cast.signy.built.after.mir +++ b/tests/mir-opt/building/enum_cast.signy.built.after.mir @@ -5,20 +5,11 @@ fn signy(_1: SignedAroundZero) -> i16 { let mut _0: i16; let _2: SignedAroundZero; let mut _3: i16; - let mut _4: u16; - let mut _5: bool; - let mut _6: bool; - let mut _7: bool; bb0: { StorageLive(_2); _2 = move _1; _3 = discriminant(_2); - _4 = copy _3 as u16 (IntToInt); - _5 = Ge(copy _4, const 65534_u16); - _6 = Le(copy _4, const 2_u16); - _7 = BitOr(move _5, move _6); - assume(move _7); _0 = move _3 as i16 (IntToInt); StorageDead(_2); return; |
