Skip to content

Commit 596de2b

Browse files
committed
only preserving derefs for trivial terminators like SwitchInt and Goto
1 parent 7c50aa0 commit 596de2b

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
@@ -1773,8 +1773,14 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> {
17731773
let opaque = self.new_opaque();
17741774
self.assign(local, opaque);
17751775
}
1776-
// Function calls maybe invalidate nested deref, and non-local assignments maybe invalidate deref.
1777-
// Currently, no distinction is made between these two cases.
1776+
}
1777+
// Function calls and ASM may invalidate (nested) derefs. We must handle them carefully.
1778+
// Currently, only preserving derefs for trivial terminators like SwitchInt and Goto.
1779+
let safe_to_preserve_derefs = matches!(
1780+
terminator.kind,
1781+
TerminatorKind::SwitchInt { .. } | TerminatorKind::Goto { .. }
1782+
);
1783+
if !safe_to_preserve_derefs {
17781784
self.invalidate_derefs();
17791785
}
17801786
self.super_terminator(terminator, location);

0 commit comments

Comments
 (0)