Skip to content

Commit a7cb24f

Browse files
committed
only preserving derefs for trivial terminators like SwitchInt and Goto
1 parent fbe5924 commit a7cb24f

File tree

1 file changed

+8
-2
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+8
-2
lines changed

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,8 +1615,14 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> {
16151615
let opaque = self.new_opaque();
16161616
self.assign(local, opaque);
16171617
}
1618-
// Function calls maybe invalidate nested deref, and non-local assignments maybe invalidate deref.
1619-
// Currently, no distinction is made between these two cases.
1618+
}
1619+
// Function calls and ASM may invalidate (nested) derefs. We must handle them carefully.
1620+
// Currently, only preserving derefs for trivial terminators like SwitchInt and Goto.
1621+
let safe_to_preserve_derefs = matches!(
1622+
terminator.kind,
1623+
TerminatorKind::SwitchInt { .. } | TerminatorKind::Goto { .. }
1624+
);
1625+
if !safe_to_preserve_derefs {
16201626
self.invalidate_derefs();
16211627
}
16221628
self.super_terminator(terminator, location);

0 commit comments

Comments
 (0)