Do not unify dereferences in GVN.

This commit is contained in:
Camille GILLOT 2024-11-01 14:32:09 +00:00 committed by Ralf Jung
parent 2cc0ee65d9
commit 917dd82628
31 changed files with 351 additions and 389 deletions

View file

@ -638,7 +638,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
let proj = match proj {
ProjectionElem::Deref => {
let ty = place.ty(self.local_decls, self.tcx).ty;
if let Some(Mutability::Not) = ty.ref_mutability()
// unsound: https://github.com/rust-lang/rust/issues/130853
if self.tcx.sess.opts.unstable_opts.unsound_mir_opts
&& let Some(Mutability::Not) = ty.ref_mutability()
&& let Some(pointee_ty) = ty.builtin_deref(true)
&& pointee_ty.is_freeze(self.tcx, self.typing_env())
{