Skip to content

Commit

Permalink
only preserving derefs for trivial terminators like SwitchInt and Goto
Browse files Browse the repository at this point in the history
  • Loading branch information
DianQK committed Jan 24, 2025
1 parent 3242cc2 commit 4e45275
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions compiler/rustc_mir_transform/src/gvn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1765,8 +1765,14 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> {
let opaque = self.new_opaque();
self.assign(local, opaque);
}
// Function calls maybe invalidate nested deref, and non-local assignments maybe invalidate deref.
// Currently, no distinction is made between these two cases.
}
// Function calls and ASM may invalidate (nested) derefs. We must handle them carefully.
// Currently, only preserving derefs for trivial terminators like SwitchInt and Goto.
let safe_to_preserve_derefs = matches!(
terminator.kind,
TerminatorKind::SwitchInt { .. } | TerminatorKind::Goto { .. }
);
if !safe_to_preserve_derefs {
self.invalidate_derefs();
}
self.super_terminator(terminator, location);
Expand Down

0 comments on commit 4e45275

Please sign in to comment.