Do not intern GVN temps.
This commit is contained in:
parent
dbf9ea30dd
commit
8162dc2433
1 changed files with 16 additions and 22 deletions
|
@ -53,6 +53,7 @@
|
||||||
//! _c = *_b // replaced by _c = _a
|
//! _c = *_b // replaced by _c = _a
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
use rustc_const_eval::interpret::MemoryKind;
|
||||||
use rustc_const_eval::interpret::{ImmTy, InterpCx, MemPlaceMeta, OpTy, Projectable, Scalar};
|
use rustc_const_eval::interpret::{ImmTy, InterpCx, MemPlaceMeta, OpTy, Projectable, Scalar};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
|
||||||
use rustc_data_structures::graph::dominators::Dominators;
|
use rustc_data_structures::graph::dominators::Dominators;
|
||||||
|
@ -323,24 +324,19 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
|
||||||
if ty.is_zst() {
|
if ty.is_zst() {
|
||||||
ImmTy::uninit(ty).into()
|
ImmTy::uninit(ty).into()
|
||||||
} else if matches!(ty.abi, Abi::Scalar(..) | Abi::ScalarPair(..)) {
|
} else if matches!(ty.abi, Abi::Scalar(..) | Abi::ScalarPair(..)) {
|
||||||
let alloc_id = self
|
let dest = self.ecx.allocate(ty, MemoryKind::Stack).ok()?;
|
||||||
.ecx
|
|
||||||
.intern_with_temp_alloc(ty, |ecx, dest| {
|
|
||||||
let variant_dest = if let Some(variant) = variant {
|
let variant_dest = if let Some(variant) = variant {
|
||||||
ecx.project_downcast(dest, variant)?
|
self.ecx.project_downcast(&dest, variant).ok()?
|
||||||
} else {
|
} else {
|
||||||
dest.clone()
|
dest.clone()
|
||||||
};
|
};
|
||||||
for (field_index, op) in fields.into_iter().enumerate() {
|
for (field_index, op) in fields.into_iter().enumerate() {
|
||||||
let field_dest = ecx.project_field(&variant_dest, field_index)?;
|
let field_dest = self.ecx.project_field(&variant_dest, field_index).ok()?;
|
||||||
ecx.copy_op(op, &field_dest, /*allow_transmute*/ false)?;
|
self.ecx.copy_op(op, &field_dest, /*allow_transmute*/ false).ok()?;
|
||||||
}
|
}
|
||||||
ecx.write_discriminant(variant.unwrap_or(FIRST_VARIANT), dest)
|
self.ecx.write_discriminant(variant.unwrap_or(FIRST_VARIANT), &dest).ok()?;
|
||||||
})
|
self.ecx.alloc_mark_immutable(dest.ptr().provenance.unwrap()).ok()?;
|
||||||
.ok()?;
|
dest.into()
|
||||||
let mplace =
|
|
||||||
self.ecx.raw_const_to_mplace(ConstAlloc { alloc_id, ty: ty.ty }).ok()?;
|
|
||||||
mplace.into()
|
|
||||||
} else {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -846,10 +842,8 @@ fn op_to_prop_const<'tcx>(
|
||||||
{
|
{
|
||||||
let pointer = mplace.ptr().into_pointer_or_addr().ok()?;
|
let pointer = mplace.ptr().into_pointer_or_addr().ok()?;
|
||||||
let (alloc_id, offset) = pointer.into_parts();
|
let (alloc_id, offset) = pointer.into_parts();
|
||||||
return if matches!(ecx.tcx.global_alloc(alloc_id), GlobalAlloc::Memory(_)) {
|
if matches!(ecx.tcx.try_get_global_alloc(alloc_id), Some(GlobalAlloc::Memory(_))) {
|
||||||
Some(ConstValue::Indirect { alloc_id, offset })
|
return Some(ConstValue::Indirect { alloc_id, offset })
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue