[llvm] [LiveRangeCalc] Fix isJointlyDominated (PR #116020)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 13 02:47:21 PST 2024
https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/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.
>From 49ae6f7c7ba535c81490bf610335b36f8afa5da4 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
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 dfd4d2910955af..1a9bc694ed0fdc 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<unsigned> 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;
}
More information about the llvm-commits
mailing list