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

Alkis Evlogimenos alkis at cs.uiuc.edu
Sat Oct 25 18:33:01 PDT 2003


Changes in directory llvm/lib/CodeGen:

LiveIntervals.cpp updated: 1.1.2.2 -> 1.1.2.3

---
Log message:

Make analysis work even after the PHIElimination pass.


---
Diffs of the changes:  (+27 -13)

Index: llvm/lib/CodeGen/LiveIntervals.cpp
diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.1.2.2 llvm/lib/CodeGen/LiveIntervals.cpp:1.1.2.3
--- llvm/lib/CodeGen/LiveIntervals.cpp:1.1.2.2	Fri Oct 24 10:57:33 2003
+++ llvm/lib/CodeGen/LiveIntervals.cpp	Sat Oct 25 18:31:53 2003
@@ -43,7 +43,7 @@
 
 void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const
 {
-    AU.addPreserved<LiveVariables>();
+    AU.setPreservesAll();
     AU.addRequired<LiveVariables>();
     AU.addRequiredID(PHIEliminationID);
     MachineFunctionPass::getAnalysisUsage(AU);
@@ -103,9 +103,16 @@
 {
     DEBUG(std::cerr << "\t\t\t\tregister: "; printRegName(_mri, reg));
 
-    assert((reg < MRegisterInfo::FirstVirtualRegister ||
-            r2iMap.find(reg) == r2iMap.end()) &&
-           "multiple definitions of virtual register");
+    if (reg >= MRegisterInfo::FirstVirtualRegister &&
+        r2iMap.find(reg) != r2iMap.end()) {
+        DEBUG(std::cerr << "multiple definitions of virtual register at "
+              "instruction[" << i << "]. previous definition at "
+              "instruction[" << r2iMap.find(reg)->second <<"]\n");
+        // we ignore this because the multiple definitions are
+        // generated by the PHIElimination pass which preservers
+        // LiveVariables
+        return;
+    }
     // initialize intervals to [index, inf] - be conservative!
     _intervals.push_back(
         Interval(reg, i, std::numeric_limits<unsigned>::max()));
@@ -146,7 +153,8 @@
     for (MBBPtrs::iterator it = _mbbOrder.begin(), itEnd = _mbbOrder.end();
          it != itEnd; ++it) {
         MachineBasicBlock* mbb = *it;
-        DEBUG(std::cerr << "machine basic block: " << mbb);
+        DEBUG(std::cerr << "machine basic block: "
+                        << mbb->getBasicBlock()->getName() << "\n");
         for (MachineBasicBlock::iterator mi = mbb->begin(), miEnd = mbb->end();
              mi != miEnd; ++index, ++mi) {
             MachineInstr* instr = *mi;
@@ -197,13 +205,19 @@
         }
     }
 
-    // sort the live intervals in increasing start point
-    sort(_intervals.begin(), _intervals.end(), StartPointComp());
+    // mark the real end of each interval instead of
+    // std::numeric_limits<unsigned>::max()
+    for (Intervals::iterator it = _intervals.begin(), itEnd = _intervals.end();
+         it != itEnd; ++it) {
+        if (it->end == std::numeric_limits<unsigned>::max()) {
+            it->end = index;
+        }
+    }
+
+    // the live intervals should be sorted in increasing start point
+//     assert(std::is_sorted(_intervals.begin(), _intervals.end(),
+//                           StartPointComp()));
 
-    DEBUG(
-        for(Intervals::iterator
-                it = _intervals.begin(), itEnd = _intervals.end();
-            it != itEnd; ++it) {
-            std::cerr << *it << '\n';
-        });
+    DEBUG(std::copy(_intervals.begin(), _intervals.end(),
+                    std::ostream_iterator<Interval>(std::cerr, "\n")));
 }





More information about the llvm-commits mailing list