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:
parent
8168765d43
commit
7706e2333e
2 changed files with 10 additions and 1 deletions
|
@ -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 b = cx.fcx.ccx.builder();
|
||||
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);
|
||||
p
|
||||
}
|
||||
|
|
|
@ -513,7 +513,9 @@ impl<'tcx> Datum<'tcx, Rvalue> {
|
|||
|this, bcx, llval| {
|
||||
debug!("populate call for Datum::to_lvalue_datum_in_scope \
|
||||
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);
|
||||
bcx.fcx.schedule_lifetime_end(scope, llval);
|
||||
bcx
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue