1
Fork 0

interpret: make read functions generic over operand type

This commit is contained in:
Ralf Jung 2023-07-25 22:19:18 +02:00
parent 00fb45dccd
commit 77ff1b83cd
19 changed files with 130 additions and 128 deletions

View file

@ -494,7 +494,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
trace!("assertion on {:?} should be {:?}", value, expected);
let expected = Scalar::from_bool(expected);
let value_const = self.use_ecx(location, |this| this.ecx.read_scalar(&value))?;
let value_const = self.use_ecx(location, |this| this.ecx.read_scalar(value))?;
if expected != value_const {
// Poison all places this operand references so that further code
@ -664,7 +664,7 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
}
TerminatorKind::SwitchInt { ref discr, ref targets } => {
if let Some(ref value) = self.eval_operand(&discr, location)
&& let Some(value_const) = self.use_ecx(location, |this| this.ecx.read_scalar(&value))
&& let Some(value_const) = self.use_ecx(location, |this| this.ecx.read_scalar(value))
&& let Ok(constant) = value_const.try_to_int()
&& let Ok(constant) = constant.to_bits(constant.size())
{