mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Improve handling of unreachable blocks in mem2reg.
We were handling regular uses, but not handling promotions in things like debug_value_addr. This was exposed by some pass ordering changes I have in an upcoming commit.
This commit is contained in:
@@ -568,7 +568,8 @@ StackAllocationPromoter::getLiveInValue(BlockSet &PhiBlocks,
|
||||
return BB->getBBArg(BB->getNumBBArg()-1);
|
||||
}
|
||||
|
||||
assert(DT->getNode(BB) && "Block is not in dominator tree!");
|
||||
if (BB->pred_empty() || !DT->getNode(BB))
|
||||
return SILUndef::get(ASI->getElementType(), ASI->getModule());
|
||||
|
||||
// No phi for this value in this block means that the value flowing
|
||||
// out of the immediate dominator reaches here.
|
||||
@@ -610,14 +611,10 @@ void StackAllocationPromoter::fixBranchesAndUses(BlockSet &PhiBlocks) {
|
||||
// examining is a value, replace it with undef. Either way, delete
|
||||
// the instruction and move on.
|
||||
SILBasicBlock *BB = LI->getParent();
|
||||
if (BB->pred_empty() || !DT->getNode(BB)) {
|
||||
Def = SILUndef::get(ASI->getElementType(), ASI->getModule());
|
||||
} else {
|
||||
Def = getLiveInValue(PhiBlocks, BB);
|
||||
}
|
||||
|
||||
Def = getLiveInValue(PhiBlocks, BB);
|
||||
|
||||
DEBUG(llvm::dbgs() << "*** Replacing " << *LI << " with Def " << *Def);
|
||||
|
||||
|
||||
// Replace the load with the definition that we found.
|
||||
replaceLoad(LI, Def, ASI);
|
||||
removedUser = true;
|
||||
|
||||
Reference in New Issue
Block a user