Do not intern too large aggregates.

This commit is contained in:
Camille GILLOT 2023-09-23 14:55:28 +00:00
parent 38c86b0798
commit db9bd9bd8c

View File

@ -291,6 +291,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
.collect::<Option<Vec<_>>>()?; .collect::<Option<Vec<_>>>()?;
let variant = if ty.is_enum() { Some(variant) } else { None }; let variant = if ty.is_enum() { Some(variant) } else { None };
let ty = self.ecx.layout_of(ty).ok()?; let ty = self.ecx.layout_of(ty).ok()?;
if ty.is_zst() {
ImmTy::uninit(ty).into()
} else if matches!(ty.abi, Abi::Scalar(..) | Abi::ScalarPair(..)) {
let alloc_id = self let alloc_id = self
.ecx .ecx
.intern_with_temp_alloc(ty, |ecx, dest| { .intern_with_temp_alloc(ty, |ecx, dest| {
@ -309,6 +312,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
let mplace = let mplace =
self.ecx.raw_const_to_mplace(ConstAlloc { alloc_id, ty: ty.ty }).ok()?; self.ecx.raw_const_to_mplace(ConstAlloc { alloc_id, ty: ty.ty }).ok()?;
mplace.into() mplace.into()
} else {
return None;
}
} }
Projection(base, elem) => { Projection(base, elem) => {