[llvm-commits] [llvm] r119896 - /llvm/trunk/lib/CodeGen/RegAllocBasic.cpp

Andrew Trick atrick at apple.com
Fri Nov 19 18:57:05 PST 2010


Author: atrick
Date: Fri Nov 19 20:57:05 2010
New Revision: 119896

URL: http://llvm.org/viewvc/llvm-project?rev=119896&view=rev
Log:
RABasic fix. Regalloc is responsible for updating block live ins.

Modified:
    llvm/trunk/lib/CodeGen/RegAllocBasic.cpp

Modified: llvm/trunk/lib/CodeGen/RegAllocBasic.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocBasic.cpp?rev=119896&r1=119895&r2=119896&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocBasic.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Fri Nov 19 20:57:05 2010
@@ -107,6 +107,9 @@
   virtual bool runOnMachineFunction(MachineFunction &mf);
 
   static char ID;
+
+private:
+  void addMBBLiveIns();
 };
 
 char RABasic::ID = 0;
@@ -465,6 +468,31 @@
   return 0;
 }
 
+// Add newly allocated physical register to the MBB live in sets.
+void RABasic::addMBBLiveIns() {
+  SmallVector<MachineBasicBlock*, 8> liveInMBBs;
+  MachineBasicBlock &entryMBB = *mf_->begin();
+
+  for (unsigned preg = 0; preg < physReg2liu_.numRegs(); ++preg) {
+    LiveIntervalUnion &liu = physReg2liu_[preg];
+    for (LiveIntervalUnion::SegmentIter segI = liu.begin(), segE = liu.end();
+         segI != segE; ++segI) {
+      // Find the set of basic blocks which this range is live into...
+      if (lis_->findLiveInMBBs(segI->start, segI->end, liveInMBBs)) {
+        // And add the physreg for this interval to their live-in sets.
+        for (unsigned i = 0; i != liveInMBBs.size(); ++i) {
+          if (liveInMBBs[i] != &entryMBB) {
+            if (!liveInMBBs[i]->isLiveIn(preg)) {
+              liveInMBBs[i]->addLiveIn(preg);
+            }
+          }
+        }
+        liveInMBBs.clear();
+      }
+    }
+  }
+}
+
 namespace llvm {
 Spiller *createInlineSpiller(MachineFunctionPass &pass,
                              MachineFunction &mf,
@@ -496,6 +524,8 @@
 
   allocatePhysRegs();
 
+  addMBBLiveIns();
+
   // Diagnostic output before rewriting
   DEBUG(dbgs() << "Post alloc VirtRegMap:\n" << *vrm_ << "\n");
 





More information about the llvm-commits mailing list