Add a helper for constructing new live ranges that ended from an instruction to the...
authorOwen Anderson <resistor@mac.com>
Thu, 5 Jun 2008 17:15:43 +0000 (17:15 +0000)
committerOwen Anderson <resistor@mac.com>
Thu, 5 Jun 2008 17:15:43 +0000 (17:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52012 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveIntervalAnalysis.h
lib/CodeGen/LiveIntervalAnalysis.cpp

index 1c61339ed3a76ef514680a3f0a03542be8ce7797..a1fb5b9b5b14c081699dddf44b9c5604b35d5b00 100644 (file)
@@ -220,6 +220,11 @@ namespace llvm {
         I = r2iMap_.insert(I, std::make_pair(reg, createInterval(reg)));
       return I->second;
     }
+    
+    /// addLiveRangeToEndOfBlock - Given a register and an instruction,
+    /// adds a live range from that instruction to the end of its MBB.
+    LiveRange addLiveRangeToEndOfBlock(unsigned reg,
+                                        MachineInstr* startInst);
 
     // Interval removal
 
index f184191b937978d1da39d22f319aba750381bd37..053e4d272f8b6a85449893eb27a2b74888d6a37d 100644 (file)
@@ -1830,3 +1830,18 @@ void LiveIntervals::spillPhysRegAroundRegDefsUses(const LiveInterval &li,
     }
   }
 }
+
+LiveRange LiveIntervals::addLiveRangeToEndOfBlock(unsigned reg,
+                                                   MachineInstr* startInst) {
+  LiveInterval& Interval = getOrCreateInterval(reg);
+  VNInfo* VN = Interval.getNextValue(
+            getInstructionIndex(startInst) + InstrSlots::DEF,
+            startInst, getVNInfoAllocator());
+  VN->hasPHIKill = true;
+  VN->kills.push_back(getMBBEndIdx(startInst->getParent()));
+  LiveRange LR(getInstructionIndex(startInst) + InstrSlots::DEF,
+               getMBBEndIdx(startInst->getParent()) + 1, VN);
+  Interval.addRange(LR);
+  
+  return LR;
+}