blob: 0a6cb2d3411f812ffd3f2f85e225caa65a4824df [file] [log] [blame]
Chris Lattnera3b8b5c2004-07-23 17:56:30 +00001//===-- LiveIntervalAnalysis.cpp - Live Interval Analysis -----------------===//
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the LiveInterval analysis pass which is used
11// by the Linear Scan Register allocator. This pass linearizes the
12// basic blocks of the function in DFS order and uses the
13// LiveVariables pass to conservatively compute live intervals for
14// each virtual and physical register.
15//
16//===----------------------------------------------------------------------===//
17
18#define DEBUG_TYPE "liveintervals"
Chris Lattnera3b8b5c2004-07-23 17:56:30 +000019#include "LiveIntervalAnalysis.h"
Misha Brukman08a6c762004-09-03 18:25:53 +000020#include "VirtRegMap.h"
Chris Lattner015959e2004-05-01 21:24:39 +000021#include "llvm/Value.h"
Alkis Evlogimenos6b4edba2003-12-21 20:19:10 +000022#include "llvm/Analysis/LoopInfo.h"
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +000023#include "llvm/CodeGen/LiveVariables.h"
24#include "llvm/CodeGen/MachineFrameInfo.h"
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +000025#include "llvm/CodeGen/MachineInstr.h"
26#include "llvm/CodeGen/Passes.h"
27#include "llvm/CodeGen/SSARegMap.h"
28#include "llvm/Target/MRegisterInfo.h"
29#include "llvm/Target/TargetInstrInfo.h"
30#include "llvm/Target/TargetMachine.h"
Reid Spencer551ccae2004-09-01 22:55:40 +000031#include "llvm/Support/CommandLine.h"
32#include "llvm/Support/Debug.h"
33#include "llvm/ADT/Statistic.h"
34#include "llvm/ADT/STLExtras.h"
Alkis Evlogimenos20aa4742004-09-03 18:19:51 +000035#include <algorithm>
Misha Brukman08a6c762004-09-03 18:25:53 +000036#include <cmath>
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +000037using namespace llvm;
38
39namespace {
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000040 RegisterAnalysis<LiveIntervals> X("liveintervals", "Live Interval Analysis");
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +000041
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000042 Statistic<> numIntervals
43 ("liveintervals", "Number of original intervals");
Alkis Evlogimenos007726c2004-02-20 20:53:26 +000044
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000045 Statistic<> numIntervalsAfter
46 ("liveintervals", "Number of intervals after coalescing");
Alkis Evlogimenos007726c2004-02-20 20:53:26 +000047
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000048 Statistic<> numJoins
49 ("liveintervals", "Number of interval joins performed");
Alkis Evlogimenos007726c2004-02-20 20:53:26 +000050
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000051 Statistic<> numPeep
52 ("liveintervals", "Number of identity moves eliminated after coalescing");
Alkis Evlogimenos007726c2004-02-20 20:53:26 +000053
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000054 Statistic<> numFolded
55 ("liveintervals", "Number of loads/stores folded into instructions");
Alkis Evlogimenos007726c2004-02-20 20:53:26 +000056
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000057 cl::opt<bool>
58 EnableJoining("join-liveintervals",
59 cl::desc("Join compatible live intervals"),
60 cl::init(true));
Chris Lattnerf768bba2005-03-09 23:05:19 +000061 cl::opt<bool>
62 DisableHack("disable-hack");
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +000063};
64
65void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const
66{
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000067 AU.addPreserved<LiveVariables>();
68 AU.addRequired<LiveVariables>();
69 AU.addPreservedID(PHIEliminationID);
70 AU.addRequiredID(PHIEliminationID);
71 AU.addRequiredID(TwoAddressInstructionPassID);
72 AU.addRequired<LoopInfo>();
73 MachineFunctionPass::getAnalysisUsage(AU);
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +000074}
75
Alkis Evlogimenos08cec002004-01-31 19:59:32 +000076void LiveIntervals::releaseMemory()
77{
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000078 mi2iMap_.clear();
79 i2miMap_.clear();
80 r2iMap_.clear();
81 r2rMap_.clear();
Alkis Evlogimenos08cec002004-01-31 19:59:32 +000082}
83
84
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +000085/// runOnMachineFunction - Register allocate the whole function
86///
87bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000088 mf_ = &fn;
89 tm_ = &fn.getTarget();
90 mri_ = tm_->getRegisterInfo();
Chris Lattnerf768bba2005-03-09 23:05:19 +000091 tii_ = tm_->getInstrInfo();
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000092 lv_ = &getAnalysis<LiveVariables>();
Alkis Evlogimenos53278012004-08-26 22:22:38 +000093 allocatableRegs_ = mri_->getAllocatableSet(fn);
Alkis Evlogimenos2c4f7b52004-09-09 19:24:38 +000094 r2rMap_.grow(mf_->getSSARegMap()->getLastVirtReg());
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +000095
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +000096 // number MachineInstrs
97 unsigned miIndex = 0;
98 for (MachineFunction::iterator mbb = mf_->begin(), mbbEnd = mf_->end();
99 mbb != mbbEnd; ++mbb)
100 for (MachineBasicBlock::iterator mi = mbb->begin(), miEnd = mbb->end();
101 mi != miEnd; ++mi) {
102 bool inserted = mi2iMap_.insert(std::make_pair(mi, miIndex)).second;
103 assert(inserted && "multiple MachineInstr -> index mappings");
104 i2miMap_.push_back(mi);
105 miIndex += InstrSlots::NUM;
Alkis Evlogimenos843b1602004-02-15 10:24:21 +0000106 }
Alkis Evlogimenosd6e40a62004-01-14 10:44:29 +0000107
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000108 computeIntervals();
Alkis Evlogimenos843b1602004-02-15 10:24:21 +0000109
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000110 numIntervals += getNumIntervals();
111
112#if 1
113 DEBUG(std::cerr << "********** INTERVALS **********\n");
114 DEBUG(for (iterator I = begin(), E = end(); I != E; ++I)
115 std::cerr << I->second << "\n");
116#endif
117
118 // join intervals if requested
119 if (EnableJoining) joinIntervals();
120
121 numIntervalsAfter += getNumIntervals();
122
123 // perform a final pass over the instructions and compute spill
124 // weights, coalesce virtual registers and remove identity moves
125 const LoopInfo& loopInfo = getAnalysis<LoopInfo>();
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000126
127 for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end();
128 mbbi != mbbe; ++mbbi) {
129 MachineBasicBlock* mbb = mbbi;
130 unsigned loopDepth = loopInfo.getLoopDepth(mbb->getBasicBlock());
131
132 for (MachineBasicBlock::iterator mii = mbb->begin(), mie = mbb->end();
133 mii != mie; ) {
134 // if the move will be an identity move delete it
135 unsigned srcReg, dstReg, RegRep;
Chris Lattnerf768bba2005-03-09 23:05:19 +0000136 if (tii_->isMoveInstr(*mii, srcReg, dstReg) &&
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000137 (RegRep = rep(srcReg)) == rep(dstReg)) {
138 // remove from def list
139 LiveInterval &interval = getOrCreateInterval(RegRep);
140 // remove index -> MachineInstr and
141 // MachineInstr -> index mappings
142 Mi2IndexMap::iterator mi2i = mi2iMap_.find(mii);
143 if (mi2i != mi2iMap_.end()) {
144 i2miMap_[mi2i->second/InstrSlots::NUM] = 0;
145 mi2iMap_.erase(mi2i);
146 }
147 mii = mbbi->erase(mii);
148 ++numPeep;
149 }
150 else {
151 for (unsigned i = 0; i < mii->getNumOperands(); ++i) {
152 const MachineOperand& mop = mii->getOperand(i);
153 if (mop.isRegister() && mop.getReg() &&
154 MRegisterInfo::isVirtualRegister(mop.getReg())) {
155 // replace register with representative register
156 unsigned reg = rep(mop.getReg());
157 mii->SetMachineOperandReg(i, reg);
158
159 LiveInterval &RegInt = getInterval(reg);
160 RegInt.weight +=
Chris Lattner7a36ae82004-10-25 18:40:47 +0000161 (mop.isUse() + mop.isDef()) * pow(10.0F, (int)loopDepth);
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000162 }
163 }
164 ++mii;
165 }
166 }
167 }
168
Chris Lattner70ca3582004-09-30 15:59:17 +0000169 DEBUG(dump());
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000170 return true;
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000171}
172
Chris Lattner70ca3582004-09-30 15:59:17 +0000173/// print - Implement the dump method.
Reid Spencerce9653c2004-12-07 04:03:45 +0000174void LiveIntervals::print(std::ostream &O, const Module* ) const {
Chris Lattner70ca3582004-09-30 15:59:17 +0000175 O << "********** INTERVALS **********\n";
176 for (const_iterator I = begin(), E = end(); I != E; ++I)
Chris Lattneref054362004-10-01 19:01:39 +0000177 O << " " << I->second << "\n";
Chris Lattner70ca3582004-09-30 15:59:17 +0000178
179 O << "********** MACHINEINSTRS **********\n";
180 for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end();
181 mbbi != mbbe; ++mbbi) {
182 O << ((Value*)mbbi->getBasicBlock())->getName() << ":\n";
183 for (MachineBasicBlock::iterator mii = mbbi->begin(),
184 mie = mbbi->end(); mii != mie; ++mii) {
Chris Lattner477e4552004-09-30 16:10:45 +0000185 O << getInstructionIndex(mii) << '\t' << *mii;
Chris Lattner70ca3582004-09-30 15:59:17 +0000186 }
187 }
188}
189
Chris Lattner70ca3582004-09-30 15:59:17 +0000190std::vector<LiveInterval*> LiveIntervals::
191addIntervalsForSpills(const LiveInterval &li, VirtRegMap &vrm, int slot) {
Alkis Evlogimenosd8d26b32004-08-27 18:59:22 +0000192 // since this is called after the analysis is done we don't know if
193 // LiveVariables is available
194 lv_ = getAnalysisToUpdate<LiveVariables>();
195
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000196 std::vector<LiveInterval*> added;
Alkis Evlogimenos26f5a692004-05-30 07:24:39 +0000197
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000198 assert(li.weight != HUGE_VAL &&
199 "attempt to spill already spilled interval!");
Alkis Evlogimenos843b1602004-02-15 10:24:21 +0000200
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000201 DEBUG(std::cerr << "\t\t\t\tadding intervals for spills for interval: "
202 << li << '\n');
Alkis Evlogimenos39a0d5c2004-02-20 06:15:40 +0000203
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000204 const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(li.reg);
Alkis Evlogimenos26f5a692004-05-30 07:24:39 +0000205
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000206 for (LiveInterval::Ranges::const_iterator
207 i = li.ranges.begin(), e = li.ranges.end(); i != e; ++i) {
208 unsigned index = getBaseIndex(i->start);
209 unsigned end = getBaseIndex(i->end-1) + InstrSlots::NUM;
210 for (; index != end; index += InstrSlots::NUM) {
211 // skip deleted instructions
212 while (index != end && !getInstructionFromIndex(index))
213 index += InstrSlots::NUM;
214 if (index == end) break;
Chris Lattner8640f4e2004-07-19 15:16:53 +0000215
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000216 MachineBasicBlock::iterator mi = getInstructionFromIndex(index);
Alkis Evlogimenos39a0d5c2004-02-20 06:15:40 +0000217
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000218 for_operand:
219 for (unsigned i = 0; i != mi->getNumOperands(); ++i) {
220 MachineOperand& mop = mi->getOperand(i);
221 if (mop.isRegister() && mop.getReg() == li.reg) {
Chris Lattner477e4552004-09-30 16:10:45 +0000222 // First thing, attempt to fold the memory reference into the
223 // instruction. If we can do this, we don't need to insert spill
224 // code.
Alkis Evlogimenosd8d26b32004-08-27 18:59:22 +0000225 if (MachineInstr* fmi = mri_->foldMemoryOperand(mi, i, slot)) {
226 if (lv_)
227 lv_->instructionChanged(mi, fmi);
Chris Lattnerbec6a9e2004-10-01 23:15:36 +0000228 vrm.virtFolded(li.reg, mi, i, fmi);
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000229 mi2iMap_.erase(mi);
230 i2miMap_[index/InstrSlots::NUM] = fmi;
231 mi2iMap_[fmi] = index;
Chris Lattner477e4552004-09-30 16:10:45 +0000232 MachineBasicBlock &MBB = *mi->getParent();
233 mi = MBB.insert(MBB.erase(mi), fmi);
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000234 ++numFolded;
Chris Lattner477e4552004-09-30 16:10:45 +0000235
236 // Folding the load/store can completely change the instruction in
237 // unpredictable ways, rescan it from the beginning.
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000238 goto for_operand;
Chris Lattner477e4552004-09-30 16:10:45 +0000239 } else {
Chris Lattner70ca3582004-09-30 15:59:17 +0000240 // This is tricky. We need to add information in the interval about
241 // the spill code so we have to use our extra load/store slots.
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000242 //
Chris Lattner70ca3582004-09-30 15:59:17 +0000243 // If we have a use we are going to have a load so we start the
244 // interval from the load slot onwards. Otherwise we start from the
245 // def slot.
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000246 unsigned start = (mop.isUse() ?
247 getLoadIndex(index) :
248 getDefIndex(index));
Chris Lattner70ca3582004-09-30 15:59:17 +0000249 // If we have a def we are going to have a store right after it so
250 // we end the interval after the use of the next
251 // instruction. Otherwise we end after the use of this instruction.
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000252 unsigned end = 1 + (mop.isDef() ?
253 getStoreIndex(index) :
254 getUseIndex(index));
Alkis Evlogimenos26f5a692004-05-30 07:24:39 +0000255
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000256 // create a new register for this spill
Alkis Evlogimenosd8d26b32004-08-27 18:59:22 +0000257 unsigned nReg = mf_->getSSARegMap()->createVirtualRegister(rc);
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000258 mi->SetMachineOperandReg(i, nReg);
259 vrm.grow();
260 vrm.assignVirt2StackSlot(nReg, slot);
261 LiveInterval& nI = getOrCreateInterval(nReg);
262 assert(nI.empty());
Chris Lattner70ca3582004-09-30 15:59:17 +0000263
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000264 // the spill weight is now infinity as it
265 // cannot be spilled again
Chris Lattner28696be2005-01-08 19:55:00 +0000266 nI.weight = float(HUGE_VAL);
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000267 LiveRange LR(start, end, nI.getNextValue());
268 DEBUG(std::cerr << " +" << LR);
269 nI.addRange(LR);
270 added.push_back(&nI);
Chris Lattner70ca3582004-09-30 15:59:17 +0000271
Alkis Evlogimenosd8d26b32004-08-27 18:59:22 +0000272 // update live variables if it is available
273 if (lv_)
274 lv_->addVirtualRegisterKilled(nReg, mi);
275 DEBUG(std::cerr << "\t\t\t\tadded new interval: " << nI << '\n');
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000276 }
Alkis Evlogimenos843b1602004-02-15 10:24:21 +0000277 }
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000278 }
Alkis Evlogimenos843b1602004-02-15 10:24:21 +0000279 }
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000280 }
Alkis Evlogimenos26f5a692004-05-30 07:24:39 +0000281
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000282 return added;
Alkis Evlogimenos843b1602004-02-15 10:24:21 +0000283}
284
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000285void LiveIntervals::printRegName(unsigned reg) const
286{
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000287 if (MRegisterInfo::isPhysicalRegister(reg))
288 std::cerr << mri_->getName(reg);
289 else
290 std::cerr << "%reg" << reg;
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000291}
292
293void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock* mbb,
294 MachineBasicBlock::iterator mi,
Chris Lattner418da552004-06-21 13:10:56 +0000295 LiveInterval& interval)
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000296{
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000297 DEBUG(std::cerr << "\t\tregister: "; printRegName(interval.reg));
298 LiveVariables::VarInfo& vi = lv_->getVarInfo(interval.reg);
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000299
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000300 // Virtual registers may be defined multiple times (due to phi
301 // elimination and 2-addr elimination). Much of what we do only has to be
302 // done once for the vreg. We use an empty interval to detect the first
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000303 // time we see a vreg.
304 if (interval.empty()) {
305 // Get the Idx of the defining instructions.
306 unsigned defIndex = getDefIndex(getInstructionIndex(mi));
Chris Lattner6097d132004-07-19 02:15:56 +0000307
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000308 unsigned ValNum = interval.getNextValue();
309 assert(ValNum == 0 && "First value in interval is not 0?");
310 ValNum = 0; // Clue in the optimizer.
Chris Lattner7ac2d312004-07-24 02:59:07 +0000311
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000312 // Loop over all of the blocks that the vreg is defined in. There are
313 // two cases we have to handle here. The most common case is a vreg
314 // whose lifetime is contained within a basic block. In this case there
315 // will be a single kill, in MBB, which comes after the definition.
316 if (vi.Kills.size() == 1 && vi.Kills[0]->getParent() == mbb) {
317 // FIXME: what about dead vars?
318 unsigned killIdx;
319 if (vi.Kills[0] != mi)
320 killIdx = getUseIndex(getInstructionIndex(vi.Kills[0]))+1;
321 else
322 killIdx = defIndex+1;
Chris Lattner6097d132004-07-19 02:15:56 +0000323
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000324 // If the kill happens after the definition, we have an intra-block
325 // live range.
326 if (killIdx > defIndex) {
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000327 assert(vi.AliveBlocks.empty() &&
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000328 "Shouldn't be alive across any blocks!");
329 LiveRange LR(defIndex, killIdx, ValNum);
330 interval.addRange(LR);
331 DEBUG(std::cerr << " +" << LR << "\n");
332 return;
333 }
Alkis Evlogimenosdd2cc652003-12-18 08:48:48 +0000334 }
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000335
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000336 // The other case we handle is when a virtual register lives to the end
337 // of the defining block, potentially live across some blocks, then is
338 // live into some number of blocks, but gets killed. Start by adding a
339 // range that goes from this definition to the end of the defining block.
Alkis Evlogimenosd19e2902004-08-31 17:39:15 +0000340 LiveRange NewLR(defIndex,
341 getInstructionIndex(&mbb->back()) + InstrSlots::NUM,
342 ValNum);
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000343 DEBUG(std::cerr << " +" << NewLR);
344 interval.addRange(NewLR);
345
346 // Iterate over all of the blocks that the variable is completely
347 // live in, adding [insrtIndex(begin), instrIndex(end)+4) to the
348 // live interval.
349 for (unsigned i = 0, e = vi.AliveBlocks.size(); i != e; ++i) {
350 if (vi.AliveBlocks[i]) {
351 MachineBasicBlock* mbb = mf_->getBlockNumbered(i);
352 if (!mbb->empty()) {
353 LiveRange LR(getInstructionIndex(&mbb->front()),
Alkis Evlogimenosd19e2902004-08-31 17:39:15 +0000354 getInstructionIndex(&mbb->back()) + InstrSlots::NUM,
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000355 ValNum);
356 interval.addRange(LR);
357 DEBUG(std::cerr << " +" << LR);
358 }
359 }
360 }
361
362 // Finally, this virtual register is live from the start of any killing
363 // block to the 'use' slot of the killing instruction.
364 for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) {
365 MachineInstr *Kill = vi.Kills[i];
366 LiveRange LR(getInstructionIndex(Kill->getParent()->begin()),
Alkis Evlogimenosd19e2902004-08-31 17:39:15 +0000367 getUseIndex(getInstructionIndex(Kill))+1,
368 ValNum);
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000369 interval.addRange(LR);
370 DEBUG(std::cerr << " +" << LR);
371 }
372
373 } else {
374 // If this is the second time we see a virtual register definition, it
375 // must be due to phi elimination or two addr elimination. If this is
376 // the result of two address elimination, then the vreg is the first
377 // operand, and is a def-and-use.
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000378 if (mi->getOperand(0).isRegister() &&
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000379 mi->getOperand(0).getReg() == interval.reg &&
380 mi->getOperand(0).isDef() && mi->getOperand(0).isUse()) {
381 // If this is a two-address definition, then we have already processed
382 // the live range. The only problem is that we didn't realize there
383 // are actually two values in the live interval. Because of this we
384 // need to take the LiveRegion that defines this register and split it
385 // into two values.
386 unsigned DefIndex = getDefIndex(getInstructionIndex(vi.DefInst));
387 unsigned RedefIndex = getDefIndex(getInstructionIndex(mi));
388
389 // Delete the initial value, which should be short and continuous,
390 // becuase the 2-addr copy must be in the same MBB as the redef.
391 interval.removeRange(DefIndex, RedefIndex);
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000392
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000393 LiveRange LR(DefIndex, RedefIndex, interval.getNextValue());
394 DEBUG(std::cerr << " replace range with " << LR);
395 interval.addRange(LR);
396
397 // If this redefinition is dead, we need to add a dummy unit live
398 // range covering the def slot.
399 for (LiveVariables::killed_iterator KI = lv_->dead_begin(mi),
400 E = lv_->dead_end(mi); KI != E; ++KI)
401 if (KI->second == interval.reg) {
402 interval.addRange(LiveRange(RedefIndex, RedefIndex+1, 0));
403 break;
404 }
405
406 DEBUG(std::cerr << "RESULT: " << interval);
407
408 } else {
409 // Otherwise, this must be because of phi elimination. If this is the
410 // first redefinition of the vreg that we have seen, go back and change
411 // the live range in the PHI block to be a different value number.
412 if (interval.containsOneValue()) {
413 assert(vi.Kills.size() == 1 &&
414 "PHI elimination vreg should have one kill, the PHI itself!");
415
416 // Remove the old range that we now know has an incorrect number.
417 MachineInstr *Killer = vi.Kills[0];
418 unsigned Start = getInstructionIndex(Killer->getParent()->begin());
419 unsigned End = getUseIndex(getInstructionIndex(Killer))+1;
420 DEBUG(std::cerr << "Removing [" << Start << "," << End << "] from: "
421 << interval << "\n");
422 interval.removeRange(Start, End);
423 DEBUG(std::cerr << "RESULT: " << interval);
424
425 // Replace the interval with one of a NEW value number.
426 LiveRange LR(Start, End, interval.getNextValue());
427 DEBUG(std::cerr << " replace range with " << LR);
428 interval.addRange(LR);
429 DEBUG(std::cerr << "RESULT: " << interval);
430 }
431
432 // In the case of PHI elimination, each variable definition is only
433 // live until the end of the block. We've already taken care of the
434 // rest of the live range.
435 unsigned defIndex = getDefIndex(getInstructionIndex(mi));
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000436 LiveRange LR(defIndex,
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000437 getInstructionIndex(&mbb->back()) + InstrSlots::NUM,
438 interval.getNextValue());
439 interval.addRange(LR);
440 DEBUG(std::cerr << " +" << LR);
441 }
442 }
443
444 DEBUG(std::cerr << '\n');
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000445}
446
Chris Lattnerf35fef72004-07-23 21:24:19 +0000447void LiveIntervals::handlePhysicalRegisterDef(MachineBasicBlock *MBB,
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000448 MachineBasicBlock::iterator mi,
Chris Lattnerf768bba2005-03-09 23:05:19 +0000449 LiveInterval& interval,
450 unsigned SrcReg, unsigned DestReg)
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000451{
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000452 // A physical register cannot be live across basic block, so its
453 // lifetime must end somewhere in its defining basic block.
454 DEBUG(std::cerr << "\t\tregister: "; printRegName(interval.reg));
455 typedef LiveVariables::killed_iterator KillIter;
Alkis Evlogimenos02ba13c2004-01-31 23:13:30 +0000456
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000457 unsigned baseIndex = getInstructionIndex(mi);
458 unsigned start = getDefIndex(baseIndex);
459 unsigned end = start;
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000460
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000461 // If it is not used after definition, it is considered dead at
462 // the instruction defining it. Hence its interval is:
463 // [defSlot(def), defSlot(def)+1)
464 for (KillIter ki = lv_->dead_begin(mi), ke = lv_->dead_end(mi);
465 ki != ke; ++ki) {
466 if (interval.reg == ki->second) {
467 DEBUG(std::cerr << " dead");
468 end = getDefIndex(start) + 1;
469 goto exit;
470 }
471 }
472
473 // If it is not dead on definition, it must be killed by a
474 // subsequent instruction. Hence its interval is:
475 // [defSlot(def), useSlot(kill)+1)
476 while (true) {
477 ++mi;
478 assert(mi != MBB->end() && "physreg was not killed in defining block!");
479 baseIndex += InstrSlots::NUM;
480 for (KillIter ki = lv_->killed_begin(mi), ke = lv_->killed_end(mi);
Alkis Evlogimenosaf254732004-01-13 22:26:14 +0000481 ki != ke; ++ki) {
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000482 if (interval.reg == ki->second) {
483 DEBUG(std::cerr << " killed");
484 end = getUseIndex(baseIndex) + 1;
485 goto exit;
486 }
Alkis Evlogimenosaf254732004-01-13 22:26:14 +0000487 }
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000488 }
Alkis Evlogimenos02ba13c2004-01-31 23:13:30 +0000489
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000490exit:
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000491 assert(start < end && "did not find end of interval?");
Chris Lattnerf768bba2005-03-09 23:05:19 +0000492
493 // Finally, if this is defining a new range for the physical register, and if
494 // that physreg is just a copy from a vreg, and if THAT vreg was a copy from
495 // the physreg, then the new fragment has the same value as the one copied
496 // into the vreg.
497 if (interval.reg == DestReg && !interval.empty() &&
498 MRegisterInfo::isVirtualRegister(SrcReg) && !DisableHack) {
499
500 // Get the live interval for the vreg, see if it is defined by a copy.
501 LiveInterval &SrcInterval = getOrCreateInterval(SrcReg);
502
503 if (SrcInterval.containsOneValue()) {
504 assert(!SrcInterval.empty() && "Can't contain a value and be empty!");
505
506 // Get the first index of the first range. Though the interval may have
507 // multiple liveranges in it, we only check the first.
508 unsigned StartIdx = SrcInterval.begin()->start;
509 MachineInstr *SrcDefMI = getInstructionFromIndex(StartIdx);
510
511 // Check to see if the vreg was defined by a copy instruction, and that
512 // the source was this physreg.
513 unsigned VRegSrcSrc, VRegSrcDest;
514 if (tii_->isMoveInstr(*SrcDefMI, VRegSrcSrc, VRegSrcDest) &&
515 SrcReg == VRegSrcDest && VRegSrcSrc == DestReg) {
516 // Okay, now we know that the vreg was defined by a copy from this
517 // physreg. Find the value number being copied and use it as the value
518 // for this range.
519 const LiveRange *DefRange = interval.getLiveRangeContaining(StartIdx-1);
520 if (DefRange) {
521 LiveRange LR(start, end, DefRange->ValId);
522 interval.addRange(LR);
523 DEBUG(std::cerr << " +" << LR << '\n');
524 return;
525 }
526 }
527 }
528 }
529
530
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000531 LiveRange LR(start, end, interval.getNextValue());
532 interval.addRange(LR);
533 DEBUG(std::cerr << " +" << LR << '\n');
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000534}
535
Chris Lattnerf35fef72004-07-23 21:24:19 +0000536void LiveIntervals::handleRegisterDef(MachineBasicBlock *MBB,
537 MachineBasicBlock::iterator MI,
538 unsigned reg) {
539 if (MRegisterInfo::isVirtualRegister(reg))
540 handleVirtualRegisterDef(MBB, MI, getOrCreateInterval(reg));
Alkis Evlogimenos53278012004-08-26 22:22:38 +0000541 else if (allocatableRegs_[reg]) {
Chris Lattnerf768bba2005-03-09 23:05:19 +0000542 unsigned SrcReg = 0, DestReg = 0;
543 bool IsMove = tii_->isMoveInstr(*MI, SrcReg, DestReg);
544
545 handlePhysicalRegisterDef(MBB, MI, getOrCreateInterval(reg),
546 SrcReg, DestReg);
Chris Lattnerf35fef72004-07-23 21:24:19 +0000547 for (const unsigned* AS = mri_->getAliasSet(reg); *AS; ++AS)
Chris Lattnerf768bba2005-03-09 23:05:19 +0000548 handlePhysicalRegisterDef(MBB, MI, getOrCreateInterval(*AS),
549 SrcReg, DestReg);
Chris Lattnerf35fef72004-07-23 21:24:19 +0000550 }
Alkis Evlogimenos4d46e1e2004-01-31 14:37:41 +0000551}
552
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000553/// computeIntervals - computes the live intervals for virtual
Alkis Evlogimenos4d46e1e2004-01-31 14:37:41 +0000554/// registers. for some ordering of the machine instructions [1,N] a
Alkis Evlogimenos08cec002004-01-31 19:59:32 +0000555/// live interval is an interval [i, j) where 1 <= i <= j < N for
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000556/// which a variable is live
557void LiveIntervals::computeIntervals()
558{
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000559 DEBUG(std::cerr << "********** COMPUTING LIVE INTERVALS **********\n");
560 DEBUG(std::cerr << "********** Function: "
561 << ((Value*)mf_->getFunction())->getName() << '\n');
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000562
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000563 for (MachineFunction::iterator I = mf_->begin(), E = mf_->end();
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000564 I != E; ++I) {
565 MachineBasicBlock* mbb = I;
566 DEBUG(std::cerr << ((Value*)mbb->getBasicBlock())->getName() << ":\n");
Alkis Evlogimenos6b4edba2003-12-21 20:19:10 +0000567
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000568 for (MachineBasicBlock::iterator mi = mbb->begin(), miEnd = mbb->end();
569 mi != miEnd; ++mi) {
570 const TargetInstrDescriptor& tid =
571 tm_->getInstrInfo()->get(mi->getOpcode());
Chris Lattner477e4552004-09-30 16:10:45 +0000572 DEBUG(std::cerr << getInstructionIndex(mi) << "\t" << *mi);
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000573
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000574 // handle implicit defs
575 for (const unsigned* id = tid.ImplicitDefs; *id; ++id)
576 handleRegisterDef(mbb, mi, *id);
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000577
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000578 // handle explicit defs
579 for (int i = mi->getNumOperands() - 1; i >= 0; --i) {
580 MachineOperand& mop = mi->getOperand(i);
581 // handle register defs - build intervals
582 if (mop.isRegister() && mop.getReg() && mop.isDef())
583 handleRegisterDef(mbb, mi, mop.getReg());
584 }
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000585 }
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000586 }
Alkis Evlogimenosff0cbe12003-11-20 03:32:25 +0000587}
Alkis Evlogimenosb27ef242003-12-05 10:38:28 +0000588
Chris Lattner1c5c0442004-07-19 14:08:10 +0000589void LiveIntervals::joinIntervalsInMachineBB(MachineBasicBlock *MBB) {
Chris Lattner7ac2d312004-07-24 02:59:07 +0000590 DEBUG(std::cerr << ((Value*)MBB->getBasicBlock())->getName() << ":\n");
Alkis Evlogimenose88280a2004-01-22 23:08:45 +0000591
Chris Lattner7ac2d312004-07-24 02:59:07 +0000592 for (MachineBasicBlock::iterator mi = MBB->begin(), mie = MBB->end();
593 mi != mie; ++mi) {
594 DEBUG(std::cerr << getInstructionIndex(mi) << '\t' << *mi);
Alkis Evlogimenose88280a2004-01-22 23:08:45 +0000595
Chris Lattner7ac2d312004-07-24 02:59:07 +0000596 // we only join virtual registers with allocatable
597 // physical registers since we do not have liveness information
598 // on not allocatable physical registers
599 unsigned regA, regB;
Chris Lattnerf768bba2005-03-09 23:05:19 +0000600 if (tii_->isMoveInstr(*mi, regA, regB) &&
Alkis Evlogimenos53278012004-08-26 22:22:38 +0000601 (MRegisterInfo::isVirtualRegister(regA) || allocatableRegs_[regA]) &&
602 (MRegisterInfo::isVirtualRegister(regB) || allocatableRegs_[regB])) {
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000603
Chris Lattner7ac2d312004-07-24 02:59:07 +0000604 // Get representative registers.
605 regA = rep(regA);
606 regB = rep(regB);
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000607
Chris Lattner7ac2d312004-07-24 02:59:07 +0000608 // If they are already joined we continue.
609 if (regA == regB)
610 continue;
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000611
Chris Lattner7ac2d312004-07-24 02:59:07 +0000612 // If they are both physical registers, we cannot join them.
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000613 if (MRegisterInfo::isPhysicalRegister(regA) &&
Chris Lattner7ac2d312004-07-24 02:59:07 +0000614 MRegisterInfo::isPhysicalRegister(regB))
615 continue;
Alkis Evlogimenose88280a2004-01-22 23:08:45 +0000616
Chris Lattner7ac2d312004-07-24 02:59:07 +0000617 // If they are not of the same register class, we cannot join them.
618 if (differingRegisterClasses(regA, regB))
619 continue;
Alkis Evlogimenose88280a2004-01-22 23:08:45 +0000620
Chris Lattner7ac2d312004-07-24 02:59:07 +0000621 LiveInterval &IntA = getInterval(regA);
622 LiveInterval &IntB = getInterval(regB);
623 assert(IntA.reg == regA && IntB.reg == regB &&
624 "Register mapping is horribly broken!");
Chris Lattner060913c2004-07-24 04:32:22 +0000625
626 DEBUG(std::cerr << "\t\tInspecting " << IntA << " and " << IntB << ": ");
627
Chris Lattner4df98e52004-07-24 03:32:06 +0000628 // If two intervals contain a single value and are joined by a copy, it
629 // does not matter if the intervals overlap, they can always be joined.
Chris Lattner7ac2d312004-07-24 02:59:07 +0000630 bool TriviallyJoinable =
631 IntA.containsOneValue() && IntB.containsOneValue();
Alkis Evlogimenose88280a2004-01-22 23:08:45 +0000632
Chris Lattner7ac2d312004-07-24 02:59:07 +0000633 unsigned MIDefIdx = getDefIndex(getInstructionIndex(mi));
Chris Lattnerc25b55a2004-07-25 07:47:25 +0000634 if ((TriviallyJoinable || IntB.joinable(IntA, MIDefIdx)) &&
Chris Lattner7ac2d312004-07-24 02:59:07 +0000635 !overlapsAliases(&IntA, &IntB)) {
636 IntB.join(IntA, MIDefIdx);
Chris Lattner1c5c0442004-07-19 14:08:10 +0000637
Chris Lattner7ac2d312004-07-24 02:59:07 +0000638 if (!MRegisterInfo::isPhysicalRegister(regA)) {
Chris Lattner4df98e52004-07-24 03:32:06 +0000639 r2iMap_.erase(regA);
Chris Lattner7ac2d312004-07-24 02:59:07 +0000640 r2rMap_[regA] = regB;
641 } else {
642 // Otherwise merge the data structures the other way so we don't lose
643 // the physreg information.
644 r2rMap_[regB] = regA;
645 IntB.reg = regA;
Alkis Evlogimenosa1613db2004-07-24 11:44:15 +0000646 IntA.swap(IntB);
Chris Lattner4df98e52004-07-24 03:32:06 +0000647 r2iMap_.erase(regB);
Alkis Evlogimenose88280a2004-01-22 23:08:45 +0000648 }
Chris Lattner7ac2d312004-07-24 02:59:07 +0000649 DEBUG(std::cerr << "Joined. Result = " << IntB << "\n");
650 ++numJoins;
651 } else {
652 DEBUG(std::cerr << "Interference!\n");
653 }
Alkis Evlogimenose88280a2004-01-22 23:08:45 +0000654 }
Chris Lattner7ac2d312004-07-24 02:59:07 +0000655 }
Alkis Evlogimenose88280a2004-01-22 23:08:45 +0000656}
657
Chris Lattnercc0d1562004-07-19 14:40:29 +0000658namespace {
659 // DepthMBBCompare - Comparison predicate that sort first based on the loop
660 // depth of the basic block (the unsigned), and then on the MBB number.
661 struct DepthMBBCompare {
662 typedef std::pair<unsigned, MachineBasicBlock*> DepthMBBPair;
663 bool operator()(const DepthMBBPair &LHS, const DepthMBBPair &RHS) const {
664 if (LHS.first > RHS.first) return true; // Deeper loops first
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000665 return LHS.first == RHS.first &&
Alkis Evlogimenos1a8ea012004-08-04 09:46:26 +0000666 LHS.second->getNumber() < RHS.second->getNumber();
Chris Lattnercc0d1562004-07-19 14:40:29 +0000667 }
668 };
669}
Chris Lattner1c5c0442004-07-19 14:08:10 +0000670
Chris Lattnercc0d1562004-07-19 14:40:29 +0000671void LiveIntervals::joinIntervals() {
672 DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n");
673
674 const LoopInfo &LI = getAnalysis<LoopInfo>();
675 if (LI.begin() == LI.end()) {
676 // If there are no loops in the function, join intervals in function order.
Chris Lattner1c5c0442004-07-19 14:08:10 +0000677 for (MachineFunction::iterator I = mf_->begin(), E = mf_->end();
678 I != E; ++I)
679 joinIntervalsInMachineBB(I);
Chris Lattnercc0d1562004-07-19 14:40:29 +0000680 } else {
681 // Otherwise, join intervals in inner loops before other intervals.
682 // Unfortunately we can't just iterate over loop hierarchy here because
683 // there may be more MBB's than BB's. Collect MBB's for sorting.
684 std::vector<std::pair<unsigned, MachineBasicBlock*> > MBBs;
685 for (MachineFunction::iterator I = mf_->begin(), E = mf_->end();
686 I != E; ++I)
687 MBBs.push_back(std::make_pair(LI.getLoopDepth(I->getBasicBlock()), I));
688
689 // Sort by loop depth.
690 std::sort(MBBs.begin(), MBBs.end(), DepthMBBCompare());
691
Alkis Evlogimenos70651572004-08-04 09:46:56 +0000692 // Finally, join intervals in loop nest order.
Chris Lattnercc0d1562004-07-19 14:40:29 +0000693 for (unsigned i = 0, e = MBBs.size(); i != e; ++i)
694 joinIntervalsInMachineBB(MBBs[i].second);
695 }
Chris Lattnerc83e40d2004-07-25 03:24:11 +0000696
697 DEBUG(std::cerr << "*** Register mapping ***\n");
Alkis Evlogimenos5d0d1e32004-09-08 03:01:50 +0000698 DEBUG(for (int i = 0, e = r2rMap_.size(); i != e; ++i)
699 if (r2rMap_[i])
700 std::cerr << " reg " << i << " -> reg " << r2rMap_[i] << "\n");
Chris Lattner1c5c0442004-07-19 14:08:10 +0000701}
702
Chris Lattner7ac2d312004-07-24 02:59:07 +0000703/// Return true if the two specified registers belong to different register
704/// classes. The registers may be either phys or virt regs.
705bool LiveIntervals::differingRegisterClasses(unsigned RegA,
706 unsigned RegB) const {
Alkis Evlogimenos79b0c3f2004-01-23 13:37:51 +0000707
Chris Lattner7ac2d312004-07-24 02:59:07 +0000708 // Get the register classes for the first reg.
Chris Lattnerad3c74f2004-10-26 05:29:18 +0000709 if (MRegisterInfo::isPhysicalRegister(RegA)) {
710 assert(MRegisterInfo::isVirtualRegister(RegB) &&
711 "Shouldn't consider two physregs!");
712 return !mf_->getSSARegMap()->getRegClass(RegB)->contains(RegA);
713 }
Chris Lattner7ac2d312004-07-24 02:59:07 +0000714
715 // Compare against the regclass for the second reg.
Chris Lattnerad3c74f2004-10-26 05:29:18 +0000716 const TargetRegisterClass *RegClass = mf_->getSSARegMap()->getRegClass(RegA);
Chris Lattner7ac2d312004-07-24 02:59:07 +0000717 if (MRegisterInfo::isVirtualRegister(RegB))
718 return RegClass != mf_->getSSARegMap()->getRegClass(RegB);
719 else
Chris Lattnerd0d0a1a2004-08-24 17:48:29 +0000720 return !RegClass->contains(RegB);
Chris Lattner7ac2d312004-07-24 02:59:07 +0000721}
722
723bool LiveIntervals::overlapsAliases(const LiveInterval *LHS,
724 const LiveInterval *RHS) const {
725 if (!MRegisterInfo::isPhysicalRegister(LHS->reg)) {
726 if (!MRegisterInfo::isPhysicalRegister(RHS->reg))
727 return false; // vreg-vreg merge has no aliases!
728 std::swap(LHS, RHS);
729 }
730
731 assert(MRegisterInfo::isPhysicalRegister(LHS->reg) &&
732 MRegisterInfo::isVirtualRegister(RHS->reg) &&
733 "first interval must describe a physical register");
734
Chris Lattner4df98e52004-07-24 03:32:06 +0000735 for (const unsigned *AS = mri_->getAliasSet(LHS->reg); *AS; ++AS)
736 if (RHS->overlaps(getInterval(*AS)))
737 return true;
Alkis Evlogimenos79b0c3f2004-01-23 13:37:51 +0000738
Chris Lattner4df98e52004-07-24 03:32:06 +0000739 return false;
Alkis Evlogimenos79b0c3f2004-01-23 13:37:51 +0000740}
741
Alkis Evlogimenosa1613db2004-07-24 11:44:15 +0000742LiveInterval LiveIntervals::createInterval(unsigned reg) {
Chris Lattner28696be2005-01-08 19:55:00 +0000743 float Weight = MRegisterInfo::isPhysicalRegister(reg) ?
744 (float)HUGE_VAL :0.0F;
Alkis Evlogimenosa1613db2004-07-24 11:44:15 +0000745 return LiveInterval(reg, Weight);
Alkis Evlogimenos9a8b4902004-04-09 18:07:57 +0000746}