Simplify const_prop logic
This commit is contained in:
parent
524e575bb4
commit
b40f3c1060
1 changed files with 9 additions and 11 deletions
|
@ -385,19 +385,17 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||||
(),
|
(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let ret = if let Ok(layout) = ecx.layout_of(body.return_ty().subst(tcx, substs)) {
|
let ret = ecx
|
||||||
|
.layout_of(body.return_ty().subst(tcx, substs))
|
||||||
|
.ok()
|
||||||
// Don't bother allocating memory for ZST types which have no values
|
// Don't bother allocating memory for ZST types which have no values
|
||||||
// or for large values.
|
// or for large values.
|
||||||
if !layout.is_zst() && layout.size < Size::from_bytes(MAX_ALLOC_LIMIT) {
|
.filter(|ret_layout| {
|
||||||
// hopefully all types will allocate, since large types have already been removed,
|
!ret_layout.is_zst() && ret_layout.size < Size::from_bytes(MAX_ALLOC_LIMIT)
|
||||||
// but check anyways
|
})
|
||||||
ecx.allocate(layout, MemoryKind::Stack).ok().map(Into::into)
|
// hopefully all types will allocate, since large types have already been removed
|
||||||
} else {
|
.and_then(|ret_layout| ecx.allocate(ret_layout, MemoryKind::Stack).ok())
|
||||||
None
|
.map(Into::into);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
ecx.push_stack_frame(
|
ecx.push_stack_frame(
|
||||||
Instance::new(def_id, substs),
|
Instance::new(def_id, substs),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue