[AllocBoxToStack] See through borrows.

Now that alloc_boxes whose lifetimes are lexical are emitted with
begin_borrow [lexical]/end_borrow, AllocBoxToStack needs to be able to
see through those new borrow scopes in order to continue stack promoting
the same boxes that it was able to before those lexical scopes were
emitted.
This commit is contained in:
Nate Chandler
2022-01-10 15:20:48 -08:00
parent 4bac557ff3
commit ceea4cf57a
2 changed files with 21 additions and 10 deletions

View File

@@ -285,6 +285,10 @@ SILBuilder::emitDestroyAddr(SILLocation Loc, SILValue Operand) {
if (isa<DeallocStackInst>(Inst))
continue;
// end_borrow insts also don't affect take-ability
if (isa<EndBorrowInst>(Inst))
continue;
// An end_access of the same address may be able to be rewritten as a
// [deinit] access.
if (auto endAccess = dyn_cast<EndAccessInst>(Inst)) {