Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5e0d0d8

Browse files
committedSep 20, 2023
Evaluated computed values to constants.
1 parent e64137c commit 5e0d0d8

16 files changed

+523
-181
lines changed
 

‎compiler/rustc_const_eval/src/interpret/discriminant.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Functions for reading and writing discriminants of multi-variant layouts (enums and generators).
22
3-
use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout};
4-
use rustc_middle::{mir, ty};
3+
use rustc_middle::mir;
4+
use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt};
5+
use rustc_middle::ty::{self, Ty};
56
use rustc_target::abi::{self, TagEncoding};
67
use rustc_target::abi::{VariantIdx, Variants};
78

@@ -245,11 +246,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
245246

246247
pub fn discriminant_for_variant(
247248
&self,
248-
layout: TyAndLayout<'tcx>,
249+
ty: Ty<'tcx>,
249250
variant: VariantIdx,
250251
) -> InterpResult<'tcx, ImmTy<'tcx, M::Provenance>> {
251-
let discr_layout = self.layout_of(layout.ty.discriminant_ty(*self.tcx))?;
252-
let discr_value = match layout.ty.discriminant_for_variant(*self.tcx, variant) {
252+
let discr_layout = self.layout_of(ty.discriminant_ty(*self.tcx))?;
253+
let discr_value = match ty.discriminant_for_variant(*self.tcx, variant) {
253254
Some(discr) => {
254255
// This type actually has discriminants.
255256
assert_eq!(discr.ty, discr_layout.ty);

‎compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
219219
sym::discriminant_value => {
220220
let place = self.deref_pointer(&args[0])?;
221221
let variant = self.read_discriminant(&place)?;
222-
let discr = self.discriminant_for_variant(place.layout, variant)?;
222+
let discr = self.discriminant_for_variant(place.layout.ty, variant)?;
223223
self.write_immediate(*discr, dest)?;
224224
}
225225
sym::exact_div => {

‎compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
157157
ImmTy { imm: val.into(), layout }
158158
}
159159

160+
#[inline]
161+
pub fn from_scalar_pair(a: Scalar<Prov>, b: Scalar<Prov>, layout: TyAndLayout<'tcx>) -> Self {
162+
debug_assert!(
163+
matches!(layout.abi, Abi::ScalarPair(..)),
164+
"`ImmTy::from_scalar_pair` on non-scalar-pair layout"
165+
);
166+
let imm = Immediate::ScalarPair(a, b);
167+
ImmTy { imm, layout }
168+
}
169+
160170
#[inline(always)]
161171
pub fn from_immediate(imm: Immediate<Prov>, layout: TyAndLayout<'tcx>) -> Self {
162172
debug_assert!(layout.is_sized(), "immediates must be sized");

‎compiler/rustc_const_eval/src/interpret/step.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
300300
Discriminant(place) => {
301301
let op = self.eval_place_to_op(place, None)?;
302302
let variant = self.read_discriminant(&op)?;
303-
let discr = self.discriminant_for_variant(op.layout, variant)?;
303+
let discr = self.discriminant_for_variant(op.layout.ty, variant)?;
304304
self.write_immediate(*discr, &dest)?;
305305
}
306306
}

‎compiler/rustc_middle/src/mir/consts.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,20 @@ impl<'tcx> ConstValue<'tcx> {
165165
// This is for diagnostics only, so we are okay to use `inspect_with_uninit_and_ptr_outside_interpreter`.
166166
Some(data.inner().inspect_with_uninit_and_ptr_outside_interpreter(start..end))
167167
}
168+
169+
pub fn has_provenance(&self, tcx: TyCtxt<'tcx>, size: Size) -> bool {
170+
let (alloc, start, end) = match *self {
171+
ConstValue::ZeroSized | ConstValue::Scalar(Scalar::Int(_)) => return false,
172+
ConstValue::Scalar(Scalar::Ptr(..)) => return true,
173+
ConstValue::Slice { data, start, end } => {
174+
(data, Size::from_bytes(start), Size::from_bytes(end))
175+
}
176+
ConstValue::Indirect { alloc_id, offset } => {
177+
(tcx.global_alloc(alloc_id).unwrap_memory(), offset, offset + size)
178+
}
179+
};
180+
!alloc.inner().provenance().range_empty(super::AllocRange::from(start..end), &tcx)
181+
}
168182
}
169183

170184
///////////////////////////////////////////////////////////////////////////

‎compiler/rustc_mir_transform/src/dataflow_const_prop.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
400400
TrackElem::Variant(idx) => self.ecx.project_downcast(op, idx).ok(),
401401
TrackElem::Discriminant => {
402402
let variant = self.ecx.read_discriminant(op).ok()?;
403-
let discr_value = self.ecx.discriminant_for_variant(op.layout, variant).ok()?;
403+
let discr_value =
404+
self.ecx.discriminant_for_variant(op.layout.ty, variant).ok()?;
404405
Some(discr_value.into())
405406
}
406407
TrackElem::DerefLen => {
@@ -499,7 +500,8 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
499500
return None;
500501
}
501502
let enum_ty_layout = self.tcx.layout_of(self.param_env.and(enum_ty)).ok()?;
502-
let discr_value = self.ecx.discriminant_for_variant(enum_ty_layout, variant_index).ok()?;
503+
let discr_value =
504+
self.ecx.discriminant_for_variant(enum_ty_layout.ty, variant_index).ok()?;
503505
Some(discr_value.to_scalar())
504506
}
505507

@@ -693,7 +695,7 @@ impl<'tcx> Visitor<'tcx> for OperandCollector<'tcx, '_, '_, '_> {
693695
}
694696
}
695697

696-
struct DummyMachine;
698+
pub(crate) struct DummyMachine;
697699

698700
impl<'mir, 'tcx: 'mir> rustc_const_eval::interpret::Machine<'mir, 'tcx> for DummyMachine {
699701
rustc_const_eval::interpret::compile_time_machine!(<'mir, 'tcx>);
@@ -708,8 +710,9 @@ impl<'mir, 'tcx: 'mir> rustc_const_eval::interpret::Machine<'mir, 'tcx> for Dumm
708710
}
709711

710712
fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>, _layout: TyAndLayout<'tcx>) -> bool {
711-
unimplemented!()
713+
false
712714
}
715+
713716
fn alignment_check_failed(
714717
_ecx: &InterpCx<'mir, 'tcx, Self>,
715718
_has: Align,

‎compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 247 additions & 10 deletions
Large diffs are not rendered by default.

‎tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
+ debug ((f: (bool, bool, u32)).2: u32) => const 123_u32;
3636
let _6: std::option::Option<u16>;
3737
scope 7 {
38-
debug o => _6;
38+
- debug o => _6;
39+
+ debug o => const Option::<u16>::Some(99_u16);
3940
let _11: u32;
4041
let _12: u32;
4142
scope 8 {
@@ -72,7 +73,7 @@
7273
_9 = const false;
7374
_10 = const 123_u32;
7475
StorageLive(_6);
75-
_6 = Option::<u16>::Some(const 99_u16);
76+
_6 = const Option::<u16>::Some(99_u16);
7677
_11 = const 32_u32;
7778
_12 = const 32_u32;
7879
StorageLive(_7);
@@ -88,3 +89,7 @@
8889
}
8990
}
9091

92+
alloc11 (size: 4, align: 2) {
93+
01 00 63 00 │ ..c.
94+
}
95+

‎tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@
121121
StorageLive(_15);
122122
StorageLive(_16);
123123
_16 = _1;
124-
_17 = Eq(const 0_u64, const 0_u64);
124+
- _17 = Eq(const 0_u64, const 0_u64);
125125
- assert(!move _17, "attempt to divide `{}` by zero", _16) -> [success: bb5, unwind unreachable];
126-
+ assert(!_17, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind unreachable];
126+
+ _17 = const true;
127+
+ assert(!const true, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind unreachable];
127128
}
128129

129130
bb5: {
@@ -140,9 +141,10 @@
140141
StorageLive(_19);
141142
StorageLive(_20);
142143
_20 = _1;
143-
_21 = Eq(const 1_u64, const 0_u64);
144+
- _21 = Eq(const 1_u64, const 0_u64);
144145
- assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb7, unwind unreachable];
145-
+ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind unreachable];
146+
+ _21 = const false;
147+
+ assert(!const false, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind unreachable];
146148
}
147149

148150
bb7: {
@@ -201,8 +203,8 @@
201203
_32 = _1;
202204
- _33 = Eq(const 0_u64, const 0_u64);
203205
- assert(!move _33, "attempt to calculate the remainder of `{}` with a divisor of zero", _32) -> [success: bb13, unwind unreachable];
204-
+ _33 = _17;
205-
+ assert(!_17, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind unreachable];
206+
+ _33 = const true;
207+
+ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind unreachable];
206208
}
207209

208210
bb13: {
@@ -221,8 +223,8 @@
221223
_36 = _1;
222224
- _37 = Eq(const 1_u64, const 0_u64);
223225
- assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb15, unwind unreachable];
224-
+ _37 = _21;
225-
+ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind unreachable];
226+
+ _37 = const false;
227+
+ assert(!const false, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind unreachable];
226228
}
227229

228230
bb15: {

‎tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@
121121
StorageLive(_15);
122122
StorageLive(_16);
123123
_16 = _1;
124-
_17 = Eq(const 0_u64, const 0_u64);
124+
- _17 = Eq(const 0_u64, const 0_u64);
125125
- assert(!move _17, "attempt to divide `{}` by zero", _16) -> [success: bb5, unwind continue];
126-
+ assert(!_17, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind continue];
126+
+ _17 = const true;
127+
+ assert(!const true, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind continue];
127128
}
128129

129130
bb5: {
@@ -140,9 +141,10 @@
140141
StorageLive(_19);
141142
StorageLive(_20);
142143
_20 = _1;
143-
_21 = Eq(const 1_u64, const 0_u64);
144+
- _21 = Eq(const 1_u64, const 0_u64);
144145
- assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb7, unwind continue];
145-
+ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind continue];
146+
+ _21 = const false;
147+
+ assert(!const false, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind continue];
146148
}
147149

148150
bb7: {
@@ -201,8 +203,8 @@
201203
_32 = _1;
202204
- _33 = Eq(const 0_u64, const 0_u64);
203205
- assert(!move _33, "attempt to calculate the remainder of `{}` with a divisor of zero", _32) -> [success: bb13, unwind continue];
204-
+ _33 = _17;
205-
+ assert(!_17, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind continue];
206+
+ _33 = const true;
207+
+ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind continue];
206208
}
207209

208210
bb13: {
@@ -221,8 +223,8 @@
221223
_36 = _1;
222224
- _37 = Eq(const 1_u64, const 0_u64);
223225
- assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb15, unwind continue];
224-
+ _37 = _21;
225-
+ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind continue];
226+
+ _37 = const false;
227+
+ assert(!const false, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind continue];
226228
}
227229

228230
bb15: {

‎tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@
153153
StorageLive(_19);
154154
StorageLive(_20);
155155
_20 = _1;
156-
_21 = Eq(const 0_u64, const 0_u64);
156+
- _21 = Eq(const 0_u64, const 0_u64);
157157
- assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb9, unwind unreachable];
158-
+ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb9, unwind unreachable];
158+
+ _21 = const true;
159+
+ assert(!const true, "attempt to divide `{}` by zero", _1) -> [success: bb9, unwind unreachable];
159160
}
160161

161162
bb9: {
@@ -172,9 +173,10 @@
172173
StorageLive(_23);
173174
StorageLive(_24);
174175
_24 = _1;
175-
_25 = Eq(const 1_u64, const 0_u64);
176+
- _25 = Eq(const 1_u64, const 0_u64);
176177
- assert(!move _25, "attempt to divide `{}` by zero", _24) -> [success: bb11, unwind unreachable];
177-
+ assert(!_25, "attempt to divide `{}` by zero", _1) -> [success: bb11, unwind unreachable];
178+
+ _25 = const false;
179+
+ assert(!const false, "attempt to divide `{}` by zero", _1) -> [success: bb11, unwind unreachable];
178180
}
179181

180182
bb11: {
@@ -233,8 +235,8 @@
233235
_36 = _1;
234236
- _37 = Eq(const 0_u64, const 0_u64);
235237
- assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb17, unwind unreachable];
236-
+ _37 = _21;
237-
+ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb17, unwind unreachable];
238+
+ _37 = const true;
239+
+ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb17, unwind unreachable];
238240
}
239241

240242
bb17: {
@@ -253,8 +255,8 @@
253255
_40 = _1;
254256
- _41 = Eq(const 1_u64, const 0_u64);
255257
- assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", _40) -> [success: bb19, unwind unreachable];
256-
+ _41 = _25;
257-
+ assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb19, unwind unreachable];
258+
+ _41 = const false;
259+
+ assert(!const false, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb19, unwind unreachable];
258260
}
259261

260262
bb19: {
@@ -350,11 +352,12 @@
350352
StorageLive(_60);
351353
StorageLive(_61);
352354
_61 = _1;
353-
_62 = const 0_i32 as u32 (IntToInt);
355+
- _62 = const 0_i32 as u32 (IntToInt);
354356
- _63 = Lt(move _62, const 64_u32);
355357
- assert(move _63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind unreachable];
356-
+ _63 = Lt(_62, const 64_u32);
357-
+ assert(_63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind unreachable];
358+
+ _62 = const 0_u32;
359+
+ _63 = const true;
360+
+ assert(const true, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind unreachable];
358361
}
359362

360363
bb28: {
@@ -374,9 +377,9 @@
374377
- _67 = const 0_i32 as u32 (IntToInt);
375378
- _68 = Lt(move _67, const 64_u32);
376379
- assert(move _68, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind unreachable];
377-
+ _67 = _62;
378-
+ _68 = _63;
379-
+ assert(_63, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind unreachable];
380+
+ _67 = const 0_u32;
381+
+ _68 = const true;
382+
+ assert(const true, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind unreachable];
380383
}
381384

382385
bb30: {

‎tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@
153153
StorageLive(_19);
154154
StorageLive(_20);
155155
_20 = _1;
156-
_21 = Eq(const 0_u64, const 0_u64);
156+
- _21 = Eq(const 0_u64, const 0_u64);
157157
- assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb9, unwind continue];
158-
+ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb9, unwind continue];
158+
+ _21 = const true;
159+
+ assert(!const true, "attempt to divide `{}` by zero", _1) -> [success: bb9, unwind continue];
159160
}
160161

161162
bb9: {
@@ -172,9 +173,10 @@
172173
StorageLive(_23);
173174
StorageLive(_24);
174175
_24 = _1;
175-
_25 = Eq(const 1_u64, const 0_u64);
176+
- _25 = Eq(const 1_u64, const 0_u64);
176177
- assert(!move _25, "attempt to divide `{}` by zero", _24) -> [success: bb11, unwind continue];
177-
+ assert(!_25, "attempt to divide `{}` by zero", _1) -> [success: bb11, unwind continue];
178+
+ _25 = const false;
179+
+ assert(!const false, "attempt to divide `{}` by zero", _1) -> [success: bb11, unwind continue];
178180
}
179181

180182
bb11: {
@@ -233,8 +235,8 @@
233235
_36 = _1;
234236
- _37 = Eq(const 0_u64, const 0_u64);
235237
- assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb17, unwind continue];
236-
+ _37 = _21;
237-
+ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb17, unwind continue];
238+
+ _37 = const true;
239+
+ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb17, unwind continue];
238240
}
239241

240242
bb17: {
@@ -253,8 +255,8 @@
253255
_40 = _1;
254256
- _41 = Eq(const 1_u64, const 0_u64);
255257
- assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", _40) -> [success: bb19, unwind continue];
256-
+ _41 = _25;
257-
+ assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb19, unwind continue];
258+
+ _41 = const false;
259+
+ assert(!const false, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb19, unwind continue];
258260
}
259261

260262
bb19: {
@@ -350,11 +352,12 @@
350352
StorageLive(_60);
351353
StorageLive(_61);
352354
_61 = _1;
353-
_62 = const 0_i32 as u32 (IntToInt);
355+
- _62 = const 0_i32 as u32 (IntToInt);
354356
- _63 = Lt(move _62, const 64_u32);
355357
- assert(move _63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind continue];
356-
+ _63 = Lt(_62, const 64_u32);
357-
+ assert(_63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind continue];
358+
+ _62 = const 0_u32;
359+
+ _63 = const true;
360+
+ assert(const true, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind continue];
358361
}
359362

360363
bb28: {
@@ -374,9 +377,9 @@
374377
- _67 = const 0_i32 as u32 (IntToInt);
375378
- _68 = Lt(move _67, const 64_u32);
376379
- assert(move _68, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind continue];
377-
+ _67 = _62;
378-
+ _68 = _63;
379-
+ assert(_63, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind continue];
380+
+ _67 = const 0_u32;
381+
+ _68 = const true;
382+
+ assert(const true, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind continue];
380383
}
381384

382385
bb30: {

‎tests/mir-opt/gvn.cast.GVN.panic-abort.diff

Lines changed: 81 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@
119119
- _6 = _1;
120120
- _5 = move _6 as u8 (IntToInt);
121121
+ _6 = const 1_i64;
122-
+ _5 = const 1_i64 as u8 (IntToInt);
122+
+ _5 = const 1_u8;
123123
StorageDead(_6);
124-
_4 = opaque::<u8>(move _5) -> [return: bb1, unwind unreachable];
124+
- _4 = opaque::<u8>(move _5) -> [return: bb1, unwind unreachable];
125+
+ _4 = opaque::<u8>(const 1_u8) -> [return: bb1, unwind unreachable];
125126
}
126127

127128
bb1: {
@@ -133,9 +134,10 @@
133134
- _9 = _1;
134135
- _8 = move _9 as u16 (IntToInt);
135136
+ _9 = const 1_i64;
136-
+ _8 = const 1_i64 as u16 (IntToInt);
137+
+ _8 = const 1_u16;
137138
StorageDead(_9);
138-
_7 = opaque::<u16>(move _8) -> [return: bb2, unwind unreachable];
139+
- _7 = opaque::<u16>(move _8) -> [return: bb2, unwind unreachable];
140+
+ _7 = opaque::<u16>(const 1_u16) -> [return: bb2, unwind unreachable];
139141
}
140142

141143
bb2: {
@@ -147,9 +149,10 @@
147149
- _12 = _1;
148150
- _11 = move _12 as u32 (IntToInt);
149151
+ _12 = const 1_i64;
150-
+ _11 = const 1_i64 as u32 (IntToInt);
152+
+ _11 = const 1_u32;
151153
StorageDead(_12);
152-
_10 = opaque::<u32>(move _11) -> [return: bb3, unwind unreachable];
154+
- _10 = opaque::<u32>(move _11) -> [return: bb3, unwind unreachable];
155+
+ _10 = opaque::<u32>(const 1_u32) -> [return: bb3, unwind unreachable];
153156
}
154157

155158
bb3: {
@@ -161,9 +164,10 @@
161164
- _15 = _1;
162165
- _14 = move _15 as u64 (IntToInt);
163166
+ _15 = const 1_i64;
164-
+ _14 = const 1_i64 as u64 (IntToInt);
167+
+ _14 = const 1_u64;
165168
StorageDead(_15);
166-
_13 = opaque::<u64>(move _14) -> [return: bb4, unwind unreachable];
169+
- _13 = opaque::<u64>(move _14) -> [return: bb4, unwind unreachable];
170+
+ _13 = opaque::<u64>(const 1_u64) -> [return: bb4, unwind unreachable];
167171
}
168172

169173
bb4: {
@@ -175,9 +179,10 @@
175179
- _18 = _1;
176180
- _17 = move _18 as i8 (IntToInt);
177181
+ _18 = const 1_i64;
178-
+ _17 = const 1_i64 as i8 (IntToInt);
182+
+ _17 = const 1_i8;
179183
StorageDead(_18);
180-
_16 = opaque::<i8>(move _17) -> [return: bb5, unwind unreachable];
184+
- _16 = opaque::<i8>(move _17) -> [return: bb5, unwind unreachable];
185+
+ _16 = opaque::<i8>(const 1_i8) -> [return: bb5, unwind unreachable];
181186
}
182187

183188
bb5: {
@@ -189,9 +194,10 @@
189194
- _21 = _1;
190195
- _20 = move _21 as i16 (IntToInt);
191196
+ _21 = const 1_i64;
192-
+ _20 = const 1_i64 as i16 (IntToInt);
197+
+ _20 = const 1_i16;
193198
StorageDead(_21);
194-
_19 = opaque::<i16>(move _20) -> [return: bb6, unwind unreachable];
199+
- _19 = opaque::<i16>(move _20) -> [return: bb6, unwind unreachable];
200+
+ _19 = opaque::<i16>(const 1_i16) -> [return: bb6, unwind unreachable];
195201
}
196202

197203
bb6: {
@@ -203,9 +209,10 @@
203209
- _24 = _1;
204210
- _23 = move _24 as i32 (IntToInt);
205211
+ _24 = const 1_i64;
206-
+ _23 = const 1_i64 as i32 (IntToInt);
212+
+ _23 = const 1_i32;
207213
StorageDead(_24);
208-
_22 = opaque::<i32>(move _23) -> [return: bb7, unwind unreachable];
214+
- _22 = opaque::<i32>(move _23) -> [return: bb7, unwind unreachable];
215+
+ _22 = opaque::<i32>(const 1_i32) -> [return: bb7, unwind unreachable];
209216
}
210217

211218
bb7: {
@@ -228,9 +235,10 @@
228235
- _29 = _1;
229236
- _28 = move _29 as f32 (IntToFloat);
230237
+ _29 = const 1_i64;
231-
+ _28 = const 1_i64 as f32 (IntToFloat);
238+
+ _28 = const 1f32;
232239
StorageDead(_29);
233-
_27 = opaque::<f32>(move _28) -> [return: bb9, unwind unreachable];
240+
- _27 = opaque::<f32>(move _28) -> [return: bb9, unwind unreachable];
241+
+ _27 = opaque::<f32>(const 1f32) -> [return: bb9, unwind unreachable];
234242
}
235243

236244
bb9: {
@@ -242,9 +250,10 @@
242250
- _32 = _1;
243251
- _31 = move _32 as f64 (IntToFloat);
244252
+ _32 = const 1_i64;
245-
+ _31 = const 1_i64 as f64 (IntToFloat);
253+
+ _31 = const 1f64;
246254
StorageDead(_32);
247-
_30 = opaque::<f64>(move _31) -> [return: bb10, unwind unreachable];
255+
- _30 = opaque::<f64>(move _31) -> [return: bb10, unwind unreachable];
256+
+ _30 = opaque::<f64>(const 1f64) -> [return: bb10, unwind unreachable];
248257
}
249258

250259
bb10: {
@@ -256,9 +265,10 @@
256265
- _35 = _2;
257266
- _34 = move _35 as u8 (IntToInt);
258267
+ _35 = const 1_u64;
259-
+ _34 = const 1_u64 as u8 (IntToInt);
268+
+ _34 = const 1_u8;
260269
StorageDead(_35);
261-
_33 = opaque::<u8>(move _34) -> [return: bb11, unwind unreachable];
270+
- _33 = opaque::<u8>(move _34) -> [return: bb11, unwind unreachable];
271+
+ _33 = opaque::<u8>(const 1_u8) -> [return: bb11, unwind unreachable];
262272
}
263273

264274
bb11: {
@@ -270,9 +280,10 @@
270280
- _38 = _2;
271281
- _37 = move _38 as u16 (IntToInt);
272282
+ _38 = const 1_u64;
273-
+ _37 = const 1_u64 as u16 (IntToInt);
283+
+ _37 = const 1_u16;
274284
StorageDead(_38);
275-
_36 = opaque::<u16>(move _37) -> [return: bb12, unwind unreachable];
285+
- _36 = opaque::<u16>(move _37) -> [return: bb12, unwind unreachable];
286+
+ _36 = opaque::<u16>(const 1_u16) -> [return: bb12, unwind unreachable];
276287
}
277288

278289
bb12: {
@@ -284,9 +295,10 @@
284295
- _41 = _2;
285296
- _40 = move _41 as u32 (IntToInt);
286297
+ _41 = const 1_u64;
287-
+ _40 = const 1_u64 as u32 (IntToInt);
298+
+ _40 = const 1_u32;
288299
StorageDead(_41);
289-
_39 = opaque::<u32>(move _40) -> [return: bb13, unwind unreachable];
300+
- _39 = opaque::<u32>(move _40) -> [return: bb13, unwind unreachable];
301+
+ _39 = opaque::<u32>(const 1_u32) -> [return: bb13, unwind unreachable];
290302
}
291303

292304
bb13: {
@@ -309,9 +321,10 @@
309321
- _46 = _2;
310322
- _45 = move _46 as i8 (IntToInt);
311323
+ _46 = const 1_u64;
312-
+ _45 = const 1_u64 as i8 (IntToInt);
324+
+ _45 = const 1_i8;
313325
StorageDead(_46);
314-
_44 = opaque::<i8>(move _45) -> [return: bb15, unwind unreachable];
326+
- _44 = opaque::<i8>(move _45) -> [return: bb15, unwind unreachable];
327+
+ _44 = opaque::<i8>(const 1_i8) -> [return: bb15, unwind unreachable];
315328
}
316329

317330
bb15: {
@@ -323,9 +336,10 @@
323336
- _49 = _2;
324337
- _48 = move _49 as i16 (IntToInt);
325338
+ _49 = const 1_u64;
326-
+ _48 = const 1_u64 as i16 (IntToInt);
339+
+ _48 = const 1_i16;
327340
StorageDead(_49);
328-
_47 = opaque::<i16>(move _48) -> [return: bb16, unwind unreachable];
341+
- _47 = opaque::<i16>(move _48) -> [return: bb16, unwind unreachable];
342+
+ _47 = opaque::<i16>(const 1_i16) -> [return: bb16, unwind unreachable];
329343
}
330344

331345
bb16: {
@@ -337,9 +351,10 @@
337351
- _52 = _2;
338352
- _51 = move _52 as i32 (IntToInt);
339353
+ _52 = const 1_u64;
340-
+ _51 = const 1_u64 as i32 (IntToInt);
354+
+ _51 = const 1_i32;
341355
StorageDead(_52);
342-
_50 = opaque::<i32>(move _51) -> [return: bb17, unwind unreachable];
356+
- _50 = opaque::<i32>(move _51) -> [return: bb17, unwind unreachable];
357+
+ _50 = opaque::<i32>(const 1_i32) -> [return: bb17, unwind unreachable];
343358
}
344359

345360
bb17: {
@@ -351,9 +366,10 @@
351366
- _55 = _2;
352367
- _54 = move _55 as i64 (IntToInt);
353368
+ _55 = const 1_u64;
354-
+ _54 = const 1_u64 as i64 (IntToInt);
369+
+ _54 = const 1_i64;
355370
StorageDead(_55);
356-
_53 = opaque::<i64>(move _54) -> [return: bb18, unwind unreachable];
371+
- _53 = opaque::<i64>(move _54) -> [return: bb18, unwind unreachable];
372+
+ _53 = opaque::<i64>(const 1_i64) -> [return: bb18, unwind unreachable];
357373
}
358374

359375
bb18: {
@@ -365,9 +381,10 @@
365381
- _58 = _2;
366382
- _57 = move _58 as f32 (IntToFloat);
367383
+ _58 = const 1_u64;
368-
+ _57 = const 1_u64 as f32 (IntToFloat);
384+
+ _57 = const 1f32;
369385
StorageDead(_58);
370-
_56 = opaque::<f32>(move _57) -> [return: bb19, unwind unreachable];
386+
- _56 = opaque::<f32>(move _57) -> [return: bb19, unwind unreachable];
387+
+ _56 = opaque::<f32>(const 1f32) -> [return: bb19, unwind unreachable];
371388
}
372389

373390
bb19: {
@@ -379,9 +396,10 @@
379396
- _61 = _2;
380397
- _60 = move _61 as f64 (IntToFloat);
381398
+ _61 = const 1_u64;
382-
+ _60 = const 1_u64 as f64 (IntToFloat);
399+
+ _60 = const 1f64;
383400
StorageDead(_61);
384-
_59 = opaque::<f64>(move _60) -> [return: bb20, unwind unreachable];
401+
- _59 = opaque::<f64>(move _60) -> [return: bb20, unwind unreachable];
402+
+ _59 = opaque::<f64>(const 1f64) -> [return: bb20, unwind unreachable];
385403
}
386404

387405
bb20: {
@@ -393,9 +411,10 @@
393411
- _64 = _3;
394412
- _63 = move _64 as u8 (FloatToInt);
395413
+ _64 = const 1f64;
396-
+ _63 = const 1f64 as u8 (FloatToInt);
414+
+ _63 = const 1_u8;
397415
StorageDead(_64);
398-
_62 = opaque::<u8>(move _63) -> [return: bb21, unwind unreachable];
416+
- _62 = opaque::<u8>(move _63) -> [return: bb21, unwind unreachable];
417+
+ _62 = opaque::<u8>(const 1_u8) -> [return: bb21, unwind unreachable];
399418
}
400419

401420
bb21: {
@@ -407,9 +426,10 @@
407426
- _67 = _3;
408427
- _66 = move _67 as u16 (FloatToInt);
409428
+ _67 = const 1f64;
410-
+ _66 = const 1f64 as u16 (FloatToInt);
429+
+ _66 = const 1_u16;
411430
StorageDead(_67);
412-
_65 = opaque::<u16>(move _66) -> [return: bb22, unwind unreachable];
431+
- _65 = opaque::<u16>(move _66) -> [return: bb22, unwind unreachable];
432+
+ _65 = opaque::<u16>(const 1_u16) -> [return: bb22, unwind unreachable];
413433
}
414434

415435
bb22: {
@@ -421,9 +441,10 @@
421441
- _70 = _3;
422442
- _69 = move _70 as u32 (FloatToInt);
423443
+ _70 = const 1f64;
424-
+ _69 = const 1f64 as u32 (FloatToInt);
444+
+ _69 = const 1_u32;
425445
StorageDead(_70);
426-
_68 = opaque::<u32>(move _69) -> [return: bb23, unwind unreachable];
446+
- _68 = opaque::<u32>(move _69) -> [return: bb23, unwind unreachable];
447+
+ _68 = opaque::<u32>(const 1_u32) -> [return: bb23, unwind unreachable];
427448
}
428449

429450
bb23: {
@@ -435,9 +456,10 @@
435456
- _73 = _3;
436457
- _72 = move _73 as u64 (FloatToInt);
437458
+ _73 = const 1f64;
438-
+ _72 = const 1f64 as u64 (FloatToInt);
459+
+ _72 = const 1_u64;
439460
StorageDead(_73);
440-
_71 = opaque::<u64>(move _72) -> [return: bb24, unwind unreachable];
461+
- _71 = opaque::<u64>(move _72) -> [return: bb24, unwind unreachable];
462+
+ _71 = opaque::<u64>(const 1_u64) -> [return: bb24, unwind unreachable];
441463
}
442464

443465
bb24: {
@@ -449,9 +471,10 @@
449471
- _76 = _3;
450472
- _75 = move _76 as i8 (FloatToInt);
451473
+ _76 = const 1f64;
452-
+ _75 = const 1f64 as i8 (FloatToInt);
474+
+ _75 = const 1_i8;
453475
StorageDead(_76);
454-
_74 = opaque::<i8>(move _75) -> [return: bb25, unwind unreachable];
476+
- _74 = opaque::<i8>(move _75) -> [return: bb25, unwind unreachable];
477+
+ _74 = opaque::<i8>(const 1_i8) -> [return: bb25, unwind unreachable];
455478
}
456479

457480
bb25: {
@@ -463,9 +486,10 @@
463486
- _79 = _3;
464487
- _78 = move _79 as i16 (FloatToInt);
465488
+ _79 = const 1f64;
466-
+ _78 = const 1f64 as i16 (FloatToInt);
489+
+ _78 = const 1_i16;
467490
StorageDead(_79);
468-
_77 = opaque::<i16>(move _78) -> [return: bb26, unwind unreachable];
491+
- _77 = opaque::<i16>(move _78) -> [return: bb26, unwind unreachable];
492+
+ _77 = opaque::<i16>(const 1_i16) -> [return: bb26, unwind unreachable];
469493
}
470494

471495
bb26: {
@@ -477,9 +501,10 @@
477501
- _82 = _3;
478502
- _81 = move _82 as i32 (FloatToInt);
479503
+ _82 = const 1f64;
480-
+ _81 = const 1f64 as i32 (FloatToInt);
504+
+ _81 = const 1_i32;
481505
StorageDead(_82);
482-
_80 = opaque::<i32>(move _81) -> [return: bb27, unwind unreachable];
506+
- _80 = opaque::<i32>(move _81) -> [return: bb27, unwind unreachable];
507+
+ _80 = opaque::<i32>(const 1_i32) -> [return: bb27, unwind unreachable];
483508
}
484509

485510
bb27: {
@@ -491,9 +516,10 @@
491516
- _85 = _3;
492517
- _84 = move _85 as i64 (FloatToInt);
493518
+ _85 = const 1f64;
494-
+ _84 = const 1f64 as i64 (FloatToInt);
519+
+ _84 = const 1_i64;
495520
StorageDead(_85);
496-
_83 = opaque::<i64>(move _84) -> [return: bb28, unwind unreachable];
521+
- _83 = opaque::<i64>(move _84) -> [return: bb28, unwind unreachable];
522+
+ _83 = opaque::<i64>(const 1_i64) -> [return: bb28, unwind unreachable];
497523
}
498524

499525
bb28: {
@@ -505,9 +531,10 @@
505531
- _88 = _3;
506532
- _87 = move _88 as f32 (FloatToFloat);
507533
+ _88 = const 1f64;
508-
+ _87 = const 1f64 as f32 (FloatToFloat);
534+
+ _87 = const 1f32;
509535
StorageDead(_88);
510-
_86 = opaque::<f32>(move _87) -> [return: bb29, unwind unreachable];
536+
- _86 = opaque::<f32>(move _87) -> [return: bb29, unwind unreachable];
537+
+ _86 = opaque::<f32>(const 1f32) -> [return: bb29, unwind unreachable];
511538
}
512539

513540
bb29: {

‎tests/mir-opt/gvn.cast.GVN.panic-unwind.diff

Lines changed: 81 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@
119119
- _6 = _1;
120120
- _5 = move _6 as u8 (IntToInt);
121121
+ _6 = const 1_i64;
122-
+ _5 = const 1_i64 as u8 (IntToInt);
122+
+ _5 = const 1_u8;
123123
StorageDead(_6);
124-
_4 = opaque::<u8>(move _5) -> [return: bb1, unwind continue];
124+
- _4 = opaque::<u8>(move _5) -> [return: bb1, unwind continue];
125+
+ _4 = opaque::<u8>(const 1_u8) -> [return: bb1, unwind continue];
125126
}
126127

127128
bb1: {
@@ -133,9 +134,10 @@
133134
- _9 = _1;
134135
- _8 = move _9 as u16 (IntToInt);
135136
+ _9 = const 1_i64;
136-
+ _8 = const 1_i64 as u16 (IntToInt);
137+
+ _8 = const 1_u16;
137138
StorageDead(_9);
138-
_7 = opaque::<u16>(move _8) -> [return: bb2, unwind continue];
139+
- _7 = opaque::<u16>(move _8) -> [return: bb2, unwind continue];
140+
+ _7 = opaque::<u16>(const 1_u16) -> [return: bb2, unwind continue];
139141
}
140142

141143
bb2: {
@@ -147,9 +149,10 @@
147149
- _12 = _1;
148150
- _11 = move _12 as u32 (IntToInt);
149151
+ _12 = const 1_i64;
150-
+ _11 = const 1_i64 as u32 (IntToInt);
152+
+ _11 = const 1_u32;
151153
StorageDead(_12);
152-
_10 = opaque::<u32>(move _11) -> [return: bb3, unwind continue];
154+
- _10 = opaque::<u32>(move _11) -> [return: bb3, unwind continue];
155+
+ _10 = opaque::<u32>(const 1_u32) -> [return: bb3, unwind continue];
153156
}
154157

155158
bb3: {
@@ -161,9 +164,10 @@
161164
- _15 = _1;
162165
- _14 = move _15 as u64 (IntToInt);
163166
+ _15 = const 1_i64;
164-
+ _14 = const 1_i64 as u64 (IntToInt);
167+
+ _14 = const 1_u64;
165168
StorageDead(_15);
166-
_13 = opaque::<u64>(move _14) -> [return: bb4, unwind continue];
169+
- _13 = opaque::<u64>(move _14) -> [return: bb4, unwind continue];
170+
+ _13 = opaque::<u64>(const 1_u64) -> [return: bb4, unwind continue];
167171
}
168172

169173
bb4: {
@@ -175,9 +179,10 @@
175179
- _18 = _1;
176180
- _17 = move _18 as i8 (IntToInt);
177181
+ _18 = const 1_i64;
178-
+ _17 = const 1_i64 as i8 (IntToInt);
182+
+ _17 = const 1_i8;
179183
StorageDead(_18);
180-
_16 = opaque::<i8>(move _17) -> [return: bb5, unwind continue];
184+
- _16 = opaque::<i8>(move _17) -> [return: bb5, unwind continue];
185+
+ _16 = opaque::<i8>(const 1_i8) -> [return: bb5, unwind continue];
181186
}
182187

183188
bb5: {
@@ -189,9 +194,10 @@
189194
- _21 = _1;
190195
- _20 = move _21 as i16 (IntToInt);
191196
+ _21 = const 1_i64;
192-
+ _20 = const 1_i64 as i16 (IntToInt);
197+
+ _20 = const 1_i16;
193198
StorageDead(_21);
194-
_19 = opaque::<i16>(move _20) -> [return: bb6, unwind continue];
199+
- _19 = opaque::<i16>(move _20) -> [return: bb6, unwind continue];
200+
+ _19 = opaque::<i16>(const 1_i16) -> [return: bb6, unwind continue];
195201
}
196202

197203
bb6: {
@@ -203,9 +209,10 @@
203209
- _24 = _1;
204210
- _23 = move _24 as i32 (IntToInt);
205211
+ _24 = const 1_i64;
206-
+ _23 = const 1_i64 as i32 (IntToInt);
212+
+ _23 = const 1_i32;
207213
StorageDead(_24);
208-
_22 = opaque::<i32>(move _23) -> [return: bb7, unwind continue];
214+
- _22 = opaque::<i32>(move _23) -> [return: bb7, unwind continue];
215+
+ _22 = opaque::<i32>(const 1_i32) -> [return: bb7, unwind continue];
209216
}
210217

211218
bb7: {
@@ -228,9 +235,10 @@
228235
- _29 = _1;
229236
- _28 = move _29 as f32 (IntToFloat);
230237
+ _29 = const 1_i64;
231-
+ _28 = const 1_i64 as f32 (IntToFloat);
238+
+ _28 = const 1f32;
232239
StorageDead(_29);
233-
_27 = opaque::<f32>(move _28) -> [return: bb9, unwind continue];
240+
- _27 = opaque::<f32>(move _28) -> [return: bb9, unwind continue];
241+
+ _27 = opaque::<f32>(const 1f32) -> [return: bb9, unwind continue];
234242
}
235243

236244
bb9: {
@@ -242,9 +250,10 @@
242250
- _32 = _1;
243251
- _31 = move _32 as f64 (IntToFloat);
244252
+ _32 = const 1_i64;
245-
+ _31 = const 1_i64 as f64 (IntToFloat);
253+
+ _31 = const 1f64;
246254
StorageDead(_32);
247-
_30 = opaque::<f64>(move _31) -> [return: bb10, unwind continue];
255+
- _30 = opaque::<f64>(move _31) -> [return: bb10, unwind continue];
256+
+ _30 = opaque::<f64>(const 1f64) -> [return: bb10, unwind continue];
248257
}
249258

250259
bb10: {
@@ -256,9 +265,10 @@
256265
- _35 = _2;
257266
- _34 = move _35 as u8 (IntToInt);
258267
+ _35 = const 1_u64;
259-
+ _34 = const 1_u64 as u8 (IntToInt);
268+
+ _34 = const 1_u8;
260269
StorageDead(_35);
261-
_33 = opaque::<u8>(move _34) -> [return: bb11, unwind continue];
270+
- _33 = opaque::<u8>(move _34) -> [return: bb11, unwind continue];
271+
+ _33 = opaque::<u8>(const 1_u8) -> [return: bb11, unwind continue];
262272
}
263273

264274
bb11: {
@@ -270,9 +280,10 @@
270280
- _38 = _2;
271281
- _37 = move _38 as u16 (IntToInt);
272282
+ _38 = const 1_u64;
273-
+ _37 = const 1_u64 as u16 (IntToInt);
283+
+ _37 = const 1_u16;
274284
StorageDead(_38);
275-
_36 = opaque::<u16>(move _37) -> [return: bb12, unwind continue];
285+
- _36 = opaque::<u16>(move _37) -> [return: bb12, unwind continue];
286+
+ _36 = opaque::<u16>(const 1_u16) -> [return: bb12, unwind continue];
276287
}
277288

278289
bb12: {
@@ -284,9 +295,10 @@
284295
- _41 = _2;
285296
- _40 = move _41 as u32 (IntToInt);
286297
+ _41 = const 1_u64;
287-
+ _40 = const 1_u64 as u32 (IntToInt);
298+
+ _40 = const 1_u32;
288299
StorageDead(_41);
289-
_39 = opaque::<u32>(move _40) -> [return: bb13, unwind continue];
300+
- _39 = opaque::<u32>(move _40) -> [return: bb13, unwind continue];
301+
+ _39 = opaque::<u32>(const 1_u32) -> [return: bb13, unwind continue];
290302
}
291303

292304
bb13: {
@@ -309,9 +321,10 @@
309321
- _46 = _2;
310322
- _45 = move _46 as i8 (IntToInt);
311323
+ _46 = const 1_u64;
312-
+ _45 = const 1_u64 as i8 (IntToInt);
324+
+ _45 = const 1_i8;
313325
StorageDead(_46);
314-
_44 = opaque::<i8>(move _45) -> [return: bb15, unwind continue];
326+
- _44 = opaque::<i8>(move _45) -> [return: bb15, unwind continue];
327+
+ _44 = opaque::<i8>(const 1_i8) -> [return: bb15, unwind continue];
315328
}
316329

317330
bb15: {
@@ -323,9 +336,10 @@
323336
- _49 = _2;
324337
- _48 = move _49 as i16 (IntToInt);
325338
+ _49 = const 1_u64;
326-
+ _48 = const 1_u64 as i16 (IntToInt);
339+
+ _48 = const 1_i16;
327340
StorageDead(_49);
328-
_47 = opaque::<i16>(move _48) -> [return: bb16, unwind continue];
341+
- _47 = opaque::<i16>(move _48) -> [return: bb16, unwind continue];
342+
+ _47 = opaque::<i16>(const 1_i16) -> [return: bb16, unwind continue];
329343
}
330344

331345
bb16: {
@@ -337,9 +351,10 @@
337351
- _52 = _2;
338352
- _51 = move _52 as i32 (IntToInt);
339353
+ _52 = const 1_u64;
340-
+ _51 = const 1_u64 as i32 (IntToInt);
354+
+ _51 = const 1_i32;
341355
StorageDead(_52);
342-
_50 = opaque::<i32>(move _51) -> [return: bb17, unwind continue];
356+
- _50 = opaque::<i32>(move _51) -> [return: bb17, unwind continue];
357+
+ _50 = opaque::<i32>(const 1_i32) -> [return: bb17, unwind continue];
343358
}
344359

345360
bb17: {
@@ -351,9 +366,10 @@
351366
- _55 = _2;
352367
- _54 = move _55 as i64 (IntToInt);
353368
+ _55 = const 1_u64;
354-
+ _54 = const 1_u64 as i64 (IntToInt);
369+
+ _54 = const 1_i64;
355370
StorageDead(_55);
356-
_53 = opaque::<i64>(move _54) -> [return: bb18, unwind continue];
371+
- _53 = opaque::<i64>(move _54) -> [return: bb18, unwind continue];
372+
+ _53 = opaque::<i64>(const 1_i64) -> [return: bb18, unwind continue];
357373
}
358374

359375
bb18: {
@@ -365,9 +381,10 @@
365381
- _58 = _2;
366382
- _57 = move _58 as f32 (IntToFloat);
367383
+ _58 = const 1_u64;
368-
+ _57 = const 1_u64 as f32 (IntToFloat);
384+
+ _57 = const 1f32;
369385
StorageDead(_58);
370-
_56 = opaque::<f32>(move _57) -> [return: bb19, unwind continue];
386+
- _56 = opaque::<f32>(move _57) -> [return: bb19, unwind continue];
387+
+ _56 = opaque::<f32>(const 1f32) -> [return: bb19, unwind continue];
371388
}
372389

373390
bb19: {
@@ -379,9 +396,10 @@
379396
- _61 = _2;
380397
- _60 = move _61 as f64 (IntToFloat);
381398
+ _61 = const 1_u64;
382-
+ _60 = const 1_u64 as f64 (IntToFloat);
399+
+ _60 = const 1f64;
383400
StorageDead(_61);
384-
_59 = opaque::<f64>(move _60) -> [return: bb20, unwind continue];
401+
- _59 = opaque::<f64>(move _60) -> [return: bb20, unwind continue];
402+
+ _59 = opaque::<f64>(const 1f64) -> [return: bb20, unwind continue];
385403
}
386404

387405
bb20: {
@@ -393,9 +411,10 @@
393411
- _64 = _3;
394412
- _63 = move _64 as u8 (FloatToInt);
395413
+ _64 = const 1f64;
396-
+ _63 = const 1f64 as u8 (FloatToInt);
414+
+ _63 = const 1_u8;
397415
StorageDead(_64);
398-
_62 = opaque::<u8>(move _63) -> [return: bb21, unwind continue];
416+
- _62 = opaque::<u8>(move _63) -> [return: bb21, unwind continue];
417+
+ _62 = opaque::<u8>(const 1_u8) -> [return: bb21, unwind continue];
399418
}
400419

401420
bb21: {
@@ -407,9 +426,10 @@
407426
- _67 = _3;
408427
- _66 = move _67 as u16 (FloatToInt);
409428
+ _67 = const 1f64;
410-
+ _66 = const 1f64 as u16 (FloatToInt);
429+
+ _66 = const 1_u16;
411430
StorageDead(_67);
412-
_65 = opaque::<u16>(move _66) -> [return: bb22, unwind continue];
431+
- _65 = opaque::<u16>(move _66) -> [return: bb22, unwind continue];
432+
+ _65 = opaque::<u16>(const 1_u16) -> [return: bb22, unwind continue];
413433
}
414434

415435
bb22: {
@@ -421,9 +441,10 @@
421441
- _70 = _3;
422442
- _69 = move _70 as u32 (FloatToInt);
423443
+ _70 = const 1f64;
424-
+ _69 = const 1f64 as u32 (FloatToInt);
444+
+ _69 = const 1_u32;
425445
StorageDead(_70);
426-
_68 = opaque::<u32>(move _69) -> [return: bb23, unwind continue];
446+
- _68 = opaque::<u32>(move _69) -> [return: bb23, unwind continue];
447+
+ _68 = opaque::<u32>(const 1_u32) -> [return: bb23, unwind continue];
427448
}
428449

429450
bb23: {
@@ -435,9 +456,10 @@
435456
- _73 = _3;
436457
- _72 = move _73 as u64 (FloatToInt);
437458
+ _73 = const 1f64;
438-
+ _72 = const 1f64 as u64 (FloatToInt);
459+
+ _72 = const 1_u64;
439460
StorageDead(_73);
440-
_71 = opaque::<u64>(move _72) -> [return: bb24, unwind continue];
461+
- _71 = opaque::<u64>(move _72) -> [return: bb24, unwind continue];
462+
+ _71 = opaque::<u64>(const 1_u64) -> [return: bb24, unwind continue];
441463
}
442464

443465
bb24: {
@@ -449,9 +471,10 @@
449471
- _76 = _3;
450472
- _75 = move _76 as i8 (FloatToInt);
451473
+ _76 = const 1f64;
452-
+ _75 = const 1f64 as i8 (FloatToInt);
474+
+ _75 = const 1_i8;
453475
StorageDead(_76);
454-
_74 = opaque::<i8>(move _75) -> [return: bb25, unwind continue];
476+
- _74 = opaque::<i8>(move _75) -> [return: bb25, unwind continue];
477+
+ _74 = opaque::<i8>(const 1_i8) -> [return: bb25, unwind continue];
455478
}
456479

457480
bb25: {
@@ -463,9 +486,10 @@
463486
- _79 = _3;
464487
- _78 = move _79 as i16 (FloatToInt);
465488
+ _79 = const 1f64;
466-
+ _78 = const 1f64 as i16 (FloatToInt);
489+
+ _78 = const 1_i16;
467490
StorageDead(_79);
468-
_77 = opaque::<i16>(move _78) -> [return: bb26, unwind continue];
491+
- _77 = opaque::<i16>(move _78) -> [return: bb26, unwind continue];
492+
+ _77 = opaque::<i16>(const 1_i16) -> [return: bb26, unwind continue];
469493
}
470494

471495
bb26: {
@@ -477,9 +501,10 @@
477501
- _82 = _3;
478502
- _81 = move _82 as i32 (FloatToInt);
479503
+ _82 = const 1f64;
480-
+ _81 = const 1f64 as i32 (FloatToInt);
504+
+ _81 = const 1_i32;
481505
StorageDead(_82);
482-
_80 = opaque::<i32>(move _81) -> [return: bb27, unwind continue];
506+
- _80 = opaque::<i32>(move _81) -> [return: bb27, unwind continue];
507+
+ _80 = opaque::<i32>(const 1_i32) -> [return: bb27, unwind continue];
483508
}
484509

485510
bb27: {
@@ -491,9 +516,10 @@
491516
- _85 = _3;
492517
- _84 = move _85 as i64 (FloatToInt);
493518
+ _85 = const 1f64;
494-
+ _84 = const 1f64 as i64 (FloatToInt);
519+
+ _84 = const 1_i64;
495520
StorageDead(_85);
496-
_83 = opaque::<i64>(move _84) -> [return: bb28, unwind continue];
521+
- _83 = opaque::<i64>(move _84) -> [return: bb28, unwind continue];
522+
+ _83 = opaque::<i64>(const 1_i64) -> [return: bb28, unwind continue];
497523
}
498524

499525
bb28: {
@@ -505,9 +531,10 @@
505531
- _88 = _3;
506532
- _87 = move _88 as f32 (FloatToFloat);
507533
+ _88 = const 1f64;
508-
+ _87 = const 1f64 as f32 (FloatToFloat);
534+
+ _87 = const 1f32;
509535
StorageDead(_88);
510-
_86 = opaque::<f32>(move _87) -> [return: bb29, unwind continue];
536+
- _86 = opaque::<f32>(move _87) -> [return: bb29, unwind continue];
537+
+ _86 = opaque::<f32>(const 1f32) -> [return: bb29, unwind continue];
511538
}
512539

513540
bb29: {

‎tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
- }
3838
-
3939
- bb1: {
40-
+ _4 = [generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)];
40+
+ _4 = const Indirect { alloc_id: alloc6, offset: Size(0 bytes) }: [generator@$DIR/inline_generator.rs:16:5: 16:8];
4141
_3 = &mut _4;
4242
- _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new(move _3) -> [return: bb2, unwind unreachable];
4343
- }
@@ -61,7 +61,7 @@
6161
_0 = const ();
6262
StorageDead(_1);
6363
return;
64-
+ }
64+
}
6565
+
6666
+ bb2: {
6767
+ StorageLive(_8);
@@ -98,6 +98,10 @@
9898
+
9999
+ bb8: {
100100
+ unreachable;
101-
}
101+
+ }
102+
+ }
103+
+
104+
+ alloc6 (size: 1, align: 1) {
105+
+ 00 │ .
102106
}
103107

‎tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
- }
3838
-
3939
- bb1: {
40-
+ _4 = [generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)];
40+
+ _4 = const Indirect { alloc_id: alloc6, offset: Size(0 bytes) }: [generator@$DIR/inline_generator.rs:16:5: 16:8];
4141
_3 = &mut _4;
4242
- _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new(move _3) -> [return: bb2, unwind: bb4];
4343
- }
@@ -66,7 +66,7 @@
6666
- bb4 (cleanup): {
6767
+ bb2 (cleanup): {
6868
resume;
69-
+ }
69+
}
7070
+
7171
+ bb3: {
7272
+ StorageLive(_8);
@@ -103,6 +103,10 @@
103103
+
104104
+ bb9: {
105105
+ unreachable;
106-
}
106+
+ }
107+
+ }
108+
+
109+
+ alloc6 (size: 1, align: 1) {
110+
+ 00 │ .
107111
}
108112

0 commit comments

Comments
 (0)
Please sign in to comment.