Skip to content

Commit 2384678

Browse files
committed
Fix an edge case in JointPostDominanceSetComputer::findJointPostDominatingSet
While computing blocksThatLeakIfNeverVisited by processing the worklist, we should also add all the successors of a predecessor block that was in the dominatedBlockSet initially. If not we will end up with incorrect result for a control flow like this : dominating block : bb1 dominated block : bb2 +----+ | bb1| +----+ +------------>| | v | +-+--+ | | bb2| -----+ | +-+--+ | | | | | v v | +-+--+ +-+--+ | |bb3 | | bb4| | +--+-+ +----+ | | | | +--------------+ Without the fix blocksThatLeakIfNeverVisited will not have bb4. The sil test for this fix is rle_redundantload_does_not_postdominate2 in redundant_load_elim_ossa_complex.sil
1 parent cd2d4cc commit 2384678

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/SIL/Utils/BasicBlockUtils.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,13 @@ void JointPostDominanceSetComputer::findJointPostDominatingSet(
463463
for (auto *predBlock : block->getPredecessorBlocks()) {
464464
if (initialBlocks.count(predBlock)) {
465465
reachableInputBlocks.push_back(predBlock);
466+
for (auto *succBlock : predBlock->getSuccessorBlocks()) {
467+
if (visitedBlocks.count(succBlock))
468+
continue;
469+
if (deadEndBlocks.isDeadEnd(succBlock))
470+
continue;
471+
blocksThatLeakIfNeverVisited.insert(succBlock);
472+
}
466473
}
467474
if (visitedBlocks.insert(predBlock).second)
468475
worklist.push_back(predBlock);

0 commit comments

Comments
 (0)