[llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp LiveIntervalAnalysis.h

Chris Lattner lattner at cs.uiuc.edu
Thu Sep 1 17:20:43 PDT 2005



Changes in directory llvm/lib/CodeGen:

LiveIntervalAnalysis.cpp updated: 1.144 -> 1.145
LiveIntervalAnalysis.h updated: 1.45 -> 1.46
---
Log message:

Teach live intervals to not crash on dead livein regs


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

 LiveIntervalAnalysis.cpp |   17 +++++++++++------
 LiveIntervalAnalysis.h   |    3 ++-
 2 files changed, 13 insertions(+), 7 deletions(-)


Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.144 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.145
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.144	Tue Aug 23 17:51:41 2005
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp	Thu Sep  1 19:20:32 2005
@@ -131,10 +131,10 @@
     for (MachineFunction::livein_iterator I = fn.livein_begin(),
            E = fn.livein_end(); I != E; ++I) {
       handlePhysicalRegisterDef(Entry, Entry->begin(),
-                                getOrCreateInterval(I->first), 0, 0);
+                                getOrCreateInterval(I->first), 0, 0, true);
       for (const unsigned* AS = mri_->getAliasSet(I->first); *AS; ++AS)
         handlePhysicalRegisterDef(Entry, Entry->begin(),
-                                  getOrCreateInterval(*AS), 0, 0);
+                                  getOrCreateInterval(*AS), 0, 0, true);
     }
   }
 
@@ -478,7 +478,8 @@
 void LiveIntervals::handlePhysicalRegisterDef(MachineBasicBlock *MBB,
                                               MachineBasicBlock::iterator mi,
                                               LiveInterval& interval,
-                                              unsigned SrcReg, unsigned DestReg)
+                                              unsigned SrcReg, unsigned DestReg,
+                                              bool isLiveIn)
 {
   // A physical register cannot be live across basic block, so its
   // lifetime must end somewhere in its defining basic block.
@@ -501,9 +502,7 @@
   // If it is not dead on definition, it must be killed by a
   // subsequent instruction. Hence its interval is:
   // [defSlot(def), useSlot(kill)+1)
-  while (true) {
-    ++mi;
-    assert(mi != MBB->end() && "physreg was not killed in defining block!");
+  while (++mi != MBB->end()) {
     baseIndex += InstrSlots::NUM;
     if (lv_->KillsRegister(mi, interval.reg)) {
       DEBUG(std::cerr << " killed");
@@ -511,6 +510,12 @@
       goto exit;
     }
   }
+  
+  // The only case we should have a dead physreg here without a killing or
+  // instruction where we know it's dead is if it is live-in to the function
+  // and never used.
+  assert(isLiveIn && "physreg was not killed in defining block!");
+  end = getDefIndex(start) + 1;  // It's dead.
 
 exit:
   assert(start < end && "did not find end of interval?");


Index: llvm/lib/CodeGen/LiveIntervalAnalysis.h
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.45 llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.46
--- llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.45	Wed Mar  9 17:05:19 2005
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.h	Thu Sep  1 19:20:32 2005
@@ -164,7 +164,8 @@
     void handlePhysicalRegisterDef(MachineBasicBlock* mbb,
                                    MachineBasicBlock::iterator mi,
                                    LiveInterval& interval,
-                                   unsigned SrcReg, unsigned DestReg);
+                                   unsigned SrcReg, unsigned DestReg,
+                                   bool isLiveIn = false);
 
     /// Return true if the two specified registers belong to different
     /// register classes.  The registers may be either phys or virt regs.






More information about the llvm-commits mailing list