1
Fork 0

use AllocId instead of Allocation in ConstValue::ByRef

This commit is contained in:
Ralf Jung 2023-09-11 20:01:48 +02:00
parent c728bf3963
commit 551f481ffb
15 changed files with 80 additions and 63 deletions

View file

@ -535,7 +535,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
}
trace!("replacing {:?} with {:?}", place, value);
// FIXME> figure out what to do when read_immediate_raw fails
// FIXME: figure out what to do when read_immediate_raw fails
let imm = self.ecx.read_immediate_raw(&value).ok()?;
let Right(imm) = imm else { return None };
@ -544,7 +544,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
Some(ConstantKind::from_scalar(self.tcx, scalar, value.layout.ty))
}
Immediate::ScalarPair(l, r) if l.try_to_int().is_ok() && r.try_to_int().is_ok() => {
let alloc = self
let alloc_id = self
.ecx
.intern_with_temp_alloc(value.layout, |ecx, dest| {
ecx.write_immediate(*imm, dest)
@ -552,7 +552,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
.ok()?;
Some(ConstantKind::Val(
ConstValue::ByRef { alloc, offset: Size::ZERO },
ConstValue::ByRef { alloc_id, offset: Size::ZERO },
value.layout.ty,
))
}