[llvm-commits] [regalloc_linearscan] CVS: llvm/lib/CodeGen/LiveIntervals.cpp

Alkis Evlogimenos alkis at cs.uiuc.edu
Wed Nov 5 20:59:01 PST 2003


Changes in directory llvm/lib/CodeGen:

LiveIntervals.cpp updated: 1.1.2.6 -> 1.1.2.7

---
Log message:

Fix bug in live interval analysis where vitrual registers that were
killed in the same basic block that defined them, were not handled
properly.


---
Diffs of the changes:  (+17 -15)

Index: llvm/lib/CodeGen/LiveIntervals.cpp
diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.1.2.6 llvm/lib/CodeGen/LiveIntervals.cpp:1.1.2.7
--- llvm/lib/CodeGen/LiveIntervals.cpp:1.1.2.6	Wed Nov  5 01:27:16 2003
+++ llvm/lib/CodeGen/LiveIntervals.cpp	Wed Nov  5 20:58:12 2003
@@ -102,16 +102,18 @@
 {
     DEBUG(std::cerr << "\t\t\tregister: "; printRegName(mri_, reg));
 
-    unsigned start = getInstructionIndex(instr);
+    unsigned instrIndex = getInstructionIndex(instr);
 
     LiveVariables::VarInfo& vi = lv_->getVarInfo(reg);
 
     Reg2IntervalMap::iterator r2iit = r2iMap_.find(reg);
+    // handle multiple definition case (machine instructions violating
+    // ssa after phi-elimination
     if (r2iit != r2iMap_.end()) {
         unsigned ii = r2iit->second;
         Interval& interval = intervals_[ii];
         unsigned end = getInstructionIndex(mbb->back()) + 1;
-        interval.addRange(start, end);
+        interval.addRange(instrIndex, end);
         DEBUG(std::cerr << " -> " << interval << '\n');
     }
     else {
@@ -121,28 +123,28 @@
         // update interval index for this register
         r2iMap_[reg] = intervals_.size() - 1;
 
-        unsigned index = lv_->getMachineBasicBlockInfo(mbb).second;
-        if (index < vi.AliveBlocks.size() && vi.AliveBlocks[index]) {
-            unsigned end = getInstructionIndex(mbb->back()) + 1;
-            interval.addRange(start, end);
-        }
-
         for (MbbIndex2MbbMap::iterator
                  it = mbbi2mbbMap_.begin(), itEnd = mbbi2mbbMap_.end();
              it != itEnd; ++it) {
-            unsigned mbbIndex = it->first;
-            MachineBasicBlock* mbb2 = it->second;
-            if (mbbIndex < vi.AliveBlocks.size() &&
-                vi.AliveBlocks[mbbIndex] && mbb != mbb2) {
-                interval.addRange(getInstructionIndex(mbb2->front()),
-                                  getInstructionIndex(mbb2->back()) + 1);
+            unsigned liveBlockIndex = it->first;
+            MachineBasicBlock* liveBlock = it->second;
+            if (liveBlockIndex < vi.AliveBlocks.size() &&
+                vi.AliveBlocks[liveBlockIndex]) {
+                unsigned start = mbb == liveBlock ?
+                    instrIndex :
+                    getInstructionIndex(liveBlock->front());
+                interval.addRange(start,
+                                  getInstructionIndex(liveBlock->back()) + 1);
             }
         }
 
         for (int i = 0, e = vi.Kills.size(); i != e; ++i) {
             MachineBasicBlock* killerBlock = vi.Kills[i].first;
             MachineInstr* killerInstr = vi.Kills[i].second;
-            interval.addRange(getInstructionIndex(killerBlock->front()),
+            unsigned start = mbb == killerBlock ?
+                instrIndex :
+                getInstructionIndex(killerBlock->front());
+            interval.addRange(start,
                               getInstructionIndex(killerInstr) + 1);
         }
         DEBUG(std::cerr << " -> " << interval << '\n');





More information about the llvm-commits mailing list