Do not unnecessarily eval consts in codegen
This commit is contained in:
parent
da889684c8
commit
914193c8f4
8 changed files with 30 additions and 19 deletions
|
@ -785,8 +785,10 @@ fn codegen_stmt<'tcx>(
|
|||
}
|
||||
Rvalue::Repeat(ref operand, times) => {
|
||||
let operand = codegen_operand(fx, operand);
|
||||
let times =
|
||||
fx.monomorphize(times).eval_target_usize(fx.tcx, ParamEnv::reveal_all());
|
||||
let times = fx
|
||||
.monomorphize(times)
|
||||
.try_to_target_usize(fx.tcx)
|
||||
.expect("expected monomorphic const in codegen");
|
||||
if operand.layout().size.bytes() == 0 {
|
||||
// Do nothing for ZST's
|
||||
} else if fx.clif_type(operand.layout().ty) == Some(types::I8) {
|
||||
|
@ -944,7 +946,10 @@ fn codegen_stmt<'tcx>(
|
|||
fn codegen_array_len<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, place: CPlace<'tcx>) -> Value {
|
||||
match *place.layout().ty.kind() {
|
||||
ty::Array(_elem_ty, len) => {
|
||||
let len = fx.monomorphize(len).eval_target_usize(fx.tcx, ParamEnv::reveal_all()) as i64;
|
||||
let len = fx
|
||||
.monomorphize(len)
|
||||
.try_to_target_usize(fx.tcx)
|
||||
.expect("expected monomorphic const in codegen") as i64;
|
||||
fx.bcx.ins().iconst(fx.pointer_type, len)
|
||||
}
|
||||
ty::Slice(_elem_ty) => place.to_ptr_unsized().1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue