[llvm] [LiveRangeCalc] Fix isJointlyDominated (PR #116020)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 02:47:57 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-regalloc

Author: Jay Foad (jayfoad)

<details>
<summary>Changes</summary>

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.


---
Full diff: https://github.com/llvm/llvm-project/pull/116020.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/LiveRangeCalc.cpp (+8-2) 


``````````diff
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;
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/116020


More information about the llvm-commits mailing list