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,24 +291,30 @@ 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()?;
let alloc_id = self if ty.is_zst() {
.ecx ImmTy::uninit(ty).into()
.intern_with_temp_alloc(ty, |ecx, dest| { } else if matches!(ty.abi, Abi::Scalar(..) | Abi::ScalarPair(..)) {
let variant_dest = if let Some(variant) = variant { let alloc_id = self
ecx.project_downcast(dest, variant)? .ecx
} else { .intern_with_temp_alloc(ty, |ecx, dest| {
dest.clone() let variant_dest = if let Some(variant) = variant {
}; ecx.project_downcast(dest, variant)?
for (field_index, op) in fields.into_iter().enumerate() { } else {
let field_dest = ecx.project_field(&variant_dest, field_index)?; dest.clone()
ecx.copy_op(op, &field_dest, /*allow_transmute*/ false)?; };
} for (field_index, op) in fields.into_iter().enumerate() {
ecx.write_discriminant(variant.unwrap_or(FIRST_VARIANT), dest) let field_dest = ecx.project_field(&variant_dest, field_index)?;
}) ecx.copy_op(op, &field_dest, /*allow_transmute*/ false)?;
.ok()?; }
let mplace = ecx.write_discriminant(variant.unwrap_or(FIRST_VARIANT), dest)
self.ecx.raw_const_to_mplace(ConstAlloc { alloc_id, ty: ty.ty }).ok()?; })
mplace.into() .ok()?;
let mplace =
self.ecx.raw_const_to_mplace(ConstAlloc { alloc_id, ty: ty.ty }).ok()?;
mplace.into()
} else {
return None;
}
} }
Projection(base, elem) => { Projection(base, elem) => {