Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 1 | //===-- LiveIntervalUnion.cpp - Live interval union data structure --------===// |
| 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 | // LiveIntervalUnion represents a coalesced set of live intervals. This may be |
| 11 | // used during coalescing to represent a congruence class, or during register |
| 12 | // allocation to model liveness of a physical register. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #define DEBUG_TYPE "regalloc" |
| 17 | #include "LiveIntervalUnion.h" |
Andrew Trick | 071d1c0 | 2010-11-09 21:04:34 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/SparseBitVector.h" |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 19 | #include "llvm/Support/Debug.h" |
| 20 | #include "llvm/Support/raw_ostream.h" |
| 21 | #include <algorithm> |
| 22 | using namespace llvm; |
| 23 | |
Andrew Trick | e141a49 | 2010-11-08 18:02:08 +0000 | [diff] [blame] | 24 | |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 25 | // Merge a LiveInterval's segments. Guarantee no overlaps. |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 26 | void LiveIntervalUnion::unify(LiveInterval &VirtReg) { |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 27 | if (VirtReg.empty()) |
| 28 | return; |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 29 | |
| 30 | // Insert each of the virtual register's live segments into the map. |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 31 | LiveInterval::iterator RegPos = VirtReg.begin(); |
| 32 | LiveInterval::iterator RegEnd = VirtReg.end(); |
| 33 | SegmentIter SegPos = Segments.find(RegPos->start); |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 34 | |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 35 | for (;;) { |
| 36 | SegPos.insert(RegPos->start, RegPos->end, &VirtReg); |
| 37 | if (++RegPos == RegEnd) |
| 38 | return; |
| 39 | SegPos.advanceTo(RegPos->start); |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 40 | } |
| 41 | } |
| 42 | |
Andrew Trick | e141a49 | 2010-11-08 18:02:08 +0000 | [diff] [blame] | 43 | // Remove a live virtual register's segments from this union. |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 44 | void LiveIntervalUnion::extract(LiveInterval &VirtReg) { |
| 45 | if (VirtReg.empty()) |
| 46 | return; |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 47 | |
Andrew Trick | e141a49 | 2010-11-08 18:02:08 +0000 | [diff] [blame] | 48 | // Remove each of the virtual register's live segments from the map. |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 49 | LiveInterval::iterator RegPos = VirtReg.begin(); |
| 50 | LiveInterval::iterator RegEnd = VirtReg.end(); |
| 51 | SegmentIter SegPos = Segments.find(RegPos->start); |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 52 | |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 53 | for (;;) { |
| 54 | assert(SegPos.value() == &VirtReg && "Inconsistent LiveInterval"); |
| 55 | SegPos.erase(); |
| 56 | if (!SegPos.valid()) |
| 57 | return; |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 58 | |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 59 | // Skip all segments that may have been coalesced. |
| 60 | RegPos = VirtReg.advanceTo(RegPos, SegPos.start()); |
| 61 | if (RegPos == RegEnd) |
| 62 | return; |
| 63 | |
| 64 | SegPos.advanceTo(RegPos->start); |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 65 | } |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 66 | } |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 67 | |
Andrew Trick | 071d1c0 | 2010-11-09 21:04:34 +0000 | [diff] [blame] | 68 | void |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 69 | LiveIntervalUnion::print(raw_ostream &OS, |
| 70 | const AbstractRegisterDescription *RegDesc) const { |
| 71 | OS << "LIU "; |
| 72 | if (RegDesc != NULL) |
| 73 | OS << RegDesc->getName(RepReg); |
Andrew Trick | 071d1c0 | 2010-11-09 21:04:34 +0000 | [diff] [blame] | 74 | else { |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 75 | OS << RepReg; |
Andrew Trick | 071d1c0 | 2010-11-09 21:04:34 +0000 | [diff] [blame] | 76 | } |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 77 | for (LiveSegments::const_iterator SI = Segments.begin(); SI.valid(); ++SI) |
| 78 | dbgs() << " [" << SI.start() << ' ' << SI.stop() << "):%reg" |
| 79 | << SI.value()->reg; |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 80 | OS << "\n"; |
Andrew Trick | 071d1c0 | 2010-11-09 21:04:34 +0000 | [diff] [blame] | 81 | } |
| 82 | |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 83 | void LiveIntervalUnion::dump(const AbstractRegisterDescription *RegDesc) const { |
| 84 | print(dbgs(), RegDesc); |
Andrew Trick | 071d1c0 | 2010-11-09 21:04:34 +0000 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | #ifndef NDEBUG |
| 88 | // Verify the live intervals in this union and add them to the visited set. |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 89 | void LiveIntervalUnion::verify(LiveVirtRegBitSet& VisitedVRegs) { |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 90 | for (SegmentIter SI = Segments.begin(); SI.valid(); ++SI) |
| 91 | VisitedVRegs.set(SI.value()->reg); |
Andrew Trick | 071d1c0 | 2010-11-09 21:04:34 +0000 | [diff] [blame] | 92 | } |
| 93 | #endif //!NDEBUG |
| 94 | |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 95 | // Private interface accessed by Query. |
| 96 | // |
| 97 | // Find a pair of segments that intersect, one in the live virtual register |
| 98 | // (LiveInterval), and the other in this LiveIntervalUnion. The caller (Query) |
| 99 | // is responsible for advancing the LiveIntervalUnion segments to find a |
| 100 | // "notable" intersection, which requires query-specific logic. |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 101 | // |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 102 | // This design assumes only a fast mechanism for intersecting a single live |
| 103 | // virtual register segment with a set of LiveIntervalUnion segments. This may |
Andrew Trick | 34fff59 | 2010-11-30 23:59:50 +0000 | [diff] [blame] | 104 | // be ok since most virtual registers have very few segments. If we had a data |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 105 | // structure that optimizd MxN intersection of segments, then we would bypass |
| 106 | // the loop that advances within the LiveInterval. |
| 107 | // |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 108 | // If no intersection exists, set VirtRegI = VirtRegEnd, and set SI to the first |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 109 | // segment whose start point is greater than LiveInterval's end point. |
| 110 | // |
| 111 | // Assumes that segments are sorted by start position in both |
| 112 | // LiveInterval and LiveSegments. |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 113 | void LiveIntervalUnion::Query::findIntersection(InterferenceResult &IR) const { |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 114 | // Search until reaching the end of the LiveUnion segments. |
| 115 | LiveInterval::iterator VirtRegEnd = VirtReg->end(); |
Jakob Stoklund Olesen | 9b0c4f8 | 2010-12-08 23:51:35 +0000 | [diff] [blame] | 116 | if (IR.VirtRegI == VirtRegEnd) |
| 117 | return; |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 118 | while (IR.LiveUnionI.valid()) { |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 119 | // Slowly advance the live virtual reg iterator until we surpass the next |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 120 | // segment in LiveUnion. |
| 121 | // |
| 122 | // Note: If this is ever used for coalescing of fixed registers and we have |
| 123 | // a live vreg with thousands of segments, then change this code to use |
| 124 | // upperBound instead. |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 125 | IR.VirtRegI = VirtReg->advanceTo(IR.VirtRegI, IR.LiveUnionI.start()); |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 126 | if (IR.VirtRegI == VirtRegEnd) |
| 127 | break; // Retain current (nonoverlapping) LiveUnionI |
| 128 | |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 129 | // VirtRegI may have advanced far beyond LiveUnionI, catch up. |
| 130 | IR.LiveUnionI.advanceTo(IR.VirtRegI->start); |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 131 | |
| 132 | // Check if no LiveUnionI exists with VirtRegI->Start < LiveUnionI.end |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 133 | if (!IR.LiveUnionI.valid()) |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 134 | break; |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 135 | if (IR.LiveUnionI.start() < IR.VirtRegI->end) { |
| 136 | assert(overlap(*IR.VirtRegI, IR.LiveUnionI) && |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 137 | "upperBound postcondition"); |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 138 | break; |
| 139 | } |
| 140 | } |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 141 | if (!IR.LiveUnionI.valid()) |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 142 | IR.VirtRegI = VirtRegEnd; |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | // Find the first intersection, and cache interference info |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 146 | // (retain segment iterators into both VirtReg and LiveUnion). |
Jakob Stoklund Olesen | a35cce1 | 2010-12-09 01:06:52 +0000 | [diff] [blame] | 147 | const LiveIntervalUnion::InterferenceResult & |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 148 | LiveIntervalUnion::Query::firstInterference() { |
Jakob Stoklund Olesen | a35cce1 | 2010-12-09 01:06:52 +0000 | [diff] [blame] | 149 | if (CheckedFirstInterference) |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 150 | return FirstInterference; |
Jakob Stoklund Olesen | a35cce1 | 2010-12-09 01:06:52 +0000 | [diff] [blame] | 151 | CheckedFirstInterference = true; |
| 152 | InterferenceResult &IR = FirstInterference; |
| 153 | |
| 154 | // Quickly skip interference check for empty sets. |
| 155 | if (VirtReg->empty() || LiveUnion->empty()) { |
| 156 | IR.VirtRegI = VirtReg->end(); |
| 157 | } else if (VirtReg->beginIndex() < LiveUnion->startIndex()) { |
| 158 | // VirtReg starts first, perform double binary search. |
| 159 | IR.VirtRegI = VirtReg->find(LiveUnion->startIndex()); |
| 160 | if (IR.VirtRegI != VirtReg->end()) |
| 161 | IR.LiveUnionI = LiveUnion->find(IR.VirtRegI->start); |
| 162 | } else { |
| 163 | // LiveUnion starts first, perform double binary search. |
| 164 | IR.LiveUnionI = LiveUnion->find(VirtReg->beginIndex()); |
| 165 | if (IR.LiveUnionI.valid()) |
| 166 | IR.VirtRegI = VirtReg->find(IR.LiveUnionI.start()); |
| 167 | else |
| 168 | IR.VirtRegI = VirtReg->end(); |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 169 | } |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 170 | findIntersection(FirstInterference); |
| 171 | return FirstInterference; |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | // Treat the result as an iterator and advance to the next interfering pair |
| 175 | // of segments. This is a plain iterator with no filter. |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 176 | bool LiveIntervalUnion::Query::nextInterference(InterferenceResult &IR) const { |
| 177 | assert(isInterference(IR) && "iteration past end of interferences"); |
| 178 | |
| 179 | // Advance either the VirtReg or LiveUnion segment to ensure that we visit all |
| 180 | // unique overlapping pairs. |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 181 | if (IR.VirtRegI->end < IR.LiveUnionI.stop()) { |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 182 | if (++IR.VirtRegI == VirtReg->end()) |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 183 | return false; |
| 184 | } |
| 185 | else { |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 186 | if (!(++IR.LiveUnionI).valid()) { |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 187 | IR.VirtRegI = VirtReg->end(); |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 188 | return false; |
| 189 | } |
| 190 | } |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 191 | // Short-circuit findIntersection() if possible. |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 192 | if (overlap(*IR.VirtRegI, IR.LiveUnionI)) |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 193 | return true; |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 194 | |
| 195 | // Find the next intersection. |
| 196 | findIntersection(IR); |
| 197 | return isInterference(IR); |
Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 198 | } |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 199 | |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 200 | // Scan the vector of interfering virtual registers in this union. Assume it's |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 201 | // quite small. |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 202 | bool LiveIntervalUnion::Query::isSeenInterference(LiveInterval *VirtReg) const { |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 203 | SmallVectorImpl<LiveInterval*>::const_iterator I = |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 204 | std::find(InterferingVRegs.begin(), InterferingVRegs.end(), VirtReg); |
| 205 | return I != InterferingVRegs.end(); |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | // Count the number of virtual registers in this union that interfere with this |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 209 | // query's live virtual register. |
| 210 | // |
| 211 | // The number of times that we either advance IR.VirtRegI or call |
| 212 | // LiveUnion.upperBound() will be no more than the number of holes in |
| 213 | // VirtReg. So each invocation of collectInterferingVRegs() takes |
| 214 | // time proportional to |VirtReg Holes| * time(LiveUnion.upperBound()). |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 215 | // |
| 216 | // For comments on how to speed it up, see Query::findIntersection(). |
| 217 | unsigned LiveIntervalUnion::Query:: |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 218 | collectInterferingVRegs(unsigned MaxInterferingRegs) { |
| 219 | InterferenceResult IR = firstInterference(); |
| 220 | LiveInterval::iterator VirtRegEnd = VirtReg->end(); |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 221 | LiveInterval *RecentInterferingVReg = NULL; |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 222 | while (IR.LiveUnionI.valid()) { |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 223 | // Advance the union's iterator to reach an unseen interfering vreg. |
| 224 | do { |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 225 | if (IR.LiveUnionI.value() == RecentInterferingVReg) |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 226 | continue; |
| 227 | |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 228 | if (!isSeenInterference(IR.LiveUnionI.value())) |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 229 | break; |
| 230 | |
| 231 | // Cache the most recent interfering vreg to bypass isSeenInterference. |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 232 | RecentInterferingVReg = IR.LiveUnionI.value(); |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 233 | |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 234 | } while ((++IR.LiveUnionI).valid()); |
| 235 | if (!IR.LiveUnionI.valid()) |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 236 | break; |
| 237 | |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 238 | // Advance the VirtReg iterator until surpassing the next segment in |
| 239 | // LiveUnion. |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 240 | IR.VirtRegI = VirtReg->advanceTo(IR.VirtRegI, IR.LiveUnionI.start()); |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 241 | if (IR.VirtRegI == VirtRegEnd) |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 242 | break; |
| 243 | |
| 244 | // Check for intersection with the union's segment. |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 245 | if (overlap(*IR.VirtRegI, IR.LiveUnionI)) { |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 246 | |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 247 | if (!IR.LiveUnionI.value()->isSpillable()) |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 248 | SeenUnspillableVReg = true; |
| 249 | |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 250 | if (InterferingVRegs.size() == MaxInterferingRegs) |
Andrew Trick | b853e6c | 2010-12-09 18:15:21 +0000 | [diff] [blame^] | 251 | // Leave SeenAllInterferences set to false to indicate that at least one |
| 252 | // interference exists beyond those we collected. |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 253 | return MaxInterferingRegs; |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 254 | |
Andrew Trick | b853e6c | 2010-12-09 18:15:21 +0000 | [diff] [blame^] | 255 | InterferingVRegs.push_back(IR.LiveUnionI.value()); |
| 256 | |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 257 | // Cache the most recent interfering vreg to bypass isSeenInterference. |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 258 | RecentInterferingVReg = IR.LiveUnionI.value(); |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 259 | ++IR.LiveUnionI; |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 260 | continue; |
| 261 | } |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 262 | // VirtRegI may have advanced far beyond LiveUnionI, |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 263 | // do a fast intersection test to "catch up" |
Jakob Stoklund Olesen | 953af2c | 2010-12-07 23:18:47 +0000 | [diff] [blame] | 264 | IR.LiveUnionI.advanceTo(IR.VirtRegI->start); |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 265 | } |
Andrew Trick | 18c57a8 | 2010-11-30 23:18:47 +0000 | [diff] [blame] | 266 | SeenAllInterferences = true; |
| 267 | return InterferingVRegs.size(); |
Andrew Trick | f4baeaf | 2010-11-10 19:18:47 +0000 | [diff] [blame] | 268 | } |