-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LiveRangeCalc] Fix isJointlyDominated #116020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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/pr-subscribers-llvm-regalloc Author: Jay Foad (jayfoad) ChangesCheck that every path from the entry block to the use block passes Full diff: https://github.com/llvm/llvm-project/pull/116020.diff 1 Files Affected:
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;
}
|
|
I'll try to come up with a test case using MachineVerifier. |
Actually MachineVerifier only uses this function to verify LiveIntervals and I can't write a MIR test for malformed LiveIntervals, so I don't have any way to test this. |
kparzysz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for catching this!
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/10779 Here is the relevant piece of the build log for the reference |
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.