diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 5487b5987e001..33e0356f7392f 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -95,7 +95,7 @@ fn inline<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) -> bool { changed: false, }; let blocks = START_BLOCK..body.basic_blocks.next_index(); - this.process_blocks(body, blocks); + this.process_blocks(body, blocks, 0); this.changed } @@ -115,10 +115,15 @@ struct Inliner<'tcx> { } impl<'tcx> Inliner<'tcx> { - fn process_blocks(&mut self, caller_body: &mut Body<'tcx>, blocks: Range) { + fn process_blocks( + &mut self, + caller_body: &mut Body<'tcx>, + blocks: Range, + depth: usize, + ) { // How many callsites in this body are we allowed to inline? We need to limit this in order // to prevent super-linear growth in MIR size - let inline_limit = match self.history.len() { + let inline_limit = match depth { 0 => usize::MAX, 1..=TOP_DOWN_DEPTH_LIMIT => 1, _ => return, @@ -137,26 +142,35 @@ impl<'tcx> Inliner<'tcx> { let span = trace_span!("process_blocks", %callsite.callee, ?bb); let _guard = span.enter(); - match self.try_inlining(caller_body, &callsite) { + let callee_attrs = self.tcx.codegen_fn_attrs(callsite.callee.def_id()); + let inline_always = matches!(callee_attrs.inline, InlineAttr::Always); + + if inlined_count >= inline_limit && !inline_always { + debug!("inline count reached"); + continue; + } + + let new_blocks = match self.try_inlining(caller_body, &callsite, callee_attrs) { + Ok(new_blocks) => new_blocks, Err(reason) => { debug!("not-inlined {} [{}]", callsite.callee, reason); continue; } - Ok(new_blocks) => { - debug!("inlined {}", callsite.callee); - self.changed = true; + }; - self.history.push(callsite.callee.def_id()); - self.process_blocks(caller_body, new_blocks); - self.history.pop(); + debug!("inlined {}", callsite.callee); + self.changed = true; - inlined_count += 1; - if inlined_count == inline_limit { - debug!("inline count reached"); - return; - } - } - } + let new_depth = if inline_always { + // This call was `inline(always)`. Do not count it in the inline cost. + depth + } else { + inlined_count += 1; + depth + 1 + }; + self.history.push(callsite.callee.def_id()); + self.process_blocks(caller_body, new_blocks, new_depth); + self.history.pop(); } } @@ -167,13 +181,12 @@ impl<'tcx> Inliner<'tcx> { &self, caller_body: &mut Body<'tcx>, callsite: &CallSite<'tcx>, + callee_attrs: &CodegenFnAttrs, ) -> Result, &'static str> { - let callee_attrs = self.tcx.codegen_fn_attrs(callsite.callee.def_id()); self.check_codegen_attributes(callsite, callee_attrs)?; let terminator = caller_body[callsite.block].terminator.as_ref().unwrap(); - let TerminatorKind::Call { args, destination, .. } = &terminator.kind else { bug!() }; - let destination_ty = destination.ty(&caller_body.local_decls, self.tcx).ty; + let TerminatorKind::Call { args, .. } = &terminator.kind else { bug!() }; for arg in args { if !arg.ty(&caller_body.local_decls, self.tcx).is_sized(self.tcx, self.param_env) { // We do not allow inlining functions with unsized params. Inlining these functions @@ -184,7 +197,7 @@ impl<'tcx> Inliner<'tcx> { self.check_mir_is_available(caller_body, &callsite.callee)?; let callee_body = try_instance_mir(self.tcx, callsite.callee.def)?; - self.check_mir_body(callsite, callee_body, callee_attrs)?; + self.check_mir_body(caller_body, callsite, callee_body, callee_attrs)?; if !self.tcx.consider_optimizing(|| { format!("Inline {:?} into {:?}", callsite.callee, caller_body.source) @@ -200,46 +213,6 @@ impl<'tcx> Inliner<'tcx> { return Err("failed to normalize callee body"); }; - // Check call signature compatibility. - // Normally, this shouldn't be required, but trait normalization failure can create a - // validation ICE. - let output_type = callee_body.return_ty(); - if !util::is_subtype(self.tcx, self.param_env, output_type, destination_ty) { - trace!(?output_type, ?destination_ty); - return Err("failed to normalize return type"); - } - if callsite.fn_sig.abi() == Abi::RustCall { - let (arg_tuple, skipped_args) = match &args[..] { - [arg_tuple] => (arg_tuple, 0), - [_, arg_tuple] => (arg_tuple, 1), - _ => bug!("Expected `rust-call` to have 1 or 2 args"), - }; - - let arg_tuple_ty = arg_tuple.ty(&caller_body.local_decls, self.tcx); - let ty::Tuple(arg_tuple_tys) = arg_tuple_ty.kind() else { - bug!("Closure arguments are not passed as a tuple"); - }; - - for (arg_ty, input) in - arg_tuple_tys.iter().zip(callee_body.args_iter().skip(skipped_args)) - { - let input_type = callee_body.local_decls[input].ty; - if !util::is_subtype(self.tcx, self.param_env, input_type, arg_ty) { - trace!(?arg_ty, ?input_type); - return Err("failed to normalize tuple argument type"); - } - } - } else { - for (arg, input) in args.iter().zip(callee_body.args_iter()) { - let input_type = callee_body.local_decls[input].ty; - let arg_ty = arg.ty(&caller_body.local_decls, self.tcx); - if !util::is_subtype(self.tcx, self.param_env, input_type, arg_ty) { - trace!(?arg_ty, ?input_type); - return Err("failed to normalize argument type"); - } - } - } - let old_blocks = caller_body.basic_blocks.next_index(); self.inline_call(caller_body, &callsite, callee_body); let new_blocks = old_blocks..caller_body.basic_blocks.next_index(); @@ -409,6 +382,7 @@ impl<'tcx> Inliner<'tcx> { #[instrument(level = "debug", skip(self, callee_body))] fn check_mir_body( &self, + caller_body: &Body<'tcx>, callsite: &CallSite<'tcx>, callee_body: &Body<'tcx>, callee_attrs: &CodegenFnAttrs, @@ -479,6 +453,57 @@ impl<'tcx> Inliner<'tcx> { // Abort if type validation found anything fishy. checker.validation?; + let substitute = |ty| { + let ty = ty::EarlyBinder::bind(ty); + callsite + .callee + .try_subst_mir_and_normalize_erasing_regions(self.tcx, self.param_env, ty) + .map_err(|_| "failed to normalize callee body") + }; + + // Check call signature compatibility. + // Normally, this shouldn't be required, but trait normalization failure can create a + // validation ICE. + let terminator = caller_body[callsite.block].terminator.as_ref().unwrap(); + let TerminatorKind::Call { args, destination, .. } = &terminator.kind else { bug!() }; + let destination_ty = destination.ty(&caller_body.local_decls, self.tcx).ty; + let output_type = substitute(callee_body.return_ty())?; + if !util::is_subtype(self.tcx, self.param_env, output_type, destination_ty) { + trace!(?output_type, ?destination_ty); + return Err("failed to normalize return type"); + } + if callsite.fn_sig.abi() == Abi::RustCall { + let (arg_tuple, skipped_args) = match &args[..] { + [arg_tuple] => (arg_tuple, 0), + [_, arg_tuple] => (arg_tuple, 1), + _ => bug!("Expected `rust-call` to have 1 or 2 args"), + }; + + let arg_tuple_ty = arg_tuple.ty(&caller_body.local_decls, self.tcx); + let ty::Tuple(arg_tuple_tys) = arg_tuple_ty.kind() else { + bug!("Closure arguments are not passed as a tuple"); + }; + + for (arg_ty, input) in + arg_tuple_tys.iter().zip(callee_body.args_iter().skip(skipped_args)) + { + let input_type = substitute(callee_body.local_decls[input].ty)?; + if !util::is_subtype(self.tcx, self.param_env, input_type, arg_ty) { + trace!(?arg_ty, ?input_type); + return Err("failed to normalize tuple argument type"); + } + } + } else { + for (arg, input) in args.iter().zip(callee_body.args_iter()) { + let input_type = substitute(callee_body.local_decls[input].ty)?; + let arg_ty = arg.ty(&caller_body.local_decls, self.tcx); + if !util::is_subtype(self.tcx, self.param_env, input_type, arg_ty) { + trace!(?arg_ty, ?input_type); + return Err("failed to normalize argument type"); + } + } + } + let cost = checker.cost; if let InlineAttr::Always = callee_attrs.inline { debug!("INLINING {:?} because inline(always) [cost={}]", callsite, cost); diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index faf48ae570fdd..7e01baf59701e 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1275,9 +1275,9 @@ mod impls { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for $t { - #[inline] + #[inline(always)] fn eq(&self, other: &$t) -> bool { (*self) == (*other) } - #[inline] + #[inline(always)] fn ne(&self, other: &$t) -> bool { (*self) != (*other) } } )*) @@ -1285,11 +1285,11 @@ mod impls { #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for () { - #[inline] + #[inline(always)] fn eq(&self, _other: &()) -> bool { true } - #[inline] + #[inline(always)] fn ne(&self, _other: &()) -> bool { false } @@ -1335,7 +1335,7 @@ mod impls { #[stable(feature = "rust1", since = "1.0.0")] impl PartialOrd for () { - #[inline] + #[inline(always)] fn partial_cmp(&self, _: &()) -> Option { Some(Equal) } @@ -1343,7 +1343,7 @@ mod impls { #[stable(feature = "rust1", since = "1.0.0")] impl PartialOrd for bool { - #[inline] + #[inline(always)] fn partial_cmp(&self, other: &bool) -> Option { Some(self.cmp(other)) } @@ -1355,7 +1355,7 @@ mod impls { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] impl PartialOrd for $t { - #[inline] + #[inline(always)] fn partial_cmp(&self, other: &$t) -> Option { Some(self.cmp(other)) } @@ -1385,7 +1385,7 @@ mod impls { #[stable(feature = "rust1", since = "1.0.0")] impl Ord for () { - #[inline] + #[inline(always)] fn cmp(&self, _other: &()) -> Ordering { Equal } @@ -1412,7 +1412,7 @@ mod impls { #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { - #[inline] + #[inline(always)] fn eq(&self, _: &!) -> bool { *self } @@ -1423,7 +1423,7 @@ mod impls { #[unstable(feature = "never_type", issue = "35121")] impl PartialOrd for ! { - #[inline] + #[inline(always)] fn partial_cmp(&self, _: &!) -> Option { *self } @@ -1431,7 +1431,7 @@ mod impls { #[unstable(feature = "never_type", issue = "35121")] impl Ord for ! { - #[inline] + #[inline(always)] fn cmp(&self, _: &!) -> Ordering { *self } @@ -1444,11 +1444,11 @@ mod impls { where A: PartialEq, { - #[inline] + #[inline(always)] fn eq(&self, other: &&B) -> bool { PartialEq::eq(*self, *other) } - #[inline] + #[inline(always)] fn ne(&self, other: &&B) -> bool { PartialEq::ne(*self, *other) } @@ -1458,23 +1458,23 @@ mod impls { where A: PartialOrd, { - #[inline] + #[inline(always)] fn partial_cmp(&self, other: &&B) -> Option { PartialOrd::partial_cmp(*self, *other) } - #[inline] + #[inline(always)] fn lt(&self, other: &&B) -> bool { PartialOrd::lt(*self, *other) } - #[inline] + #[inline(always)] fn le(&self, other: &&B) -> bool { PartialOrd::le(*self, *other) } - #[inline] + #[inline(always)] fn gt(&self, other: &&B) -> bool { PartialOrd::gt(*self, *other) } - #[inline] + #[inline(always)] fn ge(&self, other: &&B) -> bool { PartialOrd::ge(*self, *other) } @@ -1484,7 +1484,7 @@ mod impls { where A: Ord, { - #[inline] + #[inline(always)] fn cmp(&self, other: &Self) -> Ordering { Ord::cmp(*self, *other) } @@ -1499,11 +1499,11 @@ mod impls { where A: PartialEq, { - #[inline] + #[inline(always)] fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) } - #[inline] + #[inline(always)] fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) } @@ -1513,23 +1513,23 @@ mod impls { where A: PartialOrd, { - #[inline] + #[inline(always)] fn partial_cmp(&self, other: &&mut B) -> Option { PartialOrd::partial_cmp(*self, *other) } - #[inline] + #[inline(always)] fn lt(&self, other: &&mut B) -> bool { PartialOrd::lt(*self, *other) } - #[inline] + #[inline(always)] fn le(&self, other: &&mut B) -> bool { PartialOrd::le(*self, *other) } - #[inline] + #[inline(always)] fn gt(&self, other: &&mut B) -> bool { PartialOrd::gt(*self, *other) } - #[inline] + #[inline(always)] fn ge(&self, other: &&mut B) -> bool { PartialOrd::ge(*self, *other) } @@ -1539,7 +1539,7 @@ mod impls { where A: Ord, { - #[inline] + #[inline(always)] fn cmp(&self, other: &Self) -> Ordering { Ord::cmp(*self, *other) } @@ -1552,11 +1552,11 @@ mod impls { where A: PartialEq, { - #[inline] + #[inline(always)] fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) } - #[inline] + #[inline(always)] fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) } @@ -1567,11 +1567,11 @@ mod impls { where A: PartialEq, { - #[inline] + #[inline(always)] fn eq(&self, other: &&B) -> bool { PartialEq::eq(*self, *other) } - #[inline] + #[inline(always)] fn ne(&self, other: &&B) -> bool { PartialEq::ne(*self, *other) } diff --git a/library/core/src/internal_macros.rs b/library/core/src/internal_macros.rs index 5774107f5207f..64a839dcf02fc 100644 --- a/library/core/src/internal_macros.rs +++ b/library/core/src/internal_macros.rs @@ -30,7 +30,7 @@ macro_rules! forward_ref_binop { impl<'a> $imp<$u> for &'a $t { type Output = <$t as $imp<$u>>::Output; - #[inline] + #[inline(always)] fn $method(self, other: $u) -> <$t as $imp<$u>>::Output { $imp::$method(*self, other) } @@ -40,7 +40,7 @@ macro_rules! forward_ref_binop { impl $imp<&$u> for $t { type Output = <$t as $imp<$u>>::Output; - #[inline] + #[inline(always)] fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output { $imp::$method(self, *other) } @@ -50,7 +50,7 @@ macro_rules! forward_ref_binop { impl $imp<&$u> for &$t { type Output = <$t as $imp<$u>>::Output; - #[inline] + #[inline(always)] fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output { $imp::$method(*self, *other) } @@ -68,7 +68,7 @@ macro_rules! forward_ref_op_assign { (impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => { #[$attr] impl $imp<&$u> for $t { - #[inline] + #[inline(always)] fn $method(&mut self, other: &$u) { $imp::$method(self, *other); } diff --git a/library/core/src/ops/arith.rs b/library/core/src/ops/arith.rs index 840c8cd2fe8d0..c889ff4119928 100644 --- a/library/core/src/ops/arith.rs +++ b/library/core/src/ops/arith.rs @@ -97,7 +97,7 @@ macro_rules! add_impl { impl Add for $t { type Output = $t; - #[inline] + #[inline(always)] #[rustc_inherit_overflow_checks] fn add(self, other: $t) -> $t { self + other } } @@ -205,7 +205,7 @@ macro_rules! sub_impl { impl Sub for $t { type Output = $t; - #[inline] + #[inline(always)] #[rustc_inherit_overflow_checks] fn sub(self, other: $t) -> $t { self - other } } @@ -334,7 +334,7 @@ macro_rules! mul_impl { impl Mul for $t { type Output = $t; - #[inline] + #[inline(always)] #[rustc_inherit_overflow_checks] fn mul(self, other: $t) -> $t { self * other } } @@ -473,7 +473,7 @@ macro_rules! div_impl_integer { impl Div for $t { type Output = $t; - #[inline] + #[inline(always)] fn div(self, other: $t) -> $t { self / other } } @@ -492,7 +492,7 @@ macro_rules! div_impl_float { impl Div for $t { type Output = $t; - #[inline] + #[inline(always)] fn div(self, other: $t) -> $t { self / other } } @@ -574,7 +574,7 @@ macro_rules! rem_impl_integer { impl Rem for $t { type Output = $t; - #[inline] + #[inline(always)] fn rem(self, other: $t) -> $t { self % other } } @@ -608,7 +608,7 @@ macro_rules! rem_impl_float { impl Rem for $t { type Output = $t; - #[inline] + #[inline(always)] fn rem(self, other: $t) -> $t { self % other } } @@ -682,7 +682,7 @@ macro_rules! neg_impl { impl Neg for $t { type Output = $t; - #[inline] + #[inline(always)] #[rustc_inherit_overflow_checks] fn neg(self) -> $t { -self } } @@ -748,7 +748,7 @@ macro_rules! add_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] impl AddAssign for $t { - #[inline] + #[inline(always)] #[rustc_inherit_overflow_checks] fn add_assign(&mut self, other: $t) { *self += other } } @@ -814,7 +814,7 @@ macro_rules! sub_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] impl SubAssign for $t { - #[inline] + #[inline(always)] #[rustc_inherit_overflow_checks] fn sub_assign(&mut self, other: $t) { *self -= other } } @@ -871,7 +871,7 @@ macro_rules! mul_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] impl MulAssign for $t { - #[inline] + #[inline(always)] #[rustc_inherit_overflow_checks] fn mul_assign(&mut self, other: $t) { *self *= other } } @@ -928,7 +928,7 @@ macro_rules! div_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] impl DivAssign for $t { - #[inline] + #[inline(always)] fn div_assign(&mut self, other: $t) { *self /= other } } @@ -988,7 +988,7 @@ macro_rules! rem_assign_impl { ($($t:ty)+) => ($( #[stable(feature = "op_assign_traits", since = "1.8.0")] impl RemAssign for $t { - #[inline] + #[inline(always)] fn rem_assign(&mut self, other: $t) { *self %= other } } diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.diff index 78cd47c5f4bf4..1d1f8b750f1b5 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.diff @@ -6,6 +6,7 @@ let _1: (!, !); // in scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 + let mut _2: fn() -> ! {sleep}; // in scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 + let mut _8: (); // in scope 0 at $DIR/inline_diverging.rs:27:13: 27:16 ++ let mut _9: (); // in scope 0 at $DIR/inline_diverging.rs:28:13: 28:16 + scope 1 (inlined call_twice:: ! {sleep}>) { // at $DIR/inline_diverging.rs:22:5: 22:22 + debug f => _2; // in scope 1 at $DIR/inline_diverging.rs:26:36: 26:37 + let mut _3: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline_diverging.rs:27:13: 27:14 @@ -18,6 +19,10 @@ + scope 3 { + debug b => _6; // in scope 3 at $DIR/inline_diverging.rs:28:9: 28:10 + } ++ scope 6 (inlined ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline_diverging.rs:28:13: 28:16 ++ scope 7 (inlined sleep) { // at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ } ++ } + } + scope 4 (inlined ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline_diverging.rs:27:13: 27:16 + scope 5 (inlined sleep) { // at $SRC_DIR/core/src/ops/function.rs:LL:COL diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir index 86e0a62b6f968..69a4b256b75e8 100644 --- a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir @@ -8,13 +8,14 @@ fn int_range(_1: usize, _2: usize) -> () { let mut _4: std::ops::Range; // in scope 0 at $DIR/loops.rs:+1:14: +1:24 let mut _5: &mut std::ops::Range; // in scope 0 at $DIR/loops.rs:+1:14: +1:24 let mut _11: std::option::Option; // in scope 0 at $DIR/loops.rs:+1:14: +1:24 - let mut _14: isize; // in scope 0 at $DIR/loops.rs:+1:5: +3:6 - let _16: (); // in scope 0 at $DIR/loops.rs:+1:14: +1:24 + let mut _13: usize; // in scope 0 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _15: isize; // in scope 0 at $DIR/loops.rs:+1:5: +3:6 + let _17: (); // in scope 0 at $DIR/loops.rs:+1:14: +1:24 scope 1 { debug iter => _4; // in scope 1 at $DIR/loops.rs:+1:14: +1:24 - let _15: usize; // in scope 1 at $DIR/loops.rs:+1:9: +1:10 + let _16: usize; // in scope 1 at $DIR/loops.rs:+1:9: +1:10 scope 2 { - debug i => _15; // in scope 2 at $DIR/loops.rs:+1:9: +1:10 + debug i => _16; // in scope 2 at $DIR/loops.rs:+1:9: +1:10 } scope 4 (inlined iter::range::>::next) { // at $DIR/loops.rs:8:14: 8:24 debug self => _5; // in scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL @@ -24,10 +25,22 @@ fn int_range(_1: usize, _2: usize) -> () { let mut _7: &usize; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL let mut _10: bool; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL let _12: usize; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - let mut _13: usize; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _14: usize; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 6 { debug old => _12; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 7 { + scope 9 (inlined ::forward_unchecked) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug start => _12; // in scope 9 at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug n => const 1_usize; // in scope 9 at $SRC_DIR/core/src/iter/range.rs:LL:COL + scope 10 { + scope 11 (inlined core::num::::unchecked_add) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _12; // in scope 11 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => const 1_usize; // in scope 11 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + scope 12 { + } + } + } + } } } scope 8 (inlined cmp::impls::::lt) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL @@ -53,7 +66,6 @@ fn int_range(_1: usize, _2: usize) -> () { bb1: { StorageLive(_11); // scope 1 at $DIR/loops.rs:+1:14: +1:24 _5 = &mut _4; // scope 1 at $DIR/loops.rs:+1:14: +1:24 - StorageLive(_12); // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_10); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_6); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL _6 = &((*_5).0: usize); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL @@ -78,25 +90,27 @@ fn int_range(_1: usize, _2: usize) -> () { bb3: { _12 = ((*_5).0: usize); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageLive(_13); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _13 = ::forward_unchecked(_12, const 1_usize) -> bb4; // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_14); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_13); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _13 = const 1_usize; // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _14 = unchecked_add::(_12, _13) -> [return: bb4, unwind unreachable]; // scope 12 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL - // + literal: Const { ty: unsafe fn(usize, usize) -> usize {::forward_unchecked}, val: Value() } + // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize, usize) -> usize {unchecked_add::}, val: Value() } } bb4: { - ((*_5).0: usize) = move _13; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_13); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_13); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + ((*_5).0: usize) = move _14; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_14); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL _11 = Option::::Some(_12); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL goto -> bb5; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL } bb5: { StorageDead(_10); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_12); // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _14 = discriminant(_11); // scope 1 at $DIR/loops.rs:+1:14: +1:24 - switchInt(move _14) -> [0: bb6, 1: bb7, otherwise: bb9]; // scope 1 at $DIR/loops.rs:+1:14: +1:24 + _15 = discriminant(_11); // scope 1 at $DIR/loops.rs:+1:14: +1:24 + switchInt(move _15) -> [0: bb6, 1: bb7, otherwise: bb9]; // scope 1 at $DIR/loops.rs:+1:14: +1:24 } bb6: { @@ -106,8 +120,8 @@ fn int_range(_1: usize, _2: usize) -> () { } bb7: { - _15 = ((_11 as Some).0: usize); // scope 1 at $DIR/loops.rs:+1:9: +1:10 - _16 = opaque::(_15) -> bb8; // scope 2 at $DIR/loops.rs:+2:9: +2:18 + _16 = ((_11 as Some).0: usize); // scope 1 at $DIR/loops.rs:+1:9: +1:10 + _17 = opaque::(_16) -> bb8; // scope 2 at $DIR/loops.rs:+2:9: +2:18 // mir::Constant // + span: $DIR/loops.rs:9:9: 9:15 // + literal: Const { ty: fn(usize) {opaque::}, val: Value() } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir index 06a4e35f1f900..5155898d83a71 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir @@ -9,15 +9,15 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _5: std::ops::Range; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 let mut _6: &mut std::ops::Range; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 let mut _12: std::option::Option; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 - let mut _15: isize; // in scope 0 at $DIR/range_iter.rs:+1:5: +3:6 - let mut _17: &impl Fn(u32); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:10 - let mut _18: (u32,); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:13 - let _19: (); // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 + let mut _16: isize; // in scope 0 at $DIR/range_iter.rs:+1:5: +3:6 + let mut _18: &impl Fn(u32); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:10 + let mut _19: (u32,); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:13 + let _20: (); // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 scope 1 { debug iter => _5; // in scope 1 at $DIR/range_iter.rs:+1:14: +1:24 - let _16: u32; // in scope 1 at $DIR/range_iter.rs:+1:9: +1:10 + let _17: u32; // in scope 1 at $DIR/range_iter.rs:+1:9: +1:10 scope 2 { - debug x => _16; // in scope 2 at $DIR/range_iter.rs:+1:9: +1:10 + debug x => _17; // in scope 2 at $DIR/range_iter.rs:+1:9: +1:10 } scope 4 (inlined iter::range::>::next) { // at $DIR/range_iter.rs:21:14: 21:24 debug self => _6; // in scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL @@ -27,10 +27,23 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _8: &u32; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL let mut _11: bool; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL let _13: u32; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - let mut _14: u32; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _15: u32; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 6 { debug old => _13; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 7 { + scope 9 (inlined ::forward_unchecked) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug start => _13; // in scope 9 at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug n => const 1_usize; // in scope 9 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _14: u32; // in scope 9 at $SRC_DIR/core/src/iter/range.rs:LL:COL + scope 10 { + scope 11 (inlined core::num::::unchecked_add) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _13; // in scope 11 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => const 1_u32; // in scope 11 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + scope 12 { + } + } + } + } } } scope 8 (inlined cmp::impls::::lt) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL @@ -56,7 +69,6 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb1: { StorageLive(_12); // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 _6 = &mut _5; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 - StorageLive(_13); // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_11); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_7); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL _7 = &((*_6).0: u32); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL @@ -81,25 +93,27 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb3: { _13 = ((*_6).0: u32); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageLive(_14); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _14 = ::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb11]; // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_15); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_14); // scope 10 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _14 = const 1_u32; // scope 10 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _15 = unchecked_add::(_13, _14) -> [return: bb4, unwind unreachable]; // scope 12 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL - // + literal: Const { ty: unsafe fn(u32, usize) -> u32 {::forward_unchecked}, val: Value() } + // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32, u32) -> u32 {unchecked_add::}, val: Value() } } bb4: { - ((*_6).0: u32) = move _14; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_14); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_14); // scope 10 at $SRC_DIR/core/src/iter/range.rs:LL:COL + ((*_6).0: u32) = move _15; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_15); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL _12 = Option::::Some(_13); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL goto -> bb5; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL } bb5: { StorageDead(_11); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_13); // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _15 = discriminant(_12); // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + _16 = discriminant(_12); // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb12]; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 } bb6: { @@ -113,33 +127,33 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb8: { - _16 = ((_12 as Some).0: u32); // scope 1 at $DIR/range_iter.rs:+1:9: +1:10 - StorageLive(_17); // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 - _17 = &_3; // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 - StorageLive(_18); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 - _18 = (_16,); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 - _19 = >::call(move _17, move _18) -> [return: bb9, unwind: bb11]; // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + _17 = ((_12 as Some).0: u32); // scope 1 at $DIR/range_iter.rs:+1:9: +1:10 + StorageLive(_18); // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 + _18 = &_3; // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 + StorageLive(_19); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + _19 = (_17,); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + _20 = >::call(move _18, move _19) -> [return: bb9, unwind: bb10]; // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 // mir::Constant // + span: $DIR/range_iter.rs:22:9: 22:10 // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(u32), (u32,)) -> >::Output {>::call}, val: Value() } } bb9: { + StorageDead(_19); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13 StorageDead(_18); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13 - StorageDead(_17); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13 StorageDead(_12); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6 goto -> bb1; // scope 1 at $DIR/range_iter.rs:+1:5: +3:6 } - bb10: { - unreachable; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + bb10 (cleanup): { + drop(_3) -> [return: bb11, unwind terminate]; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2 } bb11 (cleanup): { - drop(_3) -> [return: bb12, unwind terminate]; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2 + resume; // scope 0 at $DIR/range_iter.rs:+0:1: +4:2 } - bb12 (cleanup): { - resume; // scope 0 at $DIR/range_iter.rs:+0:1: +4:2 + bb12: { + unreachable; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 } } diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir index f15722deee013..816bf9c5df804 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir @@ -11,10 +11,23 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { let mut _3: &u32; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL let mut _6: bool; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL let _7: u32; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - let mut _8: u32; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _9: u32; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 3 { debug old => _7; // in scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 4 { + scope 6 (inlined ::forward_unchecked) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug start => _7; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug n => const 1_usize; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _8: u32; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + scope 7 { + scope 8 (inlined core::num::::unchecked_add) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _7; // in scope 8 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => const 1_u32; // in scope 8 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + scope 9 { + } + } + } + } } } scope 5 (inlined cmp::impls::::lt) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL @@ -27,7 +40,6 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { } bb0: { - StorageLive(_7); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_6); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_2); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL _2 = &((*_1).0: u32); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL @@ -52,23 +64,25 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { bb2: { _7 = ((*_1).0: u32); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageLive(_8); // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _8 = ::forward_unchecked(_7, const 1_usize) -> bb3; // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_9); // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_8); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _8 = const 1_u32; // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _9 = unchecked_add::(_7, _8) -> [return: bb3, unwind unreachable]; // scope 9 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL - // + literal: Const { ty: unsafe fn(u32, usize) -> u32 {::forward_unchecked}, val: Value() } + // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32, u32) -> u32 {unchecked_add::}, val: Value() } } bb3: { - ((*_1).0: u32) = move _8; // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_8); // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_8); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + ((*_1).0: u32) = move _9; // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_9); // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL _0 = Option::::Some(_7); // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL goto -> bb4; // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL } bb4: { StorageDead(_6); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_7); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL return; // scope 0 at $DIR/range_iter.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir index 870496f14ea90..89d47378c6721 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir @@ -9,20 +9,21 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _5: std::ops::Range; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 let mut _6: &mut std::ops::Range; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 let mut _12: std::option::Option; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 - let mut _15: isize; // in scope 0 at $DIR/slice_iter.rs:+1:5: +4:6 - let mut _17: usize; // in scope 0 at $DIR/slice_iter.rs:+2:18: +2:26 - let mut _18: bool; // in scope 0 at $DIR/slice_iter.rs:+2:18: +2:26 - let mut _20: &impl Fn(usize, &T); // in scope 0 at $DIR/slice_iter.rs:+3:9: +3:10 - let mut _21: (usize, &T); // in scope 0 at $DIR/slice_iter.rs:+3:9: +3:16 - let _22: (); // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 + let mut _14: usize; // in scope 0 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _16: isize; // in scope 0 at $DIR/slice_iter.rs:+1:5: +4:6 + let mut _18: usize; // in scope 0 at $DIR/slice_iter.rs:+2:18: +2:26 + let mut _19: bool; // in scope 0 at $DIR/slice_iter.rs:+2:18: +2:26 + let mut _21: &impl Fn(usize, &T); // in scope 0 at $DIR/slice_iter.rs:+3:9: +3:10 + let mut _22: (usize, &T); // in scope 0 at $DIR/slice_iter.rs:+3:9: +3:16 + let _23: (); // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 scope 1 { debug iter => _5; // in scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 - let _16: usize; // in scope 1 at $DIR/slice_iter.rs:+1:9: +1:10 + let _17: usize; // in scope 1 at $DIR/slice_iter.rs:+1:9: +1:10 scope 2 { - debug i => _16; // in scope 2 at $DIR/slice_iter.rs:+1:9: +1:10 - let _19: &T; // in scope 2 at $DIR/slice_iter.rs:+2:13: +2:14 + debug i => _17; // in scope 2 at $DIR/slice_iter.rs:+1:9: +1:10 + let _20: &T; // in scope 2 at $DIR/slice_iter.rs:+2:13: +2:14 scope 3 { - debug x => _19; // in scope 3 at $DIR/slice_iter.rs:+2:13: +2:14 + debug x => _20; // in scope 3 at $DIR/slice_iter.rs:+2:13: +2:14 } } scope 5 (inlined iter::range::>::next) { // at $DIR/slice_iter.rs:49:14: 49:28 @@ -33,10 +34,22 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _8: &usize; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL let mut _11: bool; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL let _13: usize; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL - let mut _14: usize; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _15: usize; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 7 { debug old => _13; // in scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 8 { + scope 10 (inlined ::forward_unchecked) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug start => _13; // in scope 10 at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug n => const 1_usize; // in scope 10 at $SRC_DIR/core/src/iter/range.rs:LL:COL + scope 11 { + scope 12 (inlined core::num::::unchecked_add) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _13; // in scope 12 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => const 1_usize; // in scope 12 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + scope 13 { + } + } + } + } } } scope 9 (inlined cmp::impls::::lt) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL @@ -65,7 +78,6 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb1: { StorageLive(_12); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 _6 = &mut _5; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 - StorageLive(_13); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_11); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_7); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL _7 = &((*_6).0: usize); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL @@ -90,25 +102,27 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb3: { _13 = ((*_6).0: usize); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageLive(_14); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _14 = ::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb12]; // scope 8 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_15); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_14); // scope 8 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _14 = const 1_usize; // scope 8 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _15 = unchecked_add::(_13, _14) -> [return: bb4, unwind unreachable]; // scope 13 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL - // + literal: Const { ty: unsafe fn(usize, usize) -> usize {::forward_unchecked}, val: Value() } + // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize, usize) -> usize {unchecked_add::}, val: Value() } } bb4: { - ((*_6).0: usize) = move _14; // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_14); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_14); // scope 8 at $SRC_DIR/core/src/iter/range.rs:LL:COL + ((*_6).0: usize) = move _15; // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_15); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL _12 = Option::::Some(_13); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL goto -> bb5; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL } bb5: { StorageDead(_11); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_13); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _15 = discriminant(_12); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb11]; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 + _16 = discriminant(_12); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 + switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb13]; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 } bb6: { @@ -122,40 +136,40 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _16 = ((_12 as Some).0: usize); // scope 1 at $DIR/slice_iter.rs:+1:9: +1:10 - _17 = Len((*_1)); // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26 - _18 = Lt(_16, _17); // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26 - assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb9, unwind: bb12]; // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26 + _17 = ((_12 as Some).0: usize); // scope 1 at $DIR/slice_iter.rs:+1:9: +1:10 + _18 = Len((*_1)); // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26 + _19 = Lt(_17, _18); // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26 + assert(move _19, "index out of bounds: the length is {} but the index is {}", move _18, _17) -> [success: bb9, unwind: bb11]; // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26 } bb9: { - _19 = &(*_1)[_16]; // scope 2 at $DIR/slice_iter.rs:+2:17: +2:26 - StorageLive(_20); // scope 3 at $DIR/slice_iter.rs:+3:9: +3:10 - _20 = &_2; // scope 3 at $DIR/slice_iter.rs:+3:9: +3:10 - StorageLive(_21); // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16 - _21 = (_16, _19); // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16 - _22 = >::call(move _20, move _21) -> [return: bb10, unwind: bb12]; // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16 + _20 = &(*_1)[_17]; // scope 2 at $DIR/slice_iter.rs:+2:17: +2:26 + StorageLive(_21); // scope 3 at $DIR/slice_iter.rs:+3:9: +3:10 + _21 = &_2; // scope 3 at $DIR/slice_iter.rs:+3:9: +3:10 + StorageLive(_22); // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16 + _22 = (_17, _20); // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16 + _23 = >::call(move _21, move _22) -> [return: bb10, unwind: bb11]; // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16 // mir::Constant // + span: $DIR/slice_iter.rs:51:9: 51:10 // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(usize, &T), (usize, &T)) -> >::Output {>::call}, val: Value() } } bb10: { + StorageDead(_22); // scope 3 at $DIR/slice_iter.rs:+3:15: +3:16 StorageDead(_21); // scope 3 at $DIR/slice_iter.rs:+3:15: +3:16 - StorageDead(_20); // scope 3 at $DIR/slice_iter.rs:+3:15: +3:16 StorageDead(_12); // scope 1 at $DIR/slice_iter.rs:+4:5: +4:6 goto -> bb1; // scope 1 at $DIR/slice_iter.rs:+1:5: +4:6 } - bb11: { - unreachable; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 + bb11 (cleanup): { + drop(_2) -> [return: bb12, unwind terminate]; // scope 0 at $DIR/slice_iter.rs:+5:1: +5:2 } bb12 (cleanup): { - drop(_2) -> [return: bb13, unwind terminate]; // scope 0 at $DIR/slice_iter.rs:+5:1: +5:2 + resume; // scope 0 at $DIR/slice_iter.rs:+0:1: +5:2 } - bb13 (cleanup): { - resume; // scope 0 at $DIR/slice_iter.rs:+0:1: +5:2 + bb13: { + unreachable; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 } }