Home | History | Annotate | Download | only in CodeGen
      1 //===-- llvm/CodeGen/LiveInterval.h - Interval representation ---*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file implements the LiveRange and LiveInterval classes.  Given some
     11 // numbering of each the machine instructions an interval [i, j) is said to be a
     12 // live interval for register v if there is no instruction with number j' >= j
     13 // such that v is live at j' and there is no instruction with number i' < i such
     14 // that v is live at i'. In this implementation intervals can have holes,
     15 // i.e. an interval might look like [1,20), [50,65), [1000,1001).  Each
     16 // individual range is represented as an instance of LiveRange, and the whole
     17 // interval is represented as an instance of LiveInterval.
     18 //
     19 //===----------------------------------------------------------------------===//
     20 
     21 #ifndef LLVM_CODEGEN_LIVEINTERVAL_H
     22 #define LLVM_CODEGEN_LIVEINTERVAL_H
     23 
     24 #include "llvm/ADT/IntEqClasses.h"
     25 #include "llvm/CodeGen/SlotIndexes.h"
     26 #include "llvm/Support/AlignOf.h"
     27 #include "llvm/Support/Allocator.h"
     28 #include <cassert>
     29 #include <climits>
     30 
     31 namespace llvm {
     32   class CoalescerPair;
     33   class LiveIntervals;
     34   class MachineInstr;
     35   class MachineRegisterInfo;
     36   class TargetRegisterInfo;
     37   class raw_ostream;
     38 
     39   /// VNInfo - Value Number Information.
     40   /// This class holds information about a machine level values, including
     41   /// definition and use points.
     42   ///
     43   class VNInfo {
     44   public:
     45     typedef BumpPtrAllocator Allocator;
     46 
     47     /// The ID number of this value.
     48     unsigned id;
     49 
     50     /// The index of the defining instruction.
     51     SlotIndex def;
     52 
     53     /// VNInfo constructor.
     54     VNInfo(unsigned i, SlotIndex d)
     55       : id(i), def(d)
     56     { }
     57 
     58     /// VNInfo construtor, copies values from orig, except for the value number.
     59     VNInfo(unsigned i, const VNInfo &orig)
     60       : id(i), def(orig.def)
     61     { }
     62 
     63     /// Copy from the parameter into this VNInfo.
     64     void copyFrom(VNInfo &src) {
     65       def = src.def;
     66     }
     67 
     68     /// Returns true if this value is defined by a PHI instruction (or was,
     69     /// PHI instrucions may have been eliminated).
     70     /// PHI-defs begin at a block boundary, all other defs begin at register or
     71     /// EC slots.
     72     bool isPHIDef() const { return def.isBlock(); }
     73 
     74     /// Returns true if this value is unused.
     75     bool isUnused() const { return !def.isValid(); }
     76 
     77     /// Mark this value as unused.
     78     void markUnused() { def = SlotIndex(); }
     79   };
     80 
     81   /// LiveRange structure - This represents a simple register range in the
     82   /// program, with an inclusive start point and an exclusive end point.
     83   /// These ranges are rendered as [start,end).
     84   struct LiveRange {
     85     SlotIndex start;  // Start point of the interval (inclusive)
     86     SlotIndex end;    // End point of the interval (exclusive)
     87     VNInfo *valno;   // identifier for the value contained in this interval.
     88 
     89     LiveRange() : valno(0) {}
     90 
     91     LiveRange(SlotIndex S, SlotIndex E, VNInfo *V)
     92       : start(S), end(E), valno(V) {
     93       assert(S < E && "Cannot create empty or backwards range");
     94     }
     95 
     96     /// contains - Return true if the index is covered by this range.
     97     ///
     98     bool contains(SlotIndex I) const {
     99       return start <= I && I < end;
    100     }
    101 
    102     /// containsRange - Return true if the given range, [S, E), is covered by
    103     /// this range.
    104     bool containsRange(SlotIndex S, SlotIndex E) const {
    105       assert((S < E) && "Backwards interval?");
    106       return (start <= S && S < end) && (start < E && E <= end);
    107     }
    108 
    109     bool operator<(const LiveRange &LR) const {
    110       return start < LR.start || (start == LR.start && end < LR.end);
    111     }
    112     bool operator==(const LiveRange &LR) const {
    113       return start == LR.start && end == LR.end;
    114     }
    115 
    116     void dump() const;
    117     void print(raw_ostream &os) const;
    118   };
    119 
    120   template <> struct isPodLike<LiveRange> { static const bool value = true; };
    121 
    122   raw_ostream& operator<<(raw_ostream& os, const LiveRange &LR);
    123 
    124 
    125   inline bool operator<(SlotIndex V, const LiveRange &LR) {
    126     return V < LR.start;
    127   }
    128 
    129   inline bool operator<(const LiveRange &LR, SlotIndex V) {
    130     return LR.start < V;
    131   }
    132 
    133   /// LiveInterval - This class represents some number of live ranges for a
    134   /// register or value.  This class also contains a bit of register allocator
    135   /// state.
    136   class LiveInterval {
    137   public:
    138 
    139     typedef SmallVector<LiveRange,4> Ranges;
    140     typedef SmallVector<VNInfo*,4> VNInfoList;
    141 
    142     const unsigned reg;  // the register or stack slot of this interval.
    143     float weight;        // weight of this interval
    144     Ranges ranges;       // the ranges in which this register is live
    145     VNInfoList valnos;   // value#'s
    146 
    147     struct InstrSlots {
    148       enum {
    149         LOAD  = 0,
    150         USE   = 1,
    151         DEF   = 2,
    152         STORE = 3,
    153         NUM   = 4
    154       };
    155 
    156     };
    157 
    158     LiveInterval(unsigned Reg, float Weight)
    159       : reg(Reg), weight(Weight) {}
    160 
    161     typedef Ranges::iterator iterator;
    162     iterator begin() { return ranges.begin(); }
    163     iterator end()   { return ranges.end(); }
    164 
    165     typedef Ranges::const_iterator const_iterator;
    166     const_iterator begin() const { return ranges.begin(); }
    167     const_iterator end() const  { return ranges.end(); }
    168 
    169     typedef VNInfoList::iterator vni_iterator;
    170     vni_iterator vni_begin() { return valnos.begin(); }
    171     vni_iterator vni_end() { return valnos.end(); }
    172 
    173     typedef VNInfoList::const_iterator const_vni_iterator;
    174     const_vni_iterator vni_begin() const { return valnos.begin(); }
    175     const_vni_iterator vni_end() const { return valnos.end(); }
    176 
    177     /// advanceTo - Advance the specified iterator to point to the LiveRange
    178     /// containing the specified position, or end() if the position is past the
    179     /// end of the interval.  If no LiveRange contains this position, but the
    180     /// position is in a hole, this method returns an iterator pointing to the
    181     /// LiveRange immediately after the hole.
    182     iterator advanceTo(iterator I, SlotIndex Pos) {
    183       assert(I != end());
    184       if (Pos >= endIndex())
    185         return end();
    186       while (I->end <= Pos) ++I;
    187       return I;
    188     }
    189 
    190     /// find - Return an iterator pointing to the first range that ends after
    191     /// Pos, or end(). This is the same as advanceTo(begin(), Pos), but faster
    192     /// when searching large intervals.
    193     ///
    194     /// If Pos is contained in a LiveRange, that range is returned.
    195     /// If Pos is in a hole, the following LiveRange is returned.
    196     /// If Pos is beyond endIndex, end() is returned.
    197     iterator find(SlotIndex Pos);
    198 
    199     const_iterator find(SlotIndex Pos) const {
    200       return const_cast<LiveInterval*>(this)->find(Pos);
    201     }
    202 
    203     void clear() {
    204       valnos.clear();
    205       ranges.clear();
    206     }
    207 
    208     bool hasAtLeastOneValue() const { return !valnos.empty(); }
    209 
    210     bool containsOneValue() const { return valnos.size() == 1; }
    211 
    212     unsigned getNumValNums() const { return (unsigned)valnos.size(); }
    213 
    214     /// getValNumInfo - Returns pointer to the specified val#.
    215     ///
    216     inline VNInfo *getValNumInfo(unsigned ValNo) {
    217       return valnos[ValNo];
    218     }
    219     inline const VNInfo *getValNumInfo(unsigned ValNo) const {
    220       return valnos[ValNo];
    221     }
    222 
    223     /// containsValue - Returns true if VNI belongs to this interval.
    224     bool containsValue(const VNInfo *VNI) const {
    225       return VNI && VNI->id < getNumValNums() && VNI == getValNumInfo(VNI->id);
    226     }
    227 
    228     /// getNextValue - Create a new value number and return it.  MIIdx specifies
    229     /// the instruction that defines the value number.
    230     VNInfo *getNextValue(SlotIndex def, VNInfo::Allocator &VNInfoAllocator) {
    231       VNInfo *VNI =
    232         new (VNInfoAllocator) VNInfo((unsigned)valnos.size(), def);
    233       valnos.push_back(VNI);
    234       return VNI;
    235     }
    236 
    237     /// createDeadDef - Make sure the interval has a value defined at Def.
    238     /// If one already exists, return it. Otherwise allocate a new value and
    239     /// add liveness for a dead def.
    240     VNInfo *createDeadDef(SlotIndex Def, VNInfo::Allocator &VNInfoAllocator);
    241 
    242     /// Create a copy of the given value. The new value will be identical except
    243     /// for the Value number.
    244     VNInfo *createValueCopy(const VNInfo *orig,
    245                             VNInfo::Allocator &VNInfoAllocator) {
    246       VNInfo *VNI =
    247         new (VNInfoAllocator) VNInfo((unsigned)valnos.size(), *orig);
    248       valnos.push_back(VNI);
    249       return VNI;
    250     }
    251 
    252     /// RenumberValues - Renumber all values in order of appearance and remove
    253     /// unused values.
    254     void RenumberValues(LiveIntervals &lis);
    255 
    256     /// MergeValueNumberInto - This method is called when two value nubmers
    257     /// are found to be equivalent.  This eliminates V1, replacing all
    258     /// LiveRanges with the V1 value number with the V2 value number.  This can
    259     /// cause merging of V1/V2 values numbers and compaction of the value space.
    260     VNInfo* MergeValueNumberInto(VNInfo *V1, VNInfo *V2);
    261 
    262     /// MergeValueInAsValue - Merge all of the live ranges of a specific val#
    263     /// in RHS into this live interval as the specified value number.
    264     /// The LiveRanges in RHS are allowed to overlap with LiveRanges in the
    265     /// current interval, it will replace the value numbers of the overlaped
    266     /// live ranges with the specified value number.
    267     void MergeRangesInAsValue(const LiveInterval &RHS, VNInfo *LHSValNo);
    268 
    269     /// MergeValueInAsValue - Merge all of the live ranges of a specific val#
    270     /// in RHS into this live interval as the specified value number.
    271     /// The LiveRanges in RHS are allowed to overlap with LiveRanges in the
    272     /// current interval, but only if the overlapping LiveRanges have the
    273     /// specified value number.
    274     void MergeValueInAsValue(const LiveInterval &RHS,
    275                              const VNInfo *RHSValNo, VNInfo *LHSValNo);
    276 
    277     bool empty() const { return ranges.empty(); }
    278 
    279     /// beginIndex - Return the lowest numbered slot covered by interval.
    280     SlotIndex beginIndex() const {
    281       assert(!empty() && "Call to beginIndex() on empty interval.");
    282       return ranges.front().start;
    283     }
    284 
    285     /// endNumber - return the maximum point of the interval of the whole,
    286     /// exclusive.
    287     SlotIndex endIndex() const {
    288       assert(!empty() && "Call to endIndex() on empty interval.");
    289       return ranges.back().end;
    290     }
    291 
    292     bool expiredAt(SlotIndex index) const {
    293       return index >= endIndex();
    294     }
    295 
    296     bool liveAt(SlotIndex index) const {
    297       const_iterator r = find(index);
    298       return r != end() && r->start <= index;
    299     }
    300 
    301     /// killedAt - Return true if a live range ends at index. Note that the kill
    302     /// point is not contained in the half-open live range. It is usually the
    303     /// getDefIndex() slot following its last use.
    304     bool killedAt(SlotIndex index) const {
    305       const_iterator r = find(index.getRegSlot(true));
    306       return r != end() && r->end == index;
    307     }
    308 
    309     /// getLiveRangeContaining - Return the live range that contains the
    310     /// specified index, or null if there is none.
    311     const LiveRange *getLiveRangeContaining(SlotIndex Idx) const {
    312       const_iterator I = FindLiveRangeContaining(Idx);
    313       return I == end() ? 0 : &*I;
    314     }
    315 
    316     /// getLiveRangeContaining - Return the live range that contains the
    317     /// specified index, or null if there is none.
    318     LiveRange *getLiveRangeContaining(SlotIndex Idx) {
    319       iterator I = FindLiveRangeContaining(Idx);
    320       return I == end() ? 0 : &*I;
    321     }
    322 
    323     /// getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
    324     VNInfo *getVNInfoAt(SlotIndex Idx) const {
    325       const_iterator I = FindLiveRangeContaining(Idx);
    326       return I == end() ? 0 : I->valno;
    327     }
    328 
    329     /// getVNInfoBefore - Return the VNInfo that is live up to but not
    330     /// necessarilly including Idx, or NULL. Use this to find the reaching def
    331     /// used by an instruction at this SlotIndex position.
    332     VNInfo *getVNInfoBefore(SlotIndex Idx) const {
    333       const_iterator I = FindLiveRangeContaining(Idx.getPrevSlot());
    334       return I == end() ? 0 : I->valno;
    335     }
    336 
    337     /// FindLiveRangeContaining - Return an iterator to the live range that
    338     /// contains the specified index, or end() if there is none.
    339     iterator FindLiveRangeContaining(SlotIndex Idx) {
    340       iterator I = find(Idx);
    341       return I != end() && I->start <= Idx ? I : end();
    342     }
    343 
    344     const_iterator FindLiveRangeContaining(SlotIndex Idx) const {
    345       const_iterator I = find(Idx);
    346       return I != end() && I->start <= Idx ? I : end();
    347     }
    348 
    349     /// overlaps - Return true if the intersection of the two live intervals is
    350     /// not empty.
    351     bool overlaps(const LiveInterval& other) const {
    352       if (other.empty())
    353         return false;
    354       return overlapsFrom(other, other.begin());
    355     }
    356 
    357     /// overlaps - Return true if the two intervals have overlapping segments
    358     /// that are not coalescable according to CP.
    359     ///
    360     /// Overlapping segments where one interval is defined by a coalescable
    361     /// copy are allowed.
    362     bool overlaps(const LiveInterval &Other, const CoalescerPair &CP,
    363                   const SlotIndexes&) const;
    364 
    365     /// overlaps - Return true if the live interval overlaps a range specified
    366     /// by [Start, End).
    367     bool overlaps(SlotIndex Start, SlotIndex End) const;
    368 
    369     /// overlapsFrom - Return true if the intersection of the two live intervals
    370     /// is not empty.  The specified iterator is a hint that we can begin
    371     /// scanning the Other interval starting at I.
    372     bool overlapsFrom(const LiveInterval& other, const_iterator I) const;
    373 
    374     /// addRange - Add the specified LiveRange to this interval, merging
    375     /// intervals as appropriate.  This returns an iterator to the inserted live
    376     /// range (which may have grown since it was inserted.
    377     iterator addRange(LiveRange LR) {
    378       return addRangeFrom(LR, ranges.begin());
    379     }
    380 
    381     /// extendInBlock - If this interval is live before Kill in the basic block
    382     /// that starts at StartIdx, extend it to be live up to Kill, and return
    383     /// the value. If there is no live range before Kill, return NULL.
    384     VNInfo *extendInBlock(SlotIndex StartIdx, SlotIndex Kill);
    385 
    386     /// join - Join two live intervals (this, and other) together.  This applies
    387     /// mappings to the value numbers in the LHS/RHS intervals as specified.  If
    388     /// the intervals are not joinable, this aborts.
    389     void join(LiveInterval &Other,
    390               const int *ValNoAssignments,
    391               const int *RHSValNoAssignments,
    392               SmallVector<VNInfo*, 16> &NewVNInfo,
    393               MachineRegisterInfo *MRI);
    394 
    395     /// isInOneLiveRange - Return true if the range specified is entirely in the
    396     /// a single LiveRange of the live interval.
    397     bool isInOneLiveRange(SlotIndex Start, SlotIndex End) const {
    398       const_iterator r = find(Start);
    399       return r != end() && r->containsRange(Start, End);
    400     }
    401 
    402     /// removeRange - Remove the specified range from this interval.  Note that
    403     /// the range must be a single LiveRange in its entirety.
    404     void removeRange(SlotIndex Start, SlotIndex End,
    405                      bool RemoveDeadValNo = false);
    406 
    407     void removeRange(LiveRange LR, bool RemoveDeadValNo = false) {
    408       removeRange(LR.start, LR.end, RemoveDeadValNo);
    409     }
    410 
    411     /// removeValNo - Remove all the ranges defined by the specified value#.
    412     /// Also remove the value# from value# list.
    413     void removeValNo(VNInfo *ValNo);
    414 
    415     /// getSize - Returns the sum of sizes of all the LiveRange's.
    416     ///
    417     unsigned getSize() const;
    418 
    419     /// Returns true if the live interval is zero length, i.e. no live ranges
    420     /// span instructions. It doesn't pay to spill such an interval.
    421     bool isZeroLength(SlotIndexes *Indexes) const {
    422       for (const_iterator i = begin(), e = end(); i != e; ++i)
    423         if (Indexes->getNextNonNullIndex(i->start).getBaseIndex() <
    424             i->end.getBaseIndex())
    425           return false;
    426       return true;
    427     }
    428 
    429     /// isSpillable - Can this interval be spilled?
    430     bool isSpillable() const {
    431       return weight != HUGE_VALF;
    432     }
    433 
    434     /// markNotSpillable - Mark interval as not spillable
    435     void markNotSpillable() {
    436       weight = HUGE_VALF;
    437     }
    438 
    439     bool operator<(const LiveInterval& other) const {
    440       const SlotIndex &thisIndex = beginIndex();
    441       const SlotIndex &otherIndex = other.beginIndex();
    442       return (thisIndex < otherIndex ||
    443               (thisIndex == otherIndex && reg < other.reg));
    444     }
    445 
    446     void print(raw_ostream &OS) const;
    447     void dump() const;
    448 
    449     /// \brief Walk the interval and assert if any invariants fail to hold.
    450     ///
    451     /// Note that this is a no-op when asserts are disabled.
    452 #ifdef NDEBUG
    453     void verify() const {}
    454 #else
    455     void verify() const;
    456 #endif
    457 
    458   private:
    459 
    460     Ranges::iterator addRangeFrom(LiveRange LR, Ranges::iterator From);
    461     void extendIntervalEndTo(Ranges::iterator I, SlotIndex NewEnd);
    462     Ranges::iterator extendIntervalStartTo(Ranges::iterator I, SlotIndex NewStr);
    463     void markValNoForDeletion(VNInfo *V);
    464 
    465     LiveInterval& operator=(const LiveInterval& rhs) LLVM_DELETED_FUNCTION;
    466 
    467   };
    468 
    469   inline raw_ostream &operator<<(raw_ostream &OS, const LiveInterval &LI) {
    470     LI.print(OS);
    471     return OS;
    472   }
    473 
    474   /// Helper class for performant LiveInterval bulk updates.
    475   ///
    476   /// Calling LiveInterval::addRange() repeatedly can be expensive on large
    477   /// live ranges because segments after the insertion point may need to be
    478   /// shifted. The LiveRangeUpdater class can defer the shifting when adding
    479   /// many segments in order.
    480   ///
    481   /// The LiveInterval will be in an invalid state until flush() is called.
    482   class LiveRangeUpdater {
    483     LiveInterval *LI;
    484     SlotIndex LastStart;
    485     LiveInterval::iterator WriteI;
    486     LiveInterval::iterator ReadI;
    487     SmallVector<LiveRange, 16> Spills;
    488     void mergeSpills();
    489 
    490   public:
    491     /// Create a LiveRangeUpdater for adding segments to LI.
    492     /// LI will temporarily be in an invalid state until flush() is called.
    493     LiveRangeUpdater(LiveInterval *li = 0) : LI(li) {}
    494 
    495     ~LiveRangeUpdater() { flush(); }
    496 
    497     /// Add a segment to LI and coalesce when possible, just like LI.addRange().
    498     /// Segments should be added in increasing start order for best performance.
    499     void add(LiveRange);
    500 
    501     void add(SlotIndex Start, SlotIndex End, VNInfo *VNI) {
    502       add(LiveRange(Start, End, VNI));
    503     }
    504 
    505     /// Return true if the LI is currently in an invalid state, and flush()
    506     /// needs to be called.
    507     bool isDirty() const { return LastStart.isValid(); }
    508 
    509     /// Flush the updater state to LI so it is valid and contains all added
    510     /// segments.
    511     void flush();
    512 
    513     /// Select a different destination live range.
    514     void setDest(LiveInterval *li) {
    515       if (LI != li && isDirty())
    516         flush();
    517       LI = li;
    518     }
    519 
    520     /// Get the current destination live range.
    521     LiveInterval *getDest() const { return LI; }
    522 
    523     void dump() const;
    524     void print(raw_ostream&) const;
    525   };
    526 
    527   inline raw_ostream &operator<<(raw_ostream &OS, const LiveRangeUpdater &X) {
    528     X.print(OS);
    529     return OS;
    530   }
    531 
    532   /// LiveRangeQuery - Query information about a live range around a given
    533   /// instruction. This class hides the implementation details of live ranges,
    534   /// and it should be used as the primary interface for examining live ranges
    535   /// around instructions.
    536   ///
    537   class LiveRangeQuery {
    538     VNInfo *EarlyVal;
    539     VNInfo *LateVal;
    540     SlotIndex EndPoint;
    541     bool Kill;
    542 
    543   public:
    544     /// Create a LiveRangeQuery for the given live range and instruction index.
    545     /// The sub-instruction slot of Idx doesn't matter, only the instruction it
    546     /// refers to is considered.
    547     LiveRangeQuery(const LiveInterval &LI, SlotIndex Idx)
    548       : EarlyVal(0), LateVal(0), Kill(false) {
    549       // Find the segment that enters the instruction.
    550       LiveInterval::const_iterator I = LI.find(Idx.getBaseIndex());
    551       LiveInterval::const_iterator E = LI.end();
    552       if (I == E)
    553         return;
    554       // Is this an instruction live-in segment?
    555       // If Idx is the start index of a basic block, include live-in segments
    556       // that start at Idx.getBaseIndex().
    557       if (I->start <= Idx.getBaseIndex()) {
    558         EarlyVal = I->valno;
    559         EndPoint = I->end;
    560         // Move to the potentially live-out segment.
    561         if (SlotIndex::isSameInstr(Idx, I->end)) {
    562           Kill = true;
    563           if (++I == E)
    564             return;
    565         }
    566         // Special case: A PHIDef value can have its def in the middle of a
    567         // segment if the value happens to be live out of the layout
    568         // predecessor.
    569         // Such a value is not live-in.
    570         if (EarlyVal->def == Idx.getBaseIndex())
    571           EarlyVal = 0;
    572       }
    573       // I now points to the segment that may be live-through, or defined by
    574       // this instr. Ignore segments starting after the current instr.
    575       if (SlotIndex::isEarlierInstr(Idx, I->start))
    576         return;
    577       LateVal = I->valno;
    578       EndPoint = I->end;
    579     }
    580 
    581     /// Return the value that is live-in to the instruction. This is the value
    582     /// that will be read by the instruction's use operands. Return NULL if no
    583     /// value is live-in.
    584     VNInfo *valueIn() const {
    585       return EarlyVal;
    586     }
    587 
    588     /// Return true if the live-in value is killed by this instruction. This
    589     /// means that either the live range ends at the instruction, or it changes
    590     /// value.
    591     bool isKill() const {
    592       return Kill;
    593     }
    594 
    595     /// Return true if this instruction has a dead def.
    596     bool isDeadDef() const {
    597       return EndPoint.isDead();
    598     }
    599 
    600     /// Return the value leaving the instruction, if any. This can be a
    601     /// live-through value, or a live def. A dead def returns NULL.
    602     VNInfo *valueOut() const {
    603       return isDeadDef() ? 0 : LateVal;
    604     }
    605 
    606     /// Return the value defined by this instruction, if any. This includes
    607     /// dead defs, it is the value created by the instruction's def operands.
    608     VNInfo *valueDefined() const {
    609       return EarlyVal == LateVal ? 0 : LateVal;
    610     }
    611 
    612     /// Return the end point of the last live range segment to interact with
    613     /// the instruction, if any.
    614     ///
    615     /// The end point is an invalid SlotIndex only if the live range doesn't
    616     /// intersect the instruction at all.
    617     ///
    618     /// The end point may be at or past the end of the instruction's basic
    619     /// block. That means the value was live out of the block.
    620     SlotIndex endPoint() const {
    621       return EndPoint;
    622     }
    623   };
    624 
    625   /// ConnectedVNInfoEqClasses - Helper class that can divide VNInfos in a
    626   /// LiveInterval into equivalence clases of connected components. A
    627   /// LiveInterval that has multiple connected components can be broken into
    628   /// multiple LiveIntervals.
    629   ///
    630   /// Given a LiveInterval that may have multiple connected components, run:
    631   ///
    632   ///   unsigned numComps = ConEQ.Classify(LI);
    633   ///   if (numComps > 1) {
    634   ///     // allocate numComps-1 new LiveIntervals into LIS[1..]
    635   ///     ConEQ.Distribute(LIS);
    636   /// }
    637 
    638   class ConnectedVNInfoEqClasses {
    639     LiveIntervals &LIS;
    640     IntEqClasses EqClass;
    641 
    642     // Note that values a and b are connected.
    643     void Connect(unsigned a, unsigned b);
    644 
    645     unsigned Renumber();
    646 
    647   public:
    648     explicit ConnectedVNInfoEqClasses(LiveIntervals &lis) : LIS(lis) {}
    649 
    650     /// Classify - Classify the values in LI into connected components.
    651     /// Return the number of connected components.
    652     unsigned Classify(const LiveInterval *LI);
    653 
    654     /// getEqClass - Classify creates equivalence classes numbered 0..N. Return
    655     /// the equivalence class assigned the VNI.
    656     unsigned getEqClass(const VNInfo *VNI) const { return EqClass[VNI->id]; }
    657 
    658     /// Distribute - Distribute values in LIV[0] into a separate LiveInterval
    659     /// for each connected component. LIV must have a LiveInterval for each
    660     /// connected component. The LiveIntervals in Liv[1..] must be empty.
    661     /// Instructions using LIV[0] are rewritten.
    662     void Distribute(LiveInterval *LIV[], MachineRegisterInfo &MRI);
    663 
    664   };
    665 
    666 }
    667 #endif
    668