Skip to content

Commit 4e45275

Browse files
committed
only preserving derefs for trivial terminators like SwitchInt and Goto
1 parent 3242cc2 commit 4e45275

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
@@ -1765,8 +1765,14 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> {
17651765
let opaque = self.new_opaque();
17661766
self.assign(local, opaque);
17671767
}
1768-
// Function calls maybe invalidate nested deref, and non-local assignments maybe invalidate deref.
1769-
// Currently, no distinction is made between these two cases.
1768+
}
1769+
// Function calls and ASM may invalidate (nested) derefs. We must handle them carefully.
1770+
// Currently, only preserving derefs for trivial terminators like SwitchInt and Goto.
1771+
let safe_to_preserve_derefs = matches!(
1772+
terminator.kind,
1773+
TerminatorKind::SwitchInt { .. } | TerminatorKind::Goto { .. }
1774+
);
1775+
if !safe_to_preserve_derefs {
17701776
self.invalidate_derefs();
17711777
}
17721778
self.super_terminator(terminator, location);

0 commit comments

Comments
 (0)