Skip to content

Commit a33ae1b

Browse files
authored
[LiveRangeCalc] Fix isJointlyDominated (#116020)
Check that every path from the entry block to the use block passes through at least one def block. Previously we only checked that at least one path passed through a def block.
1 parent b385c63 commit a33ae1b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/CodeGen/LiveRangeCalc.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,21 @@ bool LiveRangeCalc::isJointlyDominated(const MachineBasicBlock *MBB,
441441
for (SlotIndex I : Defs)
442442
DefBlocks.set(Indexes.getMBBFromIndex(I)->getNumber());
443443

444+
unsigned EntryNum = MF.front().getNumber();
444445
SetVector<unsigned> PredQueue;
445446
PredQueue.insert(MBB->getNumber());
446447
for (unsigned i = 0; i != PredQueue.size(); ++i) {
447448
unsigned BN = PredQueue[i];
448449
if (DefBlocks[BN])
449-
return true;
450+
continue;
451+
if (BN == EntryNum) {
452+
// We found a path from MBB back to the entry block without hitting any of
453+
// the def blocks.
454+
return false;
455+
}
450456
const MachineBasicBlock *B = MF.getBlockNumbered(BN);
451457
for (const MachineBasicBlock *P : B->predecessors())
452458
PredQueue.insert(P->getNumber());
453459
}
454-
return false;
460+
return true;
455461
}

0 commit comments

Comments
 (0)