Do not convert copies of packed projections to moves.

This commit is contained in:
Camille GILLOT 2023-08-23 16:00:42 +00:00
parent fe5f591257
commit 1c5f1762b7
4 changed files with 60 additions and 0 deletions

View file

@ -12,6 +12,7 @@
//! will still not cause any further changes.
//!
use crate::util::is_disaligned;
use rustc_index::bit_set::BitSet;
use rustc_middle::mir::visit::Visitor;
use rustc_middle::mir::*;
@ -31,6 +32,8 @@ pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, borrowed: &BitS
.iterate_to_fixpoint()
.into_results_cursor(body);
let param_env = tcx.param_env_reveal_all_normalized(body.source.def_id());
// For blocks with a call terminator, if an argument copy can be turned into a move,
// record it as (block, argument index).
let mut call_operands_to_move = Vec::new();
@ -49,6 +52,7 @@ pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, borrowed: &BitS
&& !place.is_indirect()
&& !borrowed.contains(place.local)
&& !state.contains(place.local)
&& !is_disaligned(tcx, body, param_env, place)
{
call_operands_to_move.push((bb, index));
}