Omit lifetime intrinsics for function arguments and similar top-level items

Function arguments are live for the whole function scope, so adding
lifetime intrinsics around them adds no value. The same is true for drop
hint allocas and everything else that goes directly through
lvalue_scratch_datum. So the easiest fix is to emit lifetime intrinsics
only for lvalue datums that are created in to_lvalue_datum_in_scope().

The reduces peak memory usage and LLVM times by about 1-4%, depending on
the crate.
This commit is contained in:
Björn Steinbrink 2015-08-25 18:33:55 +02:00
parent 727a5d543d
commit 9a15d664a6

View file

@ -304,9 +304,7 @@ pub fn lvalue_scratch_datum<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
let scratch = alloc_ty(bcx, ty, name);
// Subtle. Populate the scratch memory *before* scheduling cleanup.
call_lifetime_start(bcx, scratch);
let bcx = populate(arg, bcx, scratch);
bcx.fcx.schedule_lifetime_end(scope, scratch);
bcx.fcx.schedule_drop_mem(scope, scratch, ty, None);
DatumBlock::new(bcx, Datum::new(scratch, ty, Lvalue::new("datum::lvalue_scratch_datum")))
@ -499,7 +497,12 @@ impl<'tcx> Datum<'tcx, Rvalue> {
ByValue => {
lvalue_scratch_datum(
bcx, self.ty, name, scope, self,
|this, bcx, llval| this.store_to(bcx, llval))
|this, bcx, llval| {
call_lifetime_start(bcx, llval);
let bcx = this.store_to(bcx, llval);
bcx.fcx.schedule_lifetime_end(scope, llval);
bcx
})
}
}
}