Enable DestinationPropagation by default.

This commit is contained in:
Camille GILLOT 2023-04-30 20:48:29 +00:00 committed by Camille Gillot
parent a9d0a6f155
commit 44c1a00a2f
26 changed files with 590 additions and 923 deletions

View file

@ -153,15 +153,7 @@ pub(super) struct DestinationPropagation;
impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
// For now, only run at MIR opt level 3. Two things need to be changed before this can be
// turned on by default:
// 1. Because of the overeager removal of storage statements, this can cause stack space
// regressions. This opt is not the place to fix this though, it's a more general
// problem in MIR.
// 2. Despite being an overall perf improvement, this still causes a 30% regression in
// keccak. We can temporarily fix this by bounding function size, but in the long term
// we should fix this by being smarter about invalidating analysis results.
sess.mir_opt_level() >= 3
sess.mir_opt_level() >= 2
}
#[tracing::instrument(level = "trace", skip(self, tcx, body))]

View file

@ -156,7 +156,6 @@ declare_passes! {
mod match_branches : MatchBranchSimplification;
mod mentioned_items : MentionedItems;
mod multiple_return_terminators : MultipleReturnTerminators;
mod nrvo : RenameReturnPlace;
mod post_drop_elaboration : CheckLiveDrops;
mod prettify : ReorderBasicBlocks, ReorderLocals;
mod promote_consts : PromoteTemps;
@ -715,7 +714,6 @@ pub(crate) fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'
&jump_threading::JumpThreading,
&early_otherwise_branch::EarlyOtherwiseBranch,
&simplify_comparison_integral::SimplifyComparisonIntegral,
&dest_prop::DestinationPropagation,
&o1(simplify_branches::SimplifyConstCondition::Final),
&o1(remove_noop_landing_pads::RemoveNoopLandingPads),
&o1(simplify::SimplifyCfg::Final),
@ -723,7 +721,7 @@ pub(crate) fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'
&strip_debuginfo::StripDebugInfo,
&copy_prop::CopyProp,
&dead_store_elimination::DeadStoreElimination::Final,
&nrvo::RenameReturnPlace,
&dest_prop::DestinationPropagation,
&simplify::SimplifyLocals::Final,
&multiple_return_terminators::MultipleReturnTerminators,
&large_enums::EnumSizeOpt { discrepancy: 128 },

View file

@ -1,234 +0,0 @@
//! See the docs for [`RenameReturnPlace`].
use rustc_hir::Mutability;
use rustc_index::bit_set::DenseBitSet;
use rustc_middle::bug;
use rustc_middle::mir::visit::{MutVisitor, NonUseContext, PlaceContext, Visitor};
use rustc_middle::mir::{self, BasicBlock, Local, Location};
use rustc_middle::ty::TyCtxt;
use tracing::{debug, trace};
/// This pass looks for MIR that always copies the same local into the return place and eliminates
/// the copy by renaming all uses of that local to `_0`.
///
/// This allows LLVM to perform an optimization similar to the named return value optimization
/// (NRVO) that is guaranteed in C++. This avoids a stack allocation and `memcpy` for the
/// relatively common pattern of allocating a buffer on the stack, mutating it, and returning it by
/// value like so:
///
/// ```rust
/// fn foo(init: fn(&mut [u8; 1024])) -> [u8; 1024] {
/// let mut buf = [0; 1024];
/// init(&mut buf);
/// buf
/// }
/// ```
///
/// For now, this pass is very simple and only capable of eliminating a single copy. A more general
/// version of copy propagation, such as the one based on non-overlapping live ranges in [#47954] and
/// [#71003], could yield even more benefits.
///
/// [#47954]: https://github.com/rust-lang/rust/pull/47954
/// [#71003]: https://github.com/rust-lang/rust/pull/71003
pub(super) struct RenameReturnPlace;
impl<'tcx> crate::MirPass<'tcx> for RenameReturnPlace {
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
// unsound: #111005
sess.mir_opt_level() > 0 && sess.opts.unstable_opts.unsound_mir_opts
}
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut mir::Body<'tcx>) {
let def_id = body.source.def_id();
let Some(returned_local) = local_eligible_for_nrvo(body) else {
debug!("`{:?}` was ineligible for NRVO", def_id);
return;
};
debug!(
"`{:?}` was eligible for NRVO, making {:?} the return place",
def_id, returned_local
);
RenameToReturnPlace { tcx, to_rename: returned_local }.visit_body_preserves_cfg(body);
// Clean up the `NOP`s we inserted for statements made useless by our renaming.
for block_data in body.basic_blocks.as_mut_preserves_cfg() {
block_data.statements.retain(|stmt| stmt.kind != mir::StatementKind::Nop);
}
// Overwrite the debuginfo of `_0` with that of the renamed local.
let (renamed_decl, ret_decl) =
body.local_decls.pick2_mut(returned_local, mir::RETURN_PLACE);
// Sometimes, the return place is assigned a local of a different but coercible type, for
// example `&mut T` instead of `&T`. Overwriting the `LocalInfo` for the return place means
// its type may no longer match the return type of its function. This doesn't cause a
// problem in codegen because these two types are layout-compatible, but may be unexpected.
debug!("_0: {:?} = {:?}: {:?}", ret_decl.ty, returned_local, renamed_decl.ty);
ret_decl.clone_from(renamed_decl);
// The return place is always mutable.
ret_decl.mutability = Mutability::Mut;
}
fn is_required(&self) -> bool {
false
}
}
/// MIR that is eligible for the NRVO must fulfill two conditions:
/// 1. The return place must not be read prior to the `Return` terminator.
/// 2. A simple assignment of a whole local to the return place (e.g., `_0 = _1`) must be the
/// only definition of the return place reaching the `Return` terminator.
///
/// If the MIR fulfills both these conditions, this function returns the `Local` that is assigned
/// to the return place along all possible paths through the control-flow graph.
fn local_eligible_for_nrvo(body: &mir::Body<'_>) -> Option<Local> {
if IsReturnPlaceRead::run(body) {
return None;
}
let mut copied_to_return_place = None;
for block in body.basic_blocks.indices() {
// Look for blocks with a `Return` terminator.
if !matches!(body[block].terminator().kind, mir::TerminatorKind::Return) {
continue;
}
// Look for an assignment of a single local to the return place prior to the `Return`.
let returned_local = find_local_assigned_to_return_place(block, body)?;
match body.local_kind(returned_local) {
// FIXME: Can we do this for arguments as well?
mir::LocalKind::Arg => return None,
mir::LocalKind::ReturnPointer => bug!("Return place was assigned to itself?"),
mir::LocalKind::Temp => {}
}
// If multiple different locals are copied to the return place. We can't pick a
// single one to rename.
if copied_to_return_place.is_some_and(|old| old != returned_local) {
return None;
}
copied_to_return_place = Some(returned_local);
}
copied_to_return_place
}
fn find_local_assigned_to_return_place(start: BasicBlock, body: &mir::Body<'_>) -> Option<Local> {
let mut block = start;
let mut seen = DenseBitSet::new_empty(body.basic_blocks.len());
// Iterate as long as `block` has exactly one predecessor that we have not yet visited.
while seen.insert(block) {
trace!("Looking for assignments to `_0` in {:?}", block);
let local = body[block].statements.iter().rev().find_map(as_local_assigned_to_return_place);
if local.is_some() {
return local;
}
match body.basic_blocks.predecessors()[block].as_slice() {
&[pred] => block = pred,
_ => return None,
}
}
None
}
// If this statement is an assignment of an unprojected local to the return place,
// return that local.
fn as_local_assigned_to_return_place(stmt: &mir::Statement<'_>) -> Option<Local> {
if let mir::StatementKind::Assign(box (lhs, rhs)) = &stmt.kind {
if lhs.as_local() == Some(mir::RETURN_PLACE) {
if let mir::Rvalue::Use(mir::Operand::Copy(rhs) | mir::Operand::Move(rhs)) = rhs {
return rhs.as_local();
}
}
}
None
}
struct RenameToReturnPlace<'tcx> {
to_rename: Local,
tcx: TyCtxt<'tcx>,
}
/// Replaces all uses of `self.to_rename` with `_0`.
impl<'tcx> MutVisitor<'tcx> for RenameToReturnPlace<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
}
fn visit_statement(&mut self, stmt: &mut mir::Statement<'tcx>, loc: Location) {
// Remove assignments of the local being replaced to the return place, since it is now the
// return place:
// _0 = _1
if as_local_assigned_to_return_place(stmt) == Some(self.to_rename) {
stmt.kind = mir::StatementKind::Nop;
return;
}
// Remove storage annotations for the local being replaced:
// StorageLive(_1)
if let mir::StatementKind::StorageLive(local) | mir::StatementKind::StorageDead(local) =
stmt.kind
{
if local == self.to_rename {
stmt.kind = mir::StatementKind::Nop;
return;
}
}
self.super_statement(stmt, loc)
}
fn visit_terminator(&mut self, terminator: &mut mir::Terminator<'tcx>, loc: Location) {
// Ignore the implicit "use" of the return place in a `Return` statement.
if let mir::TerminatorKind::Return = terminator.kind {
return;
}
self.super_terminator(terminator, loc);
}
fn visit_local(&mut self, l: &mut Local, ctxt: PlaceContext, _: Location) {
if *l == mir::RETURN_PLACE {
assert_eq!(ctxt, PlaceContext::NonUse(NonUseContext::VarDebugInfo));
} else if *l == self.to_rename {
*l = mir::RETURN_PLACE;
}
}
}
struct IsReturnPlaceRead(bool);
impl IsReturnPlaceRead {
fn run(body: &mir::Body<'_>) -> bool {
let mut vis = IsReturnPlaceRead(false);
vis.visit_body(body);
vis.0
}
}
impl<'tcx> Visitor<'tcx> for IsReturnPlaceRead {
fn visit_local(&mut self, l: Local, ctxt: PlaceContext, _: Location) {
if l == mir::RETURN_PLACE && ctxt.is_use() && !ctxt.is_place_assignment() {
self.0 = true;
}
}
fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, loc: Location) {
// Ignore the implicit "use" of the return place in a `Return` statement.
if let mir::TerminatorKind::Return = terminator.kind {
return;
}
self.super_terminator(terminator, loc);
}
}

View file

@ -1,5 +1,5 @@
- // MIR for `nrvo` before RenameReturnPlace
+ // MIR for `nrvo` after RenameReturnPlace
- // MIR for `nrvo` before DestinationPropagation
+ // MIR for `nrvo` after DestinationPropagation
fn nrvo(_1: for<'a> fn(&'a mut [u8; 1024])) -> [u8; 1024] {
debug init => _1;
@ -10,32 +10,33 @@
let mut _5: &mut [u8; 1024];
let mut _6: &mut [u8; 1024];
scope 1 {
- debug buf => _2;
+ debug buf => _0;
debug buf => _2;
}
bb0: {
- StorageLive(_2);
- _2 = [const 0_u8; 1024];
+ _0 = [const 0_u8; 1024];
StorageLive(_2);
_2 = [const 0_u8; 1024];
StorageLive(_3);
StorageLive(_4);
_4 = copy _1;
- StorageLive(_4);
- _4 = copy _1;
+ nop;
+ nop;
StorageLive(_5);
StorageLive(_6);
- _6 = &mut _2;
+ _6 = &mut _0;
_6 = &mut _2;
_5 = &mut (*_6);
_3 = move _4(move _5) -> [return: bb1, unwind unreachable];
- _3 = move _4(move _5) -> [return: bb1, unwind unreachable];
+ _3 = move _1(move _5) -> [return: bb1, unwind unreachable];
}
bb1: {
StorageDead(_5);
StorageDead(_4);
- StorageDead(_4);
+ nop;
StorageDead(_6);
StorageDead(_3);
- _0 = copy _2;
- StorageDead(_2);
_0 = copy _2;
StorageDead(_2);
return;
}
}

View file

@ -1,5 +1,5 @@
- // MIR for `nrvo` before RenameReturnPlace
+ // MIR for `nrvo` after RenameReturnPlace
- // MIR for `nrvo` before DestinationPropagation
+ // MIR for `nrvo` after DestinationPropagation
fn nrvo(_1: for<'a> fn(&'a mut [u8; 1024])) -> [u8; 1024] {
debug init => _1;
@ -10,32 +10,33 @@
let mut _5: &mut [u8; 1024];
let mut _6: &mut [u8; 1024];
scope 1 {
- debug buf => _2;
+ debug buf => _0;
debug buf => _2;
}
bb0: {
- StorageLive(_2);
- _2 = [const 0_u8; 1024];
+ _0 = [const 0_u8; 1024];
StorageLive(_2);
_2 = [const 0_u8; 1024];
StorageLive(_3);
StorageLive(_4);
_4 = copy _1;
- StorageLive(_4);
- _4 = copy _1;
+ nop;
+ nop;
StorageLive(_5);
StorageLive(_6);
- _6 = &mut _2;
+ _6 = &mut _0;
_6 = &mut _2;
_5 = &mut (*_6);
_3 = move _4(move _5) -> [return: bb1, unwind continue];
- _3 = move _4(move _5) -> [return: bb1, unwind continue];
+ _3 = move _1(move _5) -> [return: bb1, unwind continue];
}
bb1: {
StorageDead(_5);
StorageDead(_4);
- StorageDead(_4);
+ nop;
StorageDead(_6);
StorageDead(_3);
- _0 = copy _2;
- StorageDead(_2);
_0 = copy _2;
StorageDead(_2);
return;
}
}

View file

@ -1,8 +1,8 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//@ test-mir-pass: RenameReturnPlace
//@ test-mir-pass: DestinationPropagation
// EMIT_MIR nrvo_simple.nrvo.RenameReturnPlace.diff
// EMIT_MIR nrvo_borrowed.nrvo.DestinationPropagation.diff
fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] {
let mut buf = [0; 1024];
init(&mut buf);

View file

@ -1,18 +1,17 @@
// This is a miscompilation, #111005 to track
//@ test-mir-pass: RenameReturnPlace
//@ test-mir-pass: DestinationPropagation
#![feature(custom_mir, core_intrinsics)]
extern crate core;
use core::intrinsics::mir::*;
// EMIT_MIR nrvo_miscompile_111005.wrong.RenameReturnPlace.diff
// EMIT_MIR nrvo_miscompile_111005.wrong.DestinationPropagation.diff
#[custom_mir(dialect = "runtime", phase = "initial")]
pub fn wrong(arg: char) -> char {
// CHECK-LABEL: fn wrong(
// CHECK: _0 = copy _1;
// FIXME: This is wrong:
// CHECK-NEXT: _0 = const 'b';
// CHECK-NEXT: _1 = const 'b';
// CHECK-NEXT: return;
mir! {
{

View file

@ -1,5 +1,5 @@
- // MIR for `wrong` before RenameReturnPlace
+ // MIR for `wrong` after RenameReturnPlace
- // MIR for `wrong` before DestinationPropagation
+ // MIR for `wrong` after DestinationPropagation
fn wrong(_1: char) -> char {
let mut _0: char;
@ -9,8 +9,9 @@
- _2 = copy _1;
- _0 = copy _2;
- _2 = const 'b';
+ nop;
+ _0 = copy _1;
+ _0 = const 'b';
+ _1 = const 'b';
return;
}
}

View file

@ -44,8 +44,7 @@ pub fn saturating_sub_at_home(lhs: u32, rhs: u32) -> u32 {
// CHECK-LABEL: fn saturating_sub_at_home
// CHECK: [[DELTA:_[0-9]+]] = SubUnchecked(copy _1, copy _2)
// CHECK: [[TEMP1:_.+]] = Option::<u32>::Some({{move|copy}} [[DELTA]]);
// CHECK: [[TEMP2:_.+]] = {{move|copy}} (([[TEMP1]] as Some).0: u32);
// CHECK: _0 = {{move|copy}} [[TEMP2]];
// CHECK: _0 = {{move|copy}} (([[TEMP1]] as Some).0: u32);
u32::checked_sub(lhs, rhs).unwrap_or(0)
}

View file

@ -10,7 +10,6 @@ fn saturating_sub_at_home(_1: u32, _2: u32) -> u32 {
let mut _4: u32;
}
scope 2 (inlined Option::<u32>::unwrap_or) {
let _6: u32;
scope 3 {
}
}
@ -28,10 +27,7 @@ fn saturating_sub_at_home(_1: u32, _2: u32) -> u32 {
_5 = Option::<u32>::Some(move _4);
StorageDead(_4);
StorageDead(_3);
StorageLive(_6);
_6 = move ((_5 as Some).0: u32);
_0 = move _6;
StorageDead(_6);
_0 = move ((_5 as Some).0: u32);
goto -> bb3;
}

View file

@ -10,7 +10,6 @@ fn saturating_sub_at_home(_1: u32, _2: u32) -> u32 {
let mut _4: u32;
}
scope 2 (inlined Option::<u32>::unwrap_or) {
let _6: u32;
scope 3 {
}
}
@ -28,10 +27,7 @@ fn saturating_sub_at_home(_1: u32, _2: u32) -> u32 {
_5 = Option::<u32>::Some(move _4);
StorageDead(_4);
StorageDead(_3);
StorageLive(_6);
_6 = move ((_5 as Some).0: u32);
_0 = move _6;
StorageDead(_6);
_0 = move ((_5 as Some).0: u32);
goto -> bb3;
}

View file

@ -5,8 +5,9 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool {
debug b => _2;
let mut _0: bool;
scope 1 (inlined <MultiField as PartialOrd>::le) {
let mut _11: std::option::Option<std::cmp::Ordering>;
let mut _6: std::option::Option<std::cmp::Ordering>;
scope 2 (inlined Option::<std::cmp::Ordering>::is_some_and::<fn(std::cmp::Ordering) -> bool {std::cmp::Ordering::is_le}>) {
let mut _11: isize;
let _12: std::cmp::Ordering;
scope 3 {
scope 4 (inlined <fn(std::cmp::Ordering) -> bool {std::cmp::Ordering::is_le} as FnOnce<(std::cmp::Ordering,)>>::call_once - shim(fn(std::cmp::Ordering) -> bool {std::cmp::Ordering::is_le})) {
@ -19,7 +20,6 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool {
}
}
scope 7 (inlined <MultiField as PartialOrd>::partial_cmp) {
let mut _6: std::option::Option<std::cmp::Ordering>;
let mut _7: i8;
scope 8 {
}
@ -38,9 +38,8 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool {
bb0: {
StorageLive(_12);
StorageLive(_11);
StorageLive(_5);
StorageLive(_6);
StorageLive(_5);
StorageLive(_7);
StorageLive(_3);
_3 = copy ((*_1).0: char);
@ -63,30 +62,44 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool {
_10 = Cmp(move _8, move _9);
StorageDead(_9);
StorageDead(_8);
_11 = Option::<std::cmp::Ordering>::Some(move _10);
_6 = Option::<std::cmp::Ordering>::Some(move _10);
StorageDead(_10);
StorageDead(_7);
StorageDead(_6);
StorageDead(_5);
goto -> bb3;
StorageLive(_11);
goto -> bb4;
}
bb2: {
_11 = copy _6;
StorageDead(_7);
StorageDead(_6);
StorageDead(_5);
goto -> bb3;
StorageLive(_11);
_11 = discriminant(_6);
switchInt(move _11) -> [0: bb3, 1: bb4, otherwise: bb6];
}
bb3: {
_12 = move ((_11 as Some).0: std::cmp::Ordering);
_0 = const false;
goto -> bb5;
}
bb4: {
_12 = move ((_6 as Some).0: std::cmp::Ordering);
StorageLive(_13);
_13 = discriminant(_12);
_0 = Le(move _13, const 0_i8);
StorageDead(_13);
goto -> bb5;
}
bb5: {
StorageDead(_11);
StorageDead(_6);
StorageDead(_12);
return;
}
bb6: {
unreachable;
}
}

View file

@ -25,7 +25,10 @@ pub fn demo_le(a: &MultiField, b: &MultiField) -> bool {
// CHECK: Cmp(move [[A1]], move [[B1]]);
// CHECK: [[D1:_[0-9]+]] = discriminant({{.+}});
// CHECK: _0 = Le(move [[D1]], const 0_i8);
// CHECK: switchInt(move [[D1]]) -> [0: bb{{[0-9]+}}, 1: bb{{[0-9]+}}, otherwise: bb{{[0-9]+}}];
// CHECK: [[D2:_[0-9]+]] = discriminant({{.+}});
// CHECK: _0 = Le(move [[D2]], const 0_i8);
*a <= *b
}

View file

@ -4,10 +4,9 @@ fn <impl at $DIR/derived_ord.rs:5:10: 5:20>::partial_cmp(_1: &MultiField, _2: &M
debug self => _1;
debug other => _2;
let mut _0: std::option::Option<std::cmp::Ordering>;
let mut _6: std::option::Option<std::cmp::Ordering>;
let mut _7: i8;
let mut _6: i8;
scope 1 {
debug cmp => _6;
debug cmp => _0;
}
scope 2 (inlined std::cmp::impls::<impl PartialOrd for char>::partial_cmp) {
let mut _3: char;
@ -15,9 +14,9 @@ fn <impl at $DIR/derived_ord.rs:5:10: 5:20>::partial_cmp(_1: &MultiField, _2: &M
let mut _5: std::cmp::Ordering;
}
scope 3 (inlined std::cmp::impls::<impl PartialOrd for i16>::partial_cmp) {
let mut _7: i16;
let mut _8: i16;
let mut _9: i16;
let mut _10: std::cmp::Ordering;
let mut _9: std::cmp::Ordering;
}
bb0: {
@ -28,27 +27,26 @@ fn <impl at $DIR/derived_ord.rs:5:10: 5:20>::partial_cmp(_1: &MultiField, _2: &M
_5 = Cmp(move _3, move _4);
StorageDead(_4);
StorageDead(_3);
_6 = Option::<std::cmp::Ordering>::Some(copy _5);
_7 = discriminant(_5);
switchInt(move _7) -> [0: bb1, otherwise: bb2];
_0 = Option::<std::cmp::Ordering>::Some(copy _5);
_6 = discriminant(_5);
switchInt(move _6) -> [0: bb1, otherwise: bb2];
}
bb1: {
StorageLive(_10);
StorageLive(_8);
_8 = copy ((*_1).1: i16);
StorageLive(_9);
_9 = copy ((*_2).1: i16);
_10 = Cmp(move _8, move _9);
StorageDead(_9);
StorageLive(_7);
_7 = copy ((*_1).1: i16);
StorageLive(_8);
_8 = copy ((*_2).1: i16);
_9 = Cmp(move _7, move _8);
StorageDead(_8);
_0 = Option::<std::cmp::Ordering>::Some(move _10);
StorageDead(_10);
StorageDead(_7);
_0 = Option::<std::cmp::Ordering>::Some(move _9);
StorageDead(_9);
goto -> bb3;
}
bb2: {
_0 = copy _6;
goto -> bb3;
}

View file

@ -5,23 +5,21 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
debug end => _2;
debug f => _3;
let mut _0: ();
let mut _4: u32;
let mut _9: std::option::Option<u32>;
let mut _11: &impl Fn(u32);
let mut _12: (u32,);
let _13: ();
let mut _7: std::option::Option<u32>;
let mut _9: &impl Fn(u32);
let mut _10: (u32,);
let _11: ();
scope 1 {
debug ((iter: std::ops::Range<u32>).0: u32) => _4;
debug ((iter: std::ops::Range<u32>).0: u32) => _1;
debug ((iter: std::ops::Range<u32>).1: u32) => _2;
let _10: u32;
let _8: u32;
scope 2 {
debug x => _10;
debug x => _8;
}
scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) {
scope 5 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) {
let mut _6: bool;
let _7: u32;
let mut _8: u32;
let mut _5: bool;
let _6: u32;
scope 6 {
scope 8 (inlined <u32 as Step>::forward_unchecked) {
scope 9 (inlined #[track_caller] core::num::<impl u32>::unchecked_add) {
@ -33,7 +31,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
}
}
scope 7 (inlined std::cmp::impls::<impl PartialOrd for u32>::lt) {
let mut _5: u32;
let mut _4: u32;
}
}
}
@ -42,25 +40,22 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
}
bb0: {
StorageLive(_4);
_4 = copy _1;
goto -> bb1;
}
bb1: {
StorageLive(_9);
StorageLive(_6);
StorageLive(_7);
StorageLive(_5);
_5 = copy _4;
_6 = Lt(move _5, copy _2);
StorageDead(_5);
switchInt(move _6) -> [0: bb2, otherwise: bb4];
StorageLive(_4);
_4 = copy _1;
_5 = Lt(move _4, copy _2);
StorageDead(_4);
switchInt(move _5) -> [0: bb2, otherwise: bb4];
}
bb2: {
StorageDead(_6);
StorageDead(_9);
StorageDead(_4);
StorageDead(_5);
StorageDead(_7);
drop(_3) -> [return: bb3, unwind unreachable];
}
@ -69,25 +64,22 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
}
bb4: {
_7 = copy _4;
StorageLive(_8);
_8 = AddUnchecked(copy _7, const 1_u32);
_4 = move _8;
StorageDead(_8);
_9 = Option::<u32>::Some(copy _7);
StorageDead(_6);
_10 = copy ((_9 as Some).0: u32);
StorageLive(_11);
_11 = &_3;
StorageLive(_12);
_12 = (copy _10,);
_13 = <impl Fn(u32) as Fn<(u32,)>>::call(move _11, move _12) -> [return: bb5, unwind unreachable];
_6 = copy _1;
_1 = AddUnchecked(copy _6, const 1_u32);
_7 = Option::<u32>::Some(copy _6);
StorageDead(_5);
_8 = copy ((_7 as Some).0: u32);
StorageLive(_9);
_9 = &_3;
StorageLive(_10);
_10 = (copy _8,);
_11 = <impl Fn(u32) as Fn<(u32,)>>::call(move _9, move _10) -> [return: bb5, unwind unreachable];
}
bb5: {
StorageDead(_12);
StorageDead(_11);
StorageDead(_10);
StorageDead(_9);
StorageDead(_7);
goto -> bb1;
}
}

View file

@ -5,23 +5,21 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
debug end => _2;
debug f => _3;
let mut _0: ();
let mut _4: u32;
let mut _9: std::option::Option<u32>;
let mut _11: &impl Fn(u32);
let mut _12: (u32,);
let _13: ();
let mut _7: std::option::Option<u32>;
let mut _9: &impl Fn(u32);
let mut _10: (u32,);
let _11: ();
scope 1 {
debug ((iter: std::ops::Range<u32>).0: u32) => _4;
debug ((iter: std::ops::Range<u32>).0: u32) => _1;
debug ((iter: std::ops::Range<u32>).1: u32) => _2;
let _10: u32;
let _8: u32;
scope 2 {
debug x => _10;
debug x => _8;
}
scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) {
scope 5 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) {
let mut _6: bool;
let _7: u32;
let mut _8: u32;
let mut _5: bool;
let _6: u32;
scope 6 {
scope 8 (inlined <u32 as Step>::forward_unchecked) {
scope 9 (inlined #[track_caller] core::num::<impl u32>::unchecked_add) {
@ -33,7 +31,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
}
}
scope 7 (inlined std::cmp::impls::<impl PartialOrd for u32>::lt) {
let mut _5: u32;
let mut _4: u32;
}
}
}
@ -42,25 +40,22 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
}
bb0: {
StorageLive(_4);
_4 = copy _1;
goto -> bb1;
}
bb1: {
StorageLive(_9);
StorageLive(_6);
StorageLive(_7);
StorageLive(_5);
_5 = copy _4;
_6 = Lt(move _5, copy _2);
StorageDead(_5);
switchInt(move _6) -> [0: bb2, otherwise: bb4];
StorageLive(_4);
_4 = copy _1;
_5 = Lt(move _4, copy _2);
StorageDead(_4);
switchInt(move _5) -> [0: bb2, otherwise: bb4];
}
bb2: {
StorageDead(_6);
StorageDead(_9);
StorageDead(_4);
StorageDead(_5);
StorageDead(_7);
drop(_3) -> [return: bb3, unwind continue];
}
@ -69,25 +64,22 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
}
bb4: {
_7 = copy _4;
StorageLive(_8);
_8 = AddUnchecked(copy _7, const 1_u32);
_4 = move _8;
StorageDead(_8);
_9 = Option::<u32>::Some(copy _7);
StorageDead(_6);
_10 = copy ((_9 as Some).0: u32);
StorageLive(_11);
_11 = &_3;
StorageLive(_12);
_12 = (copy _10,);
_13 = <impl Fn(u32) as Fn<(u32,)>>::call(move _11, move _12) -> [return: bb5, unwind: bb6];
_6 = copy _1;
_1 = AddUnchecked(copy _6, const 1_u32);
_7 = Option::<u32>::Some(copy _6);
StorageDead(_5);
_8 = copy ((_7 as Some).0: u32);
StorageLive(_9);
_9 = &_3;
StorageLive(_10);
_10 = (copy _8,);
_11 = <impl Fn(u32) as Fn<(u32,)>>::call(move _9, move _10) -> [return: bb5, unwind: bb6];
}
bb5: {
StorageDead(_12);
StorageDead(_11);
StorageDead(_10);
StorageDead(_9);
StorageDead(_7);
goto -> bb1;
}

View file

@ -4,30 +4,28 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
debug slice => _1;
debug f => _2;
let mut _0: ();
let mut _11: std::ptr::NonNull<T>;
let mut _12: *const T;
let mut _13: usize;
let mut _32: std::option::Option<(usize, &T)>;
let mut _35: &impl Fn(usize, &T);
let mut _36: (usize, &T);
let _37: ();
let mut _10: usize;
let mut _28: std::option::Option<(usize, &T)>;
let mut _31: &impl Fn(usize, &T);
let mut _32: (usize, &T);
let _33: ();
scope 1 {
debug (((iter: Enumerate<std::slice::Iter<'_, T>>).0: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _11;
debug (((iter: Enumerate<std::slice::Iter<'_, T>>).0: std::slice::Iter<'_, T>).1: *const T) => _12;
debug (((iter: Enumerate<std::slice::Iter<'_, T>>).0: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _6;
debug (((iter: Enumerate<std::slice::Iter<'_, T>>).0: std::slice::Iter<'_, T>).1: *const T) => _9;
debug (((iter: Enumerate<std::slice::Iter<'_, T>>).0: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>;
debug ((iter: Enumerate<std::slice::Iter<'_, T>>).1: usize) => _13;
let _33: usize;
let _34: &T;
debug ((iter: Enumerate<std::slice::Iter<'_, T>>).1: usize) => _10;
let _29: usize;
let _30: &T;
scope 2 {
debug i => _33;
debug x => _34;
debug i => _29;
debug x => _30;
}
scope 18 (inlined <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next) {
let mut _27: std::option::Option<&T>;
let mut _30: (usize, bool);
let mut _31: (usize, &T);
let mut _23: std::option::Option<&T>;
let mut _26: (usize, bool);
let mut _27: (usize, &T);
scope 19 {
let _29: usize;
let _25: usize;
scope 24 {
}
}
@ -42,21 +40,21 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
}
}
scope 25 (inlined <Option<&T> as Try>::branch) {
let _28: &T;
let _24: &T;
scope 26 {
}
}
scope 28 (inlined <std::slice::Iter<'_, T> as Iterator>::next) {
let _14: std::ptr::NonNull<T>;
let _16: std::ptr::NonNull<T>;
let mut _19: bool;
let mut _22: std::ptr::NonNull<T>;
let mut _24: usize;
let _26: &T;
let mut _6: std::ptr::NonNull<T>;
let _11: std::ptr::NonNull<T>;
let _13: std::ptr::NonNull<T>;
let mut _16: bool;
let mut _20: usize;
let _22: &T;
scope 29 {
let _15: *const T;
let _12: *const T;
scope 30 {
let _23: usize;
let _19: usize;
scope 31 {
scope 34 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) {
scope 35 (inlined core::ub_checks::check_language_ub) {
@ -72,21 +70,21 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
}
}
scope 38 (inlined <NonNull<T> as PartialEq>::eq) {
let mut _17: *mut T;
let mut _18: *mut T;
let mut _14: *mut T;
let mut _15: *mut T;
scope 39 (inlined NonNull::<T>::as_ptr) {
}
scope 40 (inlined NonNull::<T>::as_ptr) {
}
}
scope 41 (inlined NonNull::<T>::add) {
let mut _20: *const T;
let mut _21: *const T;
let mut _17: *const T;
let mut _18: *const T;
scope 42 (inlined NonNull::<T>::as_ptr) {
}
}
scope 43 (inlined NonNull::<T>::as_ref::<'_>) {
let _25: *const T;
let _21: *const T;
scope 44 (inlined NonNull::<T>::as_ptr) {
}
scope 45 (inlined std::ptr::mut_ptr::<impl *mut T>::cast_const) {
@ -102,9 +100,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
let _3: usize;
let mut _7: *mut T;
let mut _8: *mut T;
let mut _10: *const T;
scope 5 {
let _6: std::ptr::NonNull<T>;
scope 6 {
let _9: *const T;
scope 7 {
@ -145,7 +141,6 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
_5 = copy _4 as *const T (PtrToPtr);
_6 = NonNull::<T> { pointer: copy _5 };
StorageDead(_5);
StorageLive(_9);
switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb1, otherwise: bb2];
}
@ -166,97 +161,86 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
}
bb3: {
_10 = copy _9;
StorageDead(_9);
StorageDead(_4);
StorageDead(_3);
StorageLive(_11);
StorageLive(_12);
StorageLive(_13);
_11 = copy _6;
_12 = copy _10;
_13 = const 0_usize;
StorageLive(_10);
_10 = const 0_usize;
goto -> bb4;
}
bb4: {
StorageLive(_32);
StorageLive(_29);
StorageLive(_30);
StorageLive(_27);
StorageLive(_14);
StorageLive(_15);
StorageLive(_23);
StorageLive(_24);
StorageLive(_16);
StorageLive(_28);
StorageLive(_25);
StorageLive(_26);
_14 = copy _11;
_15 = copy _12;
StorageLive(_23);
StorageLive(_11);
StorageLive(_12);
StorageLive(_19);
StorageLive(_20);
StorageLive(_13);
StorageLive(_22);
_11 = copy _6;
_12 = copy _9;
switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb5, otherwise: bb8];
}
bb5: {
StorageLive(_19);
_16 = copy _15 as std::ptr::NonNull<T> (Transmute);
StorageLive(_17);
_17 = copy _14 as *mut T (Transmute);
StorageLive(_18);
_18 = copy _16 as *mut T (Transmute);
_19 = Eq(copy _17, copy _18);
StorageDead(_18);
StorageDead(_17);
switchInt(move _19) -> [0: bb6, otherwise: bb7];
StorageLive(_16);
_13 = copy _12 as std::ptr::NonNull<T> (Transmute);
StorageLive(_14);
_14 = copy _11 as *mut T (Transmute);
StorageLive(_15);
_15 = copy _13 as *mut T (Transmute);
_16 = Eq(copy _14, copy _15);
StorageDead(_15);
StorageDead(_14);
switchInt(move _16) -> [0: bb6, otherwise: bb7];
}
bb6: {
StorageDead(_19);
StorageLive(_22);
StorageLive(_21);
StorageLive(_20);
_20 = copy _14 as *const T (Transmute);
_21 = Offset(copy _20, const 1_usize);
StorageDead(_20);
_22 = NonNull::<T> { pointer: copy _21 };
StorageDead(_21);
_11 = move _22;
StorageDead(_22);
StorageDead(_16);
StorageLive(_18);
StorageLive(_17);
_17 = copy _11 as *const T (Transmute);
_18 = Offset(copy _17, const 1_usize);
StorageDead(_17);
_6 = NonNull::<T> { pointer: copy _18 };
StorageDead(_18);
goto -> bb13;
}
bb7: {
StorageDead(_19);
StorageDead(_26);
StorageDead(_16);
StorageDead(_24);
StorageDead(_23);
StorageDead(_15);
StorageDead(_14);
StorageDead(_22);
StorageDead(_13);
StorageDead(_20);
StorageDead(_19);
StorageDead(_12);
StorageDead(_11);
goto -> bb10;
}
bb8: {
_23 = copy _15 as usize (Transmute);
switchInt(copy _23) -> [0: bb9, otherwise: bb12];
_19 = copy _12 as usize (Transmute);
switchInt(copy _19) -> [0: bb9, otherwise: bb12];
}
bb9: {
StorageDead(_26);
StorageDead(_16);
StorageDead(_24);
StorageDead(_23);
StorageDead(_15);
StorageDead(_14);
StorageDead(_22);
StorageDead(_13);
StorageDead(_20);
StorageDead(_19);
StorageDead(_12);
StorageDead(_11);
goto -> bb10;
}
bb10: {
StorageDead(_27);
StorageDead(_30);
StorageDead(_29);
StorageDead(_32);
StorageDead(_11);
StorageDead(_12);
StorageDead(_13);
StorageDead(_23);
StorageDead(_26);
StorageDead(_25);
StorageDead(_28);
StorageDead(_10);
drop(_2) -> [return: bb11, unwind unreachable];
}
@ -265,51 +249,51 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
}
bb12: {
_24 = SubUnchecked(copy _23, const 1_usize);
_12 = copy _24 as *const T (Transmute);
_20 = SubUnchecked(copy _19, const 1_usize);
_9 = copy _20 as *const T (Transmute);
goto -> bb13;
}
bb13: {
StorageLive(_25);
_25 = copy _14 as *const T (Transmute);
_26 = &(*_25);
StorageDead(_25);
_27 = Option::<&T>::Some(copy _26);
StorageDead(_26);
StorageDead(_16);
StorageDead(_24);
StorageLive(_21);
_21 = copy _11 as *const T (Transmute);
_22 = &(*_21);
StorageDead(_21);
_23 = Option::<&T>::Some(copy _22);
StorageDead(_22);
StorageDead(_13);
StorageDead(_20);
StorageDead(_19);
StorageDead(_12);
StorageDead(_11);
_24 = copy ((_23 as Some).0: &T);
StorageDead(_23);
StorageDead(_15);
StorageDead(_14);
_28 = copy ((_27 as Some).0: &T);
StorageDead(_27);
_29 = copy _13;
_30 = AddWithOverflow(copy _13, const 1_usize);
assert(!move (_30.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _13, const 1_usize) -> [success: bb14, unwind unreachable];
_25 = copy _10;
_26 = AddWithOverflow(copy _10, const 1_usize);
assert(!move (_26.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _10, const 1_usize) -> [success: bb14, unwind unreachable];
}
bb14: {
_13 = move (_30.0: usize);
_10 = move (_26.0: usize);
StorageLive(_27);
_27 = (copy _25, copy _24);
_28 = Option::<(usize, &T)>::Some(move _27);
StorageDead(_27);
StorageDead(_26);
StorageDead(_25);
_29 = copy (((_28 as Some).0: (usize, &T)).0: usize);
_30 = copy (((_28 as Some).0: (usize, &T)).1: &T);
StorageLive(_31);
_31 = (copy _29, copy _28);
_32 = Option::<(usize, &T)>::Some(move _31);
StorageDead(_31);
StorageDead(_30);
StorageDead(_29);
_33 = copy (((_32 as Some).0: (usize, &T)).0: usize);
_34 = copy (((_32 as Some).0: (usize, &T)).1: &T);
StorageLive(_35);
_35 = &_2;
StorageLive(_36);
_36 = (copy _33, copy _34);
_37 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _35, move _36) -> [return: bb15, unwind unreachable];
_31 = &_2;
StorageLive(_32);
_32 = (copy _29, copy _30);
_33 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _31, move _32) -> [return: bb15, unwind unreachable];
}
bb15: {
StorageDead(_36);
StorageDead(_35);
StorageDead(_32);
StorageDead(_31);
StorageDead(_28);
goto -> bb4;
}
}

View file

@ -4,22 +4,22 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
debug slice => _1;
debug f => _2;
let mut _0: ();
let mut _11: std::slice::Iter<'_, T>;
let mut _10: std::slice::Iter<'_, T>;
let mut _11: std::iter::Enumerate<std::slice::Iter<'_, T>>;
let mut _12: std::iter::Enumerate<std::slice::Iter<'_, T>>;
let mut _13: std::iter::Enumerate<std::slice::Iter<'_, T>>;
let mut _14: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>;
let mut _15: std::option::Option<(usize, &T)>;
let mut _16: isize;
let mut _19: &impl Fn(usize, &T);
let mut _20: (usize, &T);
let _21: ();
let mut _13: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>;
let mut _14: std::option::Option<(usize, &T)>;
let mut _15: isize;
let mut _18: &impl Fn(usize, &T);
let mut _19: (usize, &T);
let _20: ();
scope 1 {
debug iter => _13;
let _17: usize;
let _18: &T;
debug iter => _12;
let _16: usize;
let _17: &T;
scope 2 {
debug i => _17;
debug x => _18;
debug i => _16;
debug x => _17;
}
}
scope 3 (inlined core::slice::<impl [T]>::iter) {
@ -27,7 +27,6 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
let _3: usize;
let mut _7: *mut T;
let mut _8: *mut T;
let mut _10: *const T;
scope 5 {
let _6: std::ptr::NonNull<T>;
scope 6 {
@ -62,9 +61,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
}
bb0: {
StorageLive(_11);
StorageLive(_10);
StorageLive(_3);
StorageLive(_6);
StorageLive(_9);
StorageLive(_4);
_3 = PtrMetadata(copy _1);
_4 = &raw const (*_1);
@ -72,7 +72,6 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
_5 = copy _4 as *const T (PtrToPtr);
_6 = NonNull::<T> { pointer: copy _5 };
StorageDead(_5);
StorageLive(_9);
switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb1, otherwise: bb2];
}
@ -93,33 +92,30 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
}
bb3: {
StorageLive(_10);
_10 = copy _9;
_11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: copy _10, _marker: const ZeroSized: PhantomData<&T> };
StorageDead(_10);
StorageDead(_9);
_10 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: copy _9, _marker: const ZeroSized: PhantomData<&T> };
StorageDead(_4);
StorageDead(_9);
StorageDead(_6);
StorageDead(_3);
_12 = Enumerate::<std::slice::Iter<'_, T>> { iter: copy _11, count: const 0_usize };
StorageDead(_11);
StorageLive(_13);
_13 = copy _12;
_11 = Enumerate::<std::slice::Iter<'_, T>> { iter: copy _10, count: const 0_usize };
StorageDead(_10);
StorageLive(_12);
_12 = copy _11;
goto -> bb4;
}
bb4: {
_14 = &mut _13;
_15 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _14) -> [return: bb5, unwind: bb11];
_13 = &mut _12;
_14 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _13) -> [return: bb5, unwind: bb11];
}
bb5: {
_16 = discriminant(_15);
switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb10];
_15 = discriminant(_14);
switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10];
}
bb6: {
StorageDead(_13);
StorageDead(_12);
drop(_2) -> [return: bb7, unwind continue];
}
@ -128,18 +124,18 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
}
bb8: {
_17 = copy (((_15 as Some).0: (usize, &T)).0: usize);
_18 = copy (((_15 as Some).0: (usize, &T)).1: &T);
_16 = copy (((_14 as Some).0: (usize, &T)).0: usize);
_17 = copy (((_14 as Some).0: (usize, &T)).1: &T);
StorageLive(_18);
_18 = &_2;
StorageLive(_19);
_19 = &_2;
StorageLive(_20);
_20 = copy ((_15 as Some).0: (usize, &T));
_21 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _19, move _20) -> [return: bb9, unwind: bb11];
_19 = copy ((_14 as Some).0: (usize, &T));
_20 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _18, move _19) -> [return: bb9, unwind: bb11];
}
bb9: {
StorageDead(_20);
StorageDead(_19);
StorageDead(_18);
goto -> bb4;
}

View file

@ -4,31 +4,29 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
debug slice => _1;
debug f => _2;
let mut _0: ();
let mut _11: std::ptr::NonNull<T>;
let mut _12: *const T;
let mut _26: std::option::Option<&T>;
let mut _28: &impl Fn(&T);
let mut _29: (&T,);
let _30: ();
let mut _22: std::option::Option<&T>;
let mut _24: &impl Fn(&T);
let mut _25: (&T,);
let _26: ();
scope 1 {
debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _11;
debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _12;
debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _6;
debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _9;
debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>;
let _27: &T;
let _23: &T;
scope 2 {
debug x => _27;
debug x => _23;
}
scope 16 (inlined <std::slice::Iter<'_, T> as Iterator>::next) {
let _13: std::ptr::NonNull<T>;
let _15: std::ptr::NonNull<T>;
let mut _18: bool;
let mut _21: std::ptr::NonNull<T>;
let mut _23: usize;
let _25: &T;
let mut _6: std::ptr::NonNull<T>;
let _10: std::ptr::NonNull<T>;
let _12: std::ptr::NonNull<T>;
let mut _15: bool;
let mut _19: usize;
let _21: &T;
scope 17 {
let _14: *const T;
let _11: *const T;
scope 18 {
let _22: usize;
let _18: usize;
scope 19 {
scope 22 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) {
scope 23 (inlined core::ub_checks::check_language_ub) {
@ -44,21 +42,21 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
}
scope 26 (inlined <NonNull<T> as PartialEq>::eq) {
let mut _16: *mut T;
let mut _17: *mut T;
let mut _13: *mut T;
let mut _14: *mut T;
scope 27 (inlined NonNull::<T>::as_ptr) {
}
scope 28 (inlined NonNull::<T>::as_ptr) {
}
}
scope 29 (inlined NonNull::<T>::add) {
let mut _19: *const T;
let mut _20: *const T;
let mut _16: *const T;
let mut _17: *const T;
scope 30 (inlined NonNull::<T>::as_ptr) {
}
}
scope 31 (inlined NonNull::<T>::as_ref::<'_>) {
let _24: *const T;
let _20: *const T;
scope 32 (inlined NonNull::<T>::as_ptr) {
}
scope 33 (inlined std::ptr::mut_ptr::<impl *mut T>::cast_const) {
@ -73,9 +71,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
let _3: usize;
let mut _7: *mut T;
let mut _8: *mut T;
let mut _10: *const T;
scope 5 {
let _6: std::ptr::NonNull<T>;
scope 6 {
let _9: *const T;
scope 7 {
@ -112,7 +108,6 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
_5 = copy _4 as *const T (PtrToPtr);
_6 = NonNull::<T> { pointer: copy _5 };
StorageDead(_5);
StorageLive(_9);
switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb1, otherwise: bb2];
}
@ -133,88 +128,77 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
bb3: {
_10 = copy _9;
StorageDead(_9);
StorageDead(_4);
StorageDead(_3);
StorageLive(_11);
StorageLive(_12);
_11 = copy _6;
_12 = copy _10;
goto -> bb4;
}
bb4: {
StorageLive(_26);
StorageLive(_13);
StorageLive(_14);
StorageLive(_22);
StorageLive(_23);
StorageLive(_15);
StorageLive(_25);
_13 = copy _11;
_14 = copy _12;
StorageLive(_10);
StorageLive(_11);
StorageLive(_18);
StorageLive(_19);
StorageLive(_12);
StorageLive(_21);
_10 = copy _6;
_11 = copy _9;
switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb5, otherwise: bb8];
}
bb5: {
StorageLive(_18);
_15 = copy _14 as std::ptr::NonNull<T> (Transmute);
StorageLive(_16);
_16 = copy _13 as *mut T (Transmute);
StorageLive(_17);
_17 = copy _15 as *mut T (Transmute);
_18 = Eq(copy _16, copy _17);
StorageDead(_17);
StorageDead(_16);
switchInt(move _18) -> [0: bb6, otherwise: bb7];
StorageLive(_15);
_12 = copy _11 as std::ptr::NonNull<T> (Transmute);
StorageLive(_13);
_13 = copy _10 as *mut T (Transmute);
StorageLive(_14);
_14 = copy _12 as *mut T (Transmute);
_15 = Eq(copy _13, copy _14);
StorageDead(_14);
StorageDead(_13);
switchInt(move _15) -> [0: bb6, otherwise: bb7];
}
bb6: {
StorageDead(_18);
StorageLive(_21);
StorageLive(_20);
StorageLive(_19);
_19 = copy _13 as *const T (Transmute);
_20 = Offset(copy _19, const 1_usize);
StorageDead(_19);
_21 = NonNull::<T> { pointer: copy _20 };
StorageDead(_20);
_11 = move _21;
StorageDead(_21);
StorageDead(_15);
StorageLive(_17);
StorageLive(_16);
_16 = copy _10 as *const T (Transmute);
_17 = Offset(copy _16, const 1_usize);
StorageDead(_16);
_6 = NonNull::<T> { pointer: copy _17 };
StorageDead(_17);
goto -> bb13;
}
bb7: {
StorageDead(_18);
StorageDead(_25);
StorageDead(_15);
StorageDead(_23);
StorageDead(_22);
StorageDead(_14);
StorageDead(_13);
StorageDead(_21);
StorageDead(_12);
StorageDead(_19);
StorageDead(_18);
StorageDead(_11);
StorageDead(_10);
goto -> bb10;
}
bb8: {
_22 = copy _14 as usize (Transmute);
switchInt(copy _22) -> [0: bb9, otherwise: bb12];
_18 = copy _11 as usize (Transmute);
switchInt(copy _18) -> [0: bb9, otherwise: bb12];
}
bb9: {
StorageDead(_25);
StorageDead(_15);
StorageDead(_23);
StorageDead(_22);
StorageDead(_14);
StorageDead(_13);
StorageDead(_21);
StorageDead(_12);
StorageDead(_19);
StorageDead(_18);
StorageDead(_11);
StorageDead(_10);
goto -> bb10;
}
bb10: {
StorageDead(_26);
StorageDead(_11);
StorageDead(_12);
StorageDead(_22);
drop(_2) -> [return: bb11, unwind unreachable];
}
@ -223,35 +207,35 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
bb12: {
_23 = SubUnchecked(copy _22, const 1_usize);
_12 = copy _23 as *const T (Transmute);
_19 = SubUnchecked(copy _18, const 1_usize);
_9 = copy _19 as *const T (Transmute);
goto -> bb13;
}
bb13: {
StorageLive(_20);
_20 = copy _10 as *const T (Transmute);
_21 = &(*_20);
StorageDead(_20);
_22 = Option::<&T>::Some(copy _21);
StorageDead(_21);
StorageDead(_12);
StorageDead(_19);
StorageDead(_18);
StorageDead(_11);
StorageDead(_10);
_23 = copy ((_22 as Some).0: &T);
StorageLive(_24);
_24 = copy _13 as *const T (Transmute);
_25 = &(*_24);
StorageDead(_24);
_26 = Option::<&T>::Some(copy _25);
StorageDead(_25);
StorageDead(_15);
StorageDead(_23);
StorageDead(_22);
StorageDead(_14);
StorageDead(_13);
_27 = copy ((_26 as Some).0: &T);
StorageLive(_28);
_28 = &_2;
StorageLive(_29);
_29 = (copy _27,);
_30 = <impl Fn(&T) as Fn<(&T,)>>::call(move _28, move _29) -> [return: bb14, unwind unreachable];
_24 = &_2;
StorageLive(_25);
_25 = (copy _23,);
_26 = <impl Fn(&T) as Fn<(&T,)>>::call(move _24, move _25) -> [return: bb14, unwind unreachable];
}
bb14: {
StorageDead(_29);
StorageDead(_28);
StorageDead(_26);
StorageDead(_25);
StorageDead(_24);
StorageDead(_22);
goto -> bb4;
}
}

View file

@ -4,31 +4,29 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
debug slice => _1;
debug f => _2;
let mut _0: ();
let mut _11: std::ptr::NonNull<T>;
let mut _12: *const T;
let mut _26: std::option::Option<&T>;
let mut _28: &impl Fn(&T);
let mut _29: (&T,);
let _30: ();
let mut _22: std::option::Option<&T>;
let mut _24: &impl Fn(&T);
let mut _25: (&T,);
let _26: ();
scope 1 {
debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _11;
debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _12;
debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _6;
debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _9;
debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>;
let _27: &T;
let _23: &T;
scope 2 {
debug x => _27;
debug x => _23;
}
scope 16 (inlined <std::slice::Iter<'_, T> as Iterator>::next) {
let _13: std::ptr::NonNull<T>;
let _15: std::ptr::NonNull<T>;
let mut _18: bool;
let mut _21: std::ptr::NonNull<T>;
let mut _23: usize;
let _25: &T;
let mut _6: std::ptr::NonNull<T>;
let _10: std::ptr::NonNull<T>;
let _12: std::ptr::NonNull<T>;
let mut _15: bool;
let mut _19: usize;
let _21: &T;
scope 17 {
let _14: *const T;
let _11: *const T;
scope 18 {
let _22: usize;
let _18: usize;
scope 19 {
scope 22 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) {
scope 23 (inlined core::ub_checks::check_language_ub) {
@ -44,21 +42,21 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
}
scope 26 (inlined <NonNull<T> as PartialEq>::eq) {
let mut _16: *mut T;
let mut _17: *mut T;
let mut _13: *mut T;
let mut _14: *mut T;
scope 27 (inlined NonNull::<T>::as_ptr) {
}
scope 28 (inlined NonNull::<T>::as_ptr) {
}
}
scope 29 (inlined NonNull::<T>::add) {
let mut _19: *const T;
let mut _20: *const T;
let mut _16: *const T;
let mut _17: *const T;
scope 30 (inlined NonNull::<T>::as_ptr) {
}
}
scope 31 (inlined NonNull::<T>::as_ref::<'_>) {
let _24: *const T;
let _20: *const T;
scope 32 (inlined NonNull::<T>::as_ptr) {
}
scope 33 (inlined std::ptr::mut_ptr::<impl *mut T>::cast_const) {
@ -73,9 +71,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
let _3: usize;
let mut _7: *mut T;
let mut _8: *mut T;
let mut _10: *const T;
scope 5 {
let _6: std::ptr::NonNull<T>;
scope 6 {
let _9: *const T;
scope 7 {
@ -112,7 +108,6 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
_5 = copy _4 as *const T (PtrToPtr);
_6 = NonNull::<T> { pointer: copy _5 };
StorageDead(_5);
StorageLive(_9);
switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb1, otherwise: bb2];
}
@ -133,88 +128,77 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
bb3: {
_10 = copy _9;
StorageDead(_9);
StorageDead(_4);
StorageDead(_3);
StorageLive(_11);
StorageLive(_12);
_11 = copy _6;
_12 = copy _10;
goto -> bb4;
}
bb4: {
StorageLive(_26);
StorageLive(_13);
StorageLive(_14);
StorageLive(_22);
StorageLive(_23);
StorageLive(_15);
StorageLive(_25);
_13 = copy _11;
_14 = copy _12;
StorageLive(_10);
StorageLive(_11);
StorageLive(_18);
StorageLive(_19);
StorageLive(_12);
StorageLive(_21);
_10 = copy _6;
_11 = copy _9;
switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb5, otherwise: bb8];
}
bb5: {
StorageLive(_18);
_15 = copy _14 as std::ptr::NonNull<T> (Transmute);
StorageLive(_16);
_16 = copy _13 as *mut T (Transmute);
StorageLive(_17);
_17 = copy _15 as *mut T (Transmute);
_18 = Eq(copy _16, copy _17);
StorageDead(_17);
StorageDead(_16);
switchInt(move _18) -> [0: bb6, otherwise: bb7];
StorageLive(_15);
_12 = copy _11 as std::ptr::NonNull<T> (Transmute);
StorageLive(_13);
_13 = copy _10 as *mut T (Transmute);
StorageLive(_14);
_14 = copy _12 as *mut T (Transmute);
_15 = Eq(copy _13, copy _14);
StorageDead(_14);
StorageDead(_13);
switchInt(move _15) -> [0: bb6, otherwise: bb7];
}
bb6: {
StorageDead(_18);
StorageLive(_21);
StorageLive(_20);
StorageLive(_19);
_19 = copy _13 as *const T (Transmute);
_20 = Offset(copy _19, const 1_usize);
StorageDead(_19);
_21 = NonNull::<T> { pointer: copy _20 };
StorageDead(_20);
_11 = move _21;
StorageDead(_21);
StorageDead(_15);
StorageLive(_17);
StorageLive(_16);
_16 = copy _10 as *const T (Transmute);
_17 = Offset(copy _16, const 1_usize);
StorageDead(_16);
_6 = NonNull::<T> { pointer: copy _17 };
StorageDead(_17);
goto -> bb13;
}
bb7: {
StorageDead(_18);
StorageDead(_25);
StorageDead(_15);
StorageDead(_23);
StorageDead(_22);
StorageDead(_14);
StorageDead(_13);
StorageDead(_21);
StorageDead(_12);
StorageDead(_19);
StorageDead(_18);
StorageDead(_11);
StorageDead(_10);
goto -> bb10;
}
bb8: {
_22 = copy _14 as usize (Transmute);
switchInt(copy _22) -> [0: bb9, otherwise: bb12];
_18 = copy _11 as usize (Transmute);
switchInt(copy _18) -> [0: bb9, otherwise: bb12];
}
bb9: {
StorageDead(_25);
StorageDead(_15);
StorageDead(_23);
StorageDead(_22);
StorageDead(_14);
StorageDead(_13);
StorageDead(_21);
StorageDead(_12);
StorageDead(_19);
StorageDead(_18);
StorageDead(_11);
StorageDead(_10);
goto -> bb10;
}
bb10: {
StorageDead(_26);
StorageDead(_11);
StorageDead(_12);
StorageDead(_22);
drop(_2) -> [return: bb11, unwind continue];
}
@ -223,35 +207,35 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
bb12: {
_23 = SubUnchecked(copy _22, const 1_usize);
_12 = copy _23 as *const T (Transmute);
_19 = SubUnchecked(copy _18, const 1_usize);
_9 = copy _19 as *const T (Transmute);
goto -> bb13;
}
bb13: {
StorageLive(_20);
_20 = copy _10 as *const T (Transmute);
_21 = &(*_20);
StorageDead(_20);
_22 = Option::<&T>::Some(copy _21);
StorageDead(_21);
StorageDead(_12);
StorageDead(_19);
StorageDead(_18);
StorageDead(_11);
StorageDead(_10);
_23 = copy ((_22 as Some).0: &T);
StorageLive(_24);
_24 = copy _13 as *const T (Transmute);
_25 = &(*_24);
StorageDead(_24);
_26 = Option::<&T>::Some(copy _25);
StorageDead(_25);
StorageDead(_15);
StorageDead(_23);
StorageDead(_22);
StorageDead(_14);
StorageDead(_13);
_27 = copy ((_26 as Some).0: &T);
StorageLive(_28);
_28 = &_2;
StorageLive(_29);
_29 = (copy _27,);
_30 = <impl Fn(&T) as Fn<(&T,)>>::call(move _28, move _29) -> [return: bb14, unwind: bb15];
_24 = &_2;
StorageLive(_25);
_25 = (copy _23,);
_26 = <impl Fn(&T) as Fn<(&T,)>>::call(move _24, move _25) -> [return: bb14, unwind: bb15];
}
bb14: {
StorageDead(_29);
StorageDead(_28);
StorageDead(_26);
StorageDead(_25);
StorageDead(_24);
StorageDead(_22);
goto -> bb4;
}

View file

@ -5,28 +5,27 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
debug f => _2;
let mut _0: ();
let mut _3: usize;
let mut _4: usize;
let mut _9: std::option::Option<usize>;
let mut _11: bool;
let mut _13: &impl Fn(usize, &T);
let mut _14: (usize, &T);
let _15: ();
let mut _8: std::option::Option<usize>;
let mut _10: bool;
let mut _12: &impl Fn(usize, &T);
let mut _13: (usize, &T);
let _14: ();
scope 1 {
debug ((iter: std::ops::Range<usize>).0: usize) => _4;
debug ((iter: std::ops::Range<usize>).1: usize) => _3;
let _10: usize;
let _9: usize;
scope 2 {
debug i => _10;
let _12: &T;
debug i => _9;
let _11: &T;
scope 3 {
debug x => _12;
debug x => _11;
}
}
scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) {
let mut _4: usize;
let mut _6: bool;
let _7: usize;
let mut _8: usize;
scope 7 {
scope 9 (inlined <usize as Step>::forward_unchecked) {
scope 10 (inlined #[track_caller] core::num::<impl usize>::unchecked_add) {
@ -48,13 +47,12 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
bb0: {
_3 = PtrMetadata(copy _1);
StorageLive(_4);
_4 = const 0_usize;
goto -> bb1;
}
bb1: {
StorageLive(_9);
StorageLive(_8);
StorageLive(_6);
StorageLive(_5);
_5 = copy _4;
@ -65,8 +63,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
bb2: {
StorageDead(_6);
StorageDead(_9);
StorageDead(_4);
StorageDead(_8);
drop(_2) -> [return: bb3, unwind unreachable];
}
@ -76,30 +73,27 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
bb4: {
_7 = copy _4;
StorageLive(_8);
_8 = AddUnchecked(copy _7, const 1_usize);
_4 = move _8;
StorageDead(_8);
_9 = Option::<usize>::Some(copy _7);
_4 = AddUnchecked(copy _7, const 1_usize);
_8 = Option::<usize>::Some(copy _7);
StorageDead(_6);
_10 = copy ((_9 as Some).0: usize);
_11 = Lt(copy _10, copy _3);
assert(move _11, "index out of bounds: the length is {} but the index is {}", copy _3, copy _10) -> [success: bb5, unwind unreachable];
_9 = copy ((_8 as Some).0: usize);
_10 = Lt(copy _9, copy _3);
assert(move _10, "index out of bounds: the length is {} but the index is {}", copy _3, copy _9) -> [success: bb5, unwind unreachable];
}
bb5: {
_12 = &(*_1)[_10];
_11 = &(*_1)[_9];
StorageLive(_12);
_12 = &_2;
StorageLive(_13);
_13 = &_2;
StorageLive(_14);
_14 = (copy _10, copy _12);
_15 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _13, move _14) -> [return: bb6, unwind unreachable];
_13 = (copy _9, copy _11);
_14 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _12, move _13) -> [return: bb6, unwind unreachable];
}
bb6: {
StorageDead(_14);
StorageDead(_13);
StorageDead(_9);
StorageDead(_12);
StorageDead(_8);
goto -> bb1;
}
}

View file

@ -5,28 +5,27 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
debug f => _2;
let mut _0: ();
let mut _3: usize;
let mut _4: usize;
let mut _9: std::option::Option<usize>;
let mut _11: bool;
let mut _13: &impl Fn(usize, &T);
let mut _14: (usize, &T);
let _15: ();
let mut _8: std::option::Option<usize>;
let mut _10: bool;
let mut _12: &impl Fn(usize, &T);
let mut _13: (usize, &T);
let _14: ();
scope 1 {
debug ((iter: std::ops::Range<usize>).0: usize) => _4;
debug ((iter: std::ops::Range<usize>).1: usize) => _3;
let _10: usize;
let _9: usize;
scope 2 {
debug i => _10;
let _12: &T;
debug i => _9;
let _11: &T;
scope 3 {
debug x => _12;
debug x => _11;
}
}
scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) {
let mut _4: usize;
let mut _6: bool;
let _7: usize;
let mut _8: usize;
scope 7 {
scope 9 (inlined <usize as Step>::forward_unchecked) {
scope 10 (inlined #[track_caller] core::num::<impl usize>::unchecked_add) {
@ -48,13 +47,12 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
bb0: {
_3 = PtrMetadata(copy _1);
StorageLive(_4);
_4 = const 0_usize;
goto -> bb1;
}
bb1: {
StorageLive(_9);
StorageLive(_8);
StorageLive(_6);
StorageLive(_5);
_5 = copy _4;
@ -65,8 +63,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
bb2: {
StorageDead(_6);
StorageDead(_9);
StorageDead(_4);
StorageDead(_8);
drop(_2) -> [return: bb3, unwind continue];
}
@ -76,30 +73,27 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
bb4: {
_7 = copy _4;
StorageLive(_8);
_8 = AddUnchecked(copy _7, const 1_usize);
_4 = move _8;
StorageDead(_8);
_9 = Option::<usize>::Some(copy _7);
_4 = AddUnchecked(copy _7, const 1_usize);
_8 = Option::<usize>::Some(copy _7);
StorageDead(_6);
_10 = copy ((_9 as Some).0: usize);
_11 = Lt(copy _10, copy _3);
assert(move _11, "index out of bounds: the length is {} but the index is {}", copy _3, copy _10) -> [success: bb5, unwind: bb7];
_9 = copy ((_8 as Some).0: usize);
_10 = Lt(copy _9, copy _3);
assert(move _10, "index out of bounds: the length is {} but the index is {}", copy _3, copy _9) -> [success: bb5, unwind: bb7];
}
bb5: {
_12 = &(*_1)[_10];
_11 = &(*_1)[_9];
StorageLive(_12);
_12 = &_2;
StorageLive(_13);
_13 = &_2;
StorageLive(_14);
_14 = (copy _10, copy _12);
_15 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _13, move _14) -> [return: bb6, unwind: bb7];
_13 = (copy _9, copy _11);
_14 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _12, move _13) -> [return: bb6, unwind: bb7];
}
bb6: {
StorageDead(_14);
StorageDead(_13);
StorageDead(_9);
StorageDead(_12);
StorageDead(_8);
goto -> bb1;
}

View file

@ -4,22 +4,22 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
debug slice => _1;
debug f => _2;
let mut _0: ();
let mut _11: std::slice::Iter<'_, T>;
let mut _10: std::slice::Iter<'_, T>;
let mut _11: std::iter::Rev<std::slice::Iter<'_, T>>;
let mut _12: std::iter::Rev<std::slice::Iter<'_, T>>;
let mut _13: std::iter::Rev<std::slice::Iter<'_, T>>;
let mut _15: std::option::Option<&T>;
let mut _16: isize;
let mut _18: &impl Fn(&T);
let mut _19: (&T,);
let _20: ();
let mut _14: std::option::Option<&T>;
let mut _15: isize;
let mut _17: &impl Fn(&T);
let mut _18: (&T,);
let _19: ();
scope 1 {
debug iter => _13;
let _17: &T;
debug iter => _12;
let _16: &T;
scope 2 {
debug x => _17;
debug x => _16;
}
scope 18 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) {
let mut _14: &mut std::slice::Iter<'_, T>;
let mut _13: &mut std::slice::Iter<'_, T>;
}
}
scope 3 (inlined core::slice::<impl [T]>::iter) {
@ -27,7 +27,6 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
let _3: usize;
let mut _7: *mut T;
let mut _8: *mut T;
let mut _10: *const T;
scope 5 {
let _6: std::ptr::NonNull<T>;
scope 6 {
@ -62,9 +61,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
bb0: {
StorageLive(_11);
StorageLive(_10);
StorageLive(_3);
StorageLive(_6);
StorageLive(_9);
StorageLive(_4);
_3 = PtrMetadata(copy _1);
_4 = &raw const (*_1);
@ -72,7 +72,6 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
_5 = copy _4 as *const T (PtrToPtr);
_6 = NonNull::<T> { pointer: copy _5 };
StorageDead(_5);
StorageLive(_9);
switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb1, otherwise: bb2];
}
@ -93,37 +92,34 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
bb3: {
StorageLive(_10);
_10 = copy _9;
_11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: copy _10, _marker: const ZeroSized: PhantomData<&T> };
StorageDead(_10);
StorageDead(_9);
_10 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: copy _9, _marker: const ZeroSized: PhantomData<&T> };
StorageDead(_4);
StorageDead(_9);
StorageDead(_6);
StorageDead(_3);
_12 = Rev::<std::slice::Iter<'_, T>> { iter: copy _11 };
StorageDead(_11);
StorageLive(_13);
_13 = copy _12;
_11 = Rev::<std::slice::Iter<'_, T>> { iter: copy _10 };
StorageDead(_10);
StorageLive(_12);
_12 = copy _11;
goto -> bb4;
}
bb4: {
StorageLive(_15);
StorageLive(_14);
_14 = &mut (_13.0: std::slice::Iter<'_, T>);
_15 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _14) -> [return: bb5, unwind unreachable];
StorageLive(_13);
_13 = &mut (_12.0: std::slice::Iter<'_, T>);
_14 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _13) -> [return: bb5, unwind unreachable];
}
bb5: {
StorageDead(_14);
_16 = discriminant(_15);
switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb10];
StorageDead(_13);
_15 = discriminant(_14);
switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10];
}
bb6: {
StorageDead(_15);
StorageDead(_13);
StorageDead(_14);
StorageDead(_12);
drop(_2) -> [return: bb7, unwind unreachable];
}
@ -132,18 +128,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
bb8: {
_17 = copy ((_15 as Some).0: &T);
_16 = copy ((_14 as Some).0: &T);
StorageLive(_17);
_17 = &_2;
StorageLive(_18);
_18 = &_2;
StorageLive(_19);
_19 = (copy _17,);
_20 = <impl Fn(&T) as Fn<(&T,)>>::call(move _18, move _19) -> [return: bb9, unwind unreachable];
_18 = (copy _16,);
_19 = <impl Fn(&T) as Fn<(&T,)>>::call(move _17, move _18) -> [return: bb9, unwind unreachable];
}
bb9: {
StorageDead(_19);
StorageDead(_18);
StorageDead(_15);
StorageDead(_17);
StorageDead(_14);
goto -> bb4;
}

View file

@ -4,22 +4,22 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
debug slice => _1;
debug f => _2;
let mut _0: ();
let mut _11: std::slice::Iter<'_, T>;
let mut _10: std::slice::Iter<'_, T>;
let mut _11: std::iter::Rev<std::slice::Iter<'_, T>>;
let mut _12: std::iter::Rev<std::slice::Iter<'_, T>>;
let mut _13: std::iter::Rev<std::slice::Iter<'_, T>>;
let mut _15: std::option::Option<&T>;
let mut _16: isize;
let mut _18: &impl Fn(&T);
let mut _19: (&T,);
let _20: ();
let mut _14: std::option::Option<&T>;
let mut _15: isize;
let mut _17: &impl Fn(&T);
let mut _18: (&T,);
let _19: ();
scope 1 {
debug iter => _13;
let _17: &T;
debug iter => _12;
let _16: &T;
scope 2 {
debug x => _17;
debug x => _16;
}
scope 18 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) {
let mut _14: &mut std::slice::Iter<'_, T>;
let mut _13: &mut std::slice::Iter<'_, T>;
}
}
scope 3 (inlined core::slice::<impl [T]>::iter) {
@ -27,7 +27,6 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
let _3: usize;
let mut _7: *mut T;
let mut _8: *mut T;
let mut _10: *const T;
scope 5 {
let _6: std::ptr::NonNull<T>;
scope 6 {
@ -62,9 +61,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
bb0: {
StorageLive(_11);
StorageLive(_10);
StorageLive(_3);
StorageLive(_6);
StorageLive(_9);
StorageLive(_4);
_3 = PtrMetadata(copy _1);
_4 = &raw const (*_1);
@ -72,7 +72,6 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
_5 = copy _4 as *const T (PtrToPtr);
_6 = NonNull::<T> { pointer: copy _5 };
StorageDead(_5);
StorageLive(_9);
switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb1, otherwise: bb2];
}
@ -93,37 +92,34 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
bb3: {
StorageLive(_10);
_10 = copy _9;
_11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: copy _10, _marker: const ZeroSized: PhantomData<&T> };
StorageDead(_10);
StorageDead(_9);
_10 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: copy _9, _marker: const ZeroSized: PhantomData<&T> };
StorageDead(_4);
StorageDead(_9);
StorageDead(_6);
StorageDead(_3);
_12 = Rev::<std::slice::Iter<'_, T>> { iter: copy _11 };
StorageDead(_11);
StorageLive(_13);
_13 = copy _12;
_11 = Rev::<std::slice::Iter<'_, T>> { iter: copy _10 };
StorageDead(_10);
StorageLive(_12);
_12 = copy _11;
goto -> bb4;
}
bb4: {
StorageLive(_15);
StorageLive(_14);
_14 = &mut (_13.0: std::slice::Iter<'_, T>);
_15 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _14) -> [return: bb5, unwind: bb11];
StorageLive(_13);
_13 = &mut (_12.0: std::slice::Iter<'_, T>);
_14 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _13) -> [return: bb5, unwind: bb11];
}
bb5: {
StorageDead(_14);
_16 = discriminant(_15);
switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb10];
StorageDead(_13);
_15 = discriminant(_14);
switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10];
}
bb6: {
StorageDead(_15);
StorageDead(_13);
StorageDead(_14);
StorageDead(_12);
drop(_2) -> [return: bb7, unwind continue];
}
@ -132,18 +128,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
}
bb8: {
_17 = copy ((_15 as Some).0: &T);
_16 = copy ((_14 as Some).0: &T);
StorageLive(_17);
_17 = &_2;
StorageLive(_18);
_18 = &_2;
StorageLive(_19);
_19 = (copy _17,);
_20 = <impl Fn(&T) as Fn<(&T,)>>::call(move _18, move _19) -> [return: bb9, unwind: bb11];
_18 = (copy _16,);
_19 = <impl Fn(&T) as Fn<(&T,)>>::call(move _17, move _18) -> [return: bb9, unwind: bb11];
}
bb9: {
StorageDead(_19);
StorageDead(_18);
StorageDead(_15);
StorageDead(_17);
StorageDead(_14);
goto -> bb4;
}

View file

@ -7,7 +7,6 @@ fn demo_ge_partial(_1: &(f32, f32), _2: &(f32, f32)) -> bool {
scope 1 (inlined std::cmp::impls::<impl PartialOrd for &(f32, f32)>::ge) {
scope 2 (inlined core::tuple::<impl PartialOrd for (f32, f32)>::ge) {
let mut _7: std::ops::ControlFlow<bool>;
let _8: bool;
scope 3 {
}
scope 4 (inlined std::cmp::impls::<impl PartialOrd for f32>::__chaining_ge) {
@ -19,8 +18,8 @@ fn demo_ge_partial(_1: &(f32, f32), _2: &(f32, f32)) -> bool {
}
}
scope 6 (inlined std::cmp::impls::<impl PartialOrd for f32>::ge) {
let mut _8: f32;
let mut _9: f32;
let mut _10: f32;
}
}
}
@ -44,10 +43,7 @@ fn demo_ge_partial(_1: &(f32, f32), _2: &(f32, f32)) -> bool {
StorageDead(_5);
StorageDead(_4);
StorageDead(_3);
StorageLive(_8);
_8 = copy ((_7 as Break).0: bool);
_0 = copy _8;
StorageDead(_8);
_0 = copy ((_7 as Break).0: bool);
goto -> bb3;
}
@ -55,13 +51,13 @@ fn demo_ge_partial(_1: &(f32, f32), _2: &(f32, f32)) -> bool {
StorageDead(_5);
StorageDead(_4);
StorageDead(_3);
StorageLive(_8);
_8 = copy ((*_1).1: f32);
StorageLive(_9);
_9 = copy ((*_1).1: f32);
StorageLive(_10);
_10 = copy ((*_2).1: f32);
_0 = Ge(move _9, move _10);
StorageDead(_10);
_9 = copy ((*_2).1: f32);
_0 = Ge(move _8, move _9);
StorageDead(_9);
StorageDead(_8);
goto -> bb3;
}

View file

@ -7,7 +7,6 @@ fn demo_le_total(_1: &(u16, i16), _2: &(u16, i16)) -> bool {
scope 1 (inlined std::cmp::impls::<impl PartialOrd for &(u16, i16)>::le) {
scope 2 (inlined core::tuple::<impl PartialOrd for (u16, i16)>::le) {
let mut _7: std::ops::ControlFlow<bool>;
let _8: bool;
scope 3 {
}
scope 4 (inlined std::cmp::impls::<impl PartialOrd for u16>::__chaining_le) {
@ -19,8 +18,8 @@ fn demo_le_total(_1: &(u16, i16), _2: &(u16, i16)) -> bool {
}
}
scope 6 (inlined std::cmp::impls::<impl PartialOrd for i16>::le) {
let mut _8: i16;
let mut _9: i16;
let mut _10: i16;
}
}
}
@ -44,10 +43,7 @@ fn demo_le_total(_1: &(u16, i16), _2: &(u16, i16)) -> bool {
StorageDead(_5);
StorageDead(_4);
StorageDead(_3);
StorageLive(_8);
_8 = copy ((_7 as Break).0: bool);
_0 = copy _8;
StorageDead(_8);
_0 = copy ((_7 as Break).0: bool);
goto -> bb3;
}
@ -55,13 +51,13 @@ fn demo_le_total(_1: &(u16, i16), _2: &(u16, i16)) -> bool {
StorageDead(_5);
StorageDead(_4);
StorageDead(_3);
StorageLive(_8);
_8 = copy ((*_1).1: i16);
StorageLive(_9);
_9 = copy ((*_1).1: i16);
StorageLive(_10);
_10 = copy ((*_2).1: i16);
_0 = Le(move _9, move _10);
StorageDead(_10);
_9 = copy ((*_2).1: i16);
_0 = Le(move _8, move _9);
StorageDead(_9);
StorageDead(_8);
goto -> bb3;
}