Intern allocations during constant propagation
This commit is contained in:
parent
8c406dc29c
commit
c5e762fd88
1 changed files with 15 additions and 2 deletions
|
@ -30,7 +30,7 @@ use crate::interpret::{
|
||||||
self, InterpCx, ScalarMaybeUndef, Immediate, OpTy,
|
self, InterpCx, ScalarMaybeUndef, Immediate, OpTy,
|
||||||
StackPopCleanup, LocalValue, LocalState, AllocId, Frame,
|
StackPopCleanup, LocalValue, LocalState, AllocId, Frame,
|
||||||
Allocation, MemoryKind, ImmTy, Pointer, Memory, PlaceTy,
|
Allocation, MemoryKind, ImmTy, Pointer, Memory, PlaceTy,
|
||||||
Operand as InterpOperand,
|
Operand as InterpOperand, intern_const_alloc_recursive,
|
||||||
};
|
};
|
||||||
use crate::const_eval::error_to_const_error;
|
use crate::const_eval::error_to_const_error;
|
||||||
use crate::transform::{MirPass, MirSource};
|
use crate::transform::{MirPass, MirSource};
|
||||||
|
@ -655,14 +655,27 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
match *op {
|
let is_scalar = match *op {
|
||||||
interpret::Operand::Immediate(Immediate::Scalar(ScalarMaybeUndef::Scalar(s))) =>
|
interpret::Operand::Immediate(Immediate::Scalar(ScalarMaybeUndef::Scalar(s))) =>
|
||||||
s.is_bits(),
|
s.is_bits(),
|
||||||
interpret::Operand::Immediate(Immediate::ScalarPair(ScalarMaybeUndef::Scalar(l),
|
interpret::Operand::Immediate(Immediate::ScalarPair(ScalarMaybeUndef::Scalar(l),
|
||||||
ScalarMaybeUndef::Scalar(r))) =>
|
ScalarMaybeUndef::Scalar(r))) =>
|
||||||
l.is_bits() && r.is_bits(),
|
l.is_bits() && r.is_bits(),
|
||||||
_ => false
|
_ => false
|
||||||
|
};
|
||||||
|
|
||||||
|
if let interpret::Operand::Indirect(_) = *op {
|
||||||
|
if self.tcx.sess.opts.debugging_opts.mir_opt_level >= 2 {
|
||||||
|
intern_const_alloc_recursive(
|
||||||
|
&mut self.ecx,
|
||||||
|
None,
|
||||||
|
op.assert_mem_place()
|
||||||
|
).expect("failed to intern alloc");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return is_scalar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue