1
Fork 0

revise lifetime handling for alloca's that are initialized as "dropped."

(This can/should be revisited when drop flags are stored out of band.)
This commit is contained in:
Felix S. Klock II 2016-01-12 17:21:11 +01:00
parent 8168765d43
commit 7706e2333e
2 changed files with 10 additions and 1 deletions

View file

@ -1354,6 +1354,13 @@ pub fn alloca_dropped<'blk, 'tcx>(cx: Block<'blk, 'tcx>, ty: Ty<'tcx>, name: &st
let p = alloca(cx, llty, name); let p = alloca(cx, llty, name);
let b = cx.fcx.ccx.builder(); let b = cx.fcx.ccx.builder();
b.position_before(cx.fcx.alloca_insert_pt.get().unwrap()); b.position_before(cx.fcx.alloca_insert_pt.get().unwrap());
// This is just like `call_lifetime_start` (but latter expects a
// Block, which we do not have for `alloca_insert_pt`).
core_lifetime_emit(cx.ccx(), p, Lifetime::Start, |ccx, size, lifetime_start| {
let ptr = b.pointercast(p, Type::i8p(ccx));
b.call(lifetime_start, &[C_u64(ccx, size), ptr], None);
});
memfill(&b, p, ty, adt::DTOR_DONE); memfill(&b, p, ty, adt::DTOR_DONE);
p p
} }

View file

@ -513,7 +513,9 @@ impl<'tcx> Datum<'tcx, Rvalue> {
|this, bcx, llval| { |this, bcx, llval| {
debug!("populate call for Datum::to_lvalue_datum_in_scope \ debug!("populate call for Datum::to_lvalue_datum_in_scope \
self.ty={:?}", this.ty); self.ty={:?}", this.ty);
call_lifetime_start(bcx, llval); // do not call_lifetime_start here; the
// `InitAlloc::Dropped` will start scratch
// value's lifetime at open of function body.
let bcx = this.store_to(bcx, llval); let bcx = this.store_to(bcx, llval);
bcx.fcx.schedule_lifetime_end(scope, llval); bcx.fcx.schedule_lifetime_end(scope, llval);
bcx bcx