From 49ae6f7c7ba535c81490bf610335b36f8afa5da4 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Wed, 13 Nov 2024 10:45:31 +0000 Subject: [PATCH] [LiveRangeCalc] Fix isJointlyDominated 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. --- llvm/lib/CodeGen/LiveRangeCalc.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/llvm/lib/CodeGen/LiveRangeCalc.cpp b/llvm/lib/CodeGen/LiveRangeCalc.cpp index dfd4d2910955a..1a9bc694ed0fd 100644 --- a/llvm/lib/CodeGen/LiveRangeCalc.cpp +++ b/llvm/lib/CodeGen/LiveRangeCalc.cpp @@ -441,15 +441,21 @@ bool LiveRangeCalc::isJointlyDominated(const MachineBasicBlock *MBB, for (SlotIndex I : Defs) DefBlocks.set(Indexes.getMBBFromIndex(I)->getNumber()); + unsigned EntryNum = MF.front().getNumber(); SetVector PredQueue; PredQueue.insert(MBB->getNumber()); for (unsigned i = 0; i != PredQueue.size(); ++i) { unsigned BN = PredQueue[i]; if (DefBlocks[BN]) - return true; + continue; + if (BN == EntryNum) { + // We found a path from MBB back to the entry block without hitting any of + // the def blocks. + return false; + } const MachineBasicBlock *B = MF.getBlockNumbered(BN); for (const MachineBasicBlock *P : B->predecessors()) PredQueue.insert(P->getNumber()); } - return false; + return true; }