Fix mem2reg for load_borrows with reborrows

StackAllocationPromoter::pruneAllocStackUsage substitutes loads/stores of alloc_stack
with values. For some reason isLoadFromStack was bailing out for load_borrows with
reborrows leaving them to be fixed up by fixBranchesAndUses which uses live in value
from predecessors for substitution which is obviosly incorrect the block containing
the load_borrow has a store before it.

Fixes rdar://145834542
This commit is contained in:
Meghana Gupta
2025-03-04 10:18:00 -08:00
parent f6924ee4fd
commit 4c46faad26
2 changed files with 27 additions and 5 deletions

View File

@@ -377,11 +377,6 @@ static bool isLoadFromStack(SILInstruction *i, AllocStackInst *asi) {
if (!isa<LoadInst>(i) && !isa<LoadBorrowInst>(i))
return false;
if (auto *lbi = dyn_cast<LoadBorrowInst>(i)) {
if (BorrowedValue(lbi).hasReborrow())
return false;
}
// Skip struct and tuple address projections.
ValueBase *op = i->getOperand(0);
while (op != asi) {