[llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveInterval.h LiveIntervalAnalysis.h

Chris Lattner lattner at cs.uiuc.edu
Tue Aug 29 16:18:13 PDT 2006



Changes in directory llvm/include/llvm/CodeGen:

LiveInterval.h updated: 1.21 -> 1.22
LiveIntervalAnalysis.h updated: 1.54 -> 1.55
---
Log message:

Teach the coallescer to coallesce live intervals joined by an arbitrary 
number of copies, potentially defining live ranges that appear to have
differing value numbers that become identical when coallsced.  Among other
things, this fixes CodeGen/X86/shift-coalesce.ll and PR687: http://llvm.org/PR687 .


---
Diffs of the changes:  (+19 -18)

 LiveInterval.h         |   28 +++++++++++-----------------
 LiveIntervalAnalysis.h |    9 ++++++++-
 2 files changed, 19 insertions(+), 18 deletions(-)


Index: llvm/include/llvm/CodeGen/LiveInterval.h
diff -u llvm/include/llvm/CodeGen/LiveInterval.h:1.21 llvm/include/llvm/CodeGen/LiveInterval.h:1.22
--- llvm/include/llvm/CodeGen/LiveInterval.h:1.21	Fri Aug 25 18:41:24 2006
+++ llvm/include/llvm/CodeGen/LiveInterval.h	Tue Aug 29 18:17:59 2006
@@ -78,8 +78,6 @@
     float weight;        // weight of this interval
     Ranges ranges;       // the ranges in which this register is live
   private:
-    unsigned NumValues;  // the number of distinct values in this interval.
-    
     /// InstDefiningValue - This tracks the def index of the instruction that
     /// defines a particular value number in the interval.  This may be ~0,
     /// which is treated as unknown, or ~1, which is a deleted value number.
@@ -87,7 +85,7 @@
   public:
 
     LiveInterval(unsigned Reg, float Weight)
-      : reg(Reg), weight(Weight), NumValues(0) {
+      : reg(Reg), weight(Weight) {
     }
 
     typedef Ranges::iterator iterator;
@@ -115,24 +113,24 @@
       std::swap(reg, other.reg);
       std::swap(weight, other.weight);
       std::swap(ranges, other.ranges);
-      std::swap(NumValues, other.NumValues);
       std::swap(InstDefiningValue, other.InstDefiningValue);
     }
 
-    bool containsOneValue() const { return NumValues == 1; }
+    bool containsOneValue() const { return InstDefiningValue.size() == 1; }
 
-    unsigned getNumValNums() const { return NumValues; }
+    unsigned getNumValNums() const { return InstDefiningValue.size(); }
     
     /// getNextValue - Create a new value number and return it.  MIIdx specifies
     /// the instruction that defines the value number.
     unsigned getNextValue(unsigned MIIdx) {
       InstDefiningValue.push_back(MIIdx);
-      return NumValues++;
+      return InstDefiningValue.size()-1;
     }
     
     /// getInstForValNum - Return the machine instruction index that defines the
     /// specified value number.
     unsigned getInstForValNum(unsigned ValNo) const {
+      assert(ValNo < InstDefiningValue.size());
       return InstDefiningValue[ValNo];
     }
     
@@ -189,11 +187,6 @@
     /// contains the specified index, or end() if there is none.
     iterator FindLiveRangeContaining(unsigned Idx);
     
-    /// joinable - Two intervals are joinable if the either don't overlap at all
-    /// or if the destination of the copy is a single assignment value, and it
-    /// only overlaps with one value in the source interval.
-    bool joinable(const LiveInterval& other, unsigned CopyIdx) const;
-
     /// getOverlapingRanges - Given another live interval which is defined as a
     /// copy from this one, return a list of all of the live ranges where the
     /// two overlap and have different value numbers.
@@ -218,11 +211,12 @@
       addRangeFrom(LR, ranges.begin());
     }
 
-    /// join - Join two live intervals (this, and other) together.  This
-    /// operation is the result of a copy instruction in the source program,
-    /// that occurs at index 'CopyIdx' that copies from 'other' to 'this'.  This
-    /// destroys 'other'.
-    void join(LiveInterval& other, unsigned CopyIdx);
+    /// join - Join two live intervals (this, and other) together.  This applies
+    /// mappings to the value numbers in the LHS/RHS intervals as specified.  If
+    /// the intervals are not joinable, this aborts.
+    void join(LiveInterval &Other, int *ValNoAssignments,
+              int *RHSValNoAssignments,
+              SmallVector<unsigned, 16> &NewInstDefiningValue);
 
 
     /// removeRange - Remove the specified range from this interval.  Note that


Index: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h
diff -u llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.54 llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.55
--- llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.54	Thu Aug 24 17:43:55 2006
+++ llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h	Tue Aug 29 18:17:59 2006
@@ -174,6 +174,13 @@
     /// it may be possible if other things get coallesced.
     bool JoinCopy(MachineInstr *CopyMI, unsigned SrcReg, unsigned DstReg);
     
+    /// JoinIntervals - Attempt to join these two intervals.  On failure, this
+    /// returns false.  Otherwise, if one of the intervals being joined is a
+    /// physreg, this method always canonicalizes DestInt to be it.  The output
+    /// "SrcInt" will not have been modified, so we can use this information
+    /// below to update aliases.
+    bool JoinIntervals(LiveInterval &LHS, LiveInterval &RHS);
+    
     /// handleRegisterDef - update intervals for a register def
     /// (calls handlePhysicalRegisterDef and
     /// handleVirtualRegisterDef)
@@ -200,7 +207,7 @@
 
 
     bool AdjustCopiesBackFrom(LiveInterval &IntA, LiveInterval &IntB,
-                              MachineInstr *CopyMI, unsigned CopyIdx);
+                              MachineInstr *CopyMI);
 
     bool overlapsAliases(const LiveInterval *lhs,
                          const LiveInterval *rhs) const;






More information about the llvm-commits mailing list