Rollup merge of #120688 - cjgillot:gvn-partial-move, r=oli-obk

GVN: also turn moves into copies with projections

Fixes https://github.com/rust-lang/rust/issues/120613
This commit is contained in:
Matthias Krüger 2024-02-08 09:06:34 +01:00 committed by GitHub
commit 65aa9eae73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 78 additions and 5 deletions

View file

@ -1231,8 +1231,8 @@ impl<'tcx> MutVisitor<'tcx> for StorageRemover<'tcx> {
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, _: Location) {
if let Operand::Move(place) = *operand
&& let Some(local) = place.as_local()
&& self.reused_locals.contains(local)
&& !place.is_indirect_first_projection()
&& self.reused_locals.contains(place.local)
{
*operand = Operand::Copy(place);
}