LLVM API Documentation
00001 //===-- RegAllocLinearScan.cpp - Linear Scan register allocator -----------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements a linear scan register allocator. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #define DEBUG_TYPE "regalloc" 00015 #include "PhysRegTracker.h" 00016 #include "VirtRegMap.h" 00017 #include "llvm/Function.h" 00018 #include "llvm/CodeGen/LiveIntervalAnalysis.h" 00019 #include "llvm/CodeGen/LiveStackAnalysis.h" 00020 #include "llvm/CodeGen/MachineFunctionPass.h" 00021 #include "llvm/CodeGen/MachineInstr.h" 00022 #include "llvm/CodeGen/MachineLoopInfo.h" 00023 #include "llvm/CodeGen/MachineRegisterInfo.h" 00024 #include "llvm/CodeGen/Passes.h" 00025 #include "llvm/CodeGen/RegAllocRegistry.h" 00026 #include "llvm/CodeGen/RegisterCoalescer.h" 00027 #include "llvm/Target/TargetRegisterInfo.h" 00028 #include "llvm/Target/TargetMachine.h" 00029 #include "llvm/Target/TargetOptions.h" 00030 #include "llvm/Target/TargetInstrInfo.h" 00031 #include "llvm/ADT/EquivalenceClasses.h" 00032 #include "llvm/ADT/SmallSet.h" 00033 #include "llvm/ADT/Statistic.h" 00034 #include "llvm/ADT/STLExtras.h" 00035 #include "llvm/Support/Debug.h" 00036 #include "llvm/Support/Compiler.h" 00037 #include <algorithm> 00038 #include <set> 00039 #include <queue> 00040 #include <memory> 00041 #include <cmath> 00042 using namespace llvm; 00043 00044 STATISTIC(NumIters , "Number of iterations performed"); 00045 STATISTIC(NumBacktracks, "Number of times we had to backtrack"); 00046 STATISTIC(NumCoalesce, "Number of copies coalesced"); 00047 00048 static cl::opt<bool> 00049 NewHeuristic("new-spilling-heuristic", 00050 cl::desc("Use new spilling heuristic"), 00051 cl::init(false), cl::Hidden); 00052 00053 static cl::opt<bool> 00054 PreSplitIntervals("pre-alloc-split", 00055 cl::desc("Pre-register allocation live interval splitting"), 00056 cl::init(false), cl::Hidden); 00057 00058 static RegisterRegAlloc 00059 linearscanRegAlloc("linearscan", "linear scan register allocator", 00060 createLinearScanRegisterAllocator); 00061 00062 namespace { 00063 struct VISIBILITY_HIDDEN RALinScan : public MachineFunctionPass { 00064 static char ID; 00065 RALinScan() : MachineFunctionPass(&ID) {} 00066 00067 typedef std::pair<LiveInterval*, LiveInterval::iterator> IntervalPtr; 00068 typedef SmallVector<IntervalPtr, 32> IntervalPtrs; 00069 private: 00070 /// RelatedRegClasses - This structure is built the first time a function is 00071 /// compiled, and keeps track of which register classes have registers that 00072 /// belong to multiple classes or have aliases that are in other classes. 00073 EquivalenceClasses<const TargetRegisterClass*> RelatedRegClasses; 00074 DenseMap<unsigned, const TargetRegisterClass*> OneClassForEachPhysReg; 00075 00076 MachineFunction* mf_; 00077 MachineRegisterInfo* mri_; 00078 const TargetMachine* tm_; 00079 const TargetRegisterInfo* tri_; 00080 const TargetInstrInfo* tii_; 00081 BitVector allocatableRegs_; 00082 LiveIntervals* li_; 00083 LiveStacks* ls_; 00084 const MachineLoopInfo *loopInfo; 00085 00086 /// handled_ - Intervals are added to the handled_ set in the order of their 00087 /// start value. This is uses for backtracking. 00088 std::vector<LiveInterval*> handled_; 00089 00090 /// fixed_ - Intervals that correspond to machine registers. 00091 /// 00092 IntervalPtrs fixed_; 00093 00094 /// active_ - Intervals that are currently being processed, and which have a 00095 /// live range active for the current point. 00096 IntervalPtrs active_; 00097 00098 /// inactive_ - Intervals that are currently being processed, but which have 00099 /// a hold at the current point. 00100 IntervalPtrs inactive_; 00101 00102 typedef std::priority_queue<LiveInterval*, 00103 SmallVector<LiveInterval*, 64>, 00104 greater_ptr<LiveInterval> > IntervalHeap; 00105 IntervalHeap unhandled_; 00106 std::auto_ptr<PhysRegTracker> prt_; 00107 std::auto_ptr<VirtRegMap> vrm_; 00108 std::auto_ptr<Spiller> spiller_; 00109 00110 public: 00111 virtual const char* getPassName() const { 00112 return "Linear Scan Register Allocator"; 00113 } 00114 00115 virtual void getAnalysisUsage(AnalysisUsage &AU) const { 00116 AU.addRequired<LiveIntervals>(); 00117 if (StrongPHIElim) 00118 AU.addRequiredID(StrongPHIEliminationID); 00119 // Make sure PassManager knows which analyses to make available 00120 // to coalescing and which analyses coalescing invalidates. 00121 AU.addRequiredTransitive<RegisterCoalescer>(); 00122 if (PreSplitIntervals) 00123 AU.addRequiredID(PreAllocSplittingID); 00124 AU.addRequired<LiveStacks>(); 00125 AU.addPreserved<LiveStacks>(); 00126 AU.addRequired<MachineLoopInfo>(); 00127 AU.addPreserved<MachineLoopInfo>(); 00128 AU.addPreservedID(MachineDominatorsID); 00129 MachineFunctionPass::getAnalysisUsage(AU); 00130 } 00131 00132 /// runOnMachineFunction - register allocate the whole function 00133 bool runOnMachineFunction(MachineFunction&); 00134 00135 private: 00136 /// linearScan - the linear scan algorithm 00137 void linearScan(); 00138 00139 /// initIntervalSets - initialize the interval sets. 00140 /// 00141 void initIntervalSets(); 00142 00143 /// processActiveIntervals - expire old intervals and move non-overlapping 00144 /// ones to the inactive list. 00145 void processActiveIntervals(unsigned CurPoint); 00146 00147 /// processInactiveIntervals - expire old intervals and move overlapping 00148 /// ones to the active list. 00149 void processInactiveIntervals(unsigned CurPoint); 00150 00151 /// assignRegOrStackSlotAtInterval - assign a register if one 00152 /// is available, or spill. 00153 void assignRegOrStackSlotAtInterval(LiveInterval* cur); 00154 00155 /// findIntervalsToSpill - Determine the intervals to spill for the 00156 /// specified interval. It's passed the physical registers whose spill 00157 /// weight is the lowest among all the registers whose live intervals 00158 /// conflict with the interval. 00159 void findIntervalsToSpill(LiveInterval *cur, 00160 std::vector<std::pair<unsigned,float> > &Candidates, 00161 unsigned NumCands, 00162 SmallVector<LiveInterval*, 8> &SpillIntervals); 00163 00164 /// attemptTrivialCoalescing - If a simple interval is defined by a copy, 00165 /// try allocate the definition the same register as the source register 00166 /// if the register is not defined during live time of the interval. This 00167 /// eliminate a copy. This is used to coalesce copies which were not 00168 /// coalesced away before allocation either due to dest and src being in 00169 /// different register classes or because the coalescer was overly 00170 /// conservative. 00171 unsigned attemptTrivialCoalescing(LiveInterval &cur, unsigned Reg); 00172 00173 /// 00174 /// register handling helpers 00175 /// 00176 00177 /// getFreePhysReg - return a free physical register for this virtual 00178 /// register interval if we have one, otherwise return 0. 00179 unsigned getFreePhysReg(LiveInterval* cur); 00180 00181 /// assignVirt2StackSlot - assigns this virtual register to a 00182 /// stack slot. returns the stack slot 00183 int assignVirt2StackSlot(unsigned virtReg); 00184 00185 void ComputeRelatedRegClasses(); 00186 00187 template <typename ItTy> 00188 void printIntervals(const char* const str, ItTy i, ItTy e) const { 00189 if (str) DOUT << str << " intervals:\n"; 00190 for (; i != e; ++i) { 00191 DOUT << "\t" << *i->first << " -> "; 00192 unsigned reg = i->first->reg; 00193 if (TargetRegisterInfo::isVirtualRegister(reg)) { 00194 reg = vrm_->getPhys(reg); 00195 } 00196 DOUT << tri_->getName(reg) << '\n'; 00197 } 00198 } 00199 }; 00200 char RALinScan::ID = 0; 00201 } 00202 00203 static RegisterPass<RALinScan> 00204 X("linearscan-regalloc", "Linear Scan Register Allocator"); 00205 00206 void RALinScan::ComputeRelatedRegClasses() { 00207 const TargetRegisterInfo &TRI = *tri_; 00208 00209 // First pass, add all reg classes to the union, and determine at least one 00210 // reg class that each register is in. 00211 bool HasAliases = false; 00212 for (TargetRegisterInfo::regclass_iterator RCI = TRI.regclass_begin(), 00213 E = TRI.regclass_end(); RCI != E; ++RCI) { 00214 RelatedRegClasses.insert(*RCI); 00215 for (TargetRegisterClass::iterator I = (*RCI)->begin(), E = (*RCI)->end(); 00216 I != E; ++I) { 00217 HasAliases = HasAliases || *TRI.getAliasSet(*I) != 0; 00218 00219 const TargetRegisterClass *&PRC = OneClassForEachPhysReg[*I]; 00220 if (PRC) { 00221 // Already processed this register. Just make sure we know that 00222 // multiple register classes share a register. 00223 RelatedRegClasses.unionSets(PRC, *RCI); 00224 } else { 00225 PRC = *RCI; 00226 } 00227 } 00228 } 00229 00230 // Second pass, now that we know conservatively what register classes each reg 00231 // belongs to, add info about aliases. We don't need to do this for targets 00232 // without register aliases. 00233 if (HasAliases) 00234 for (DenseMap<unsigned, const TargetRegisterClass*>::iterator 00235 I = OneClassForEachPhysReg.begin(), E = OneClassForEachPhysReg.end(); 00236 I != E; ++I) 00237 for (const unsigned *AS = TRI.getAliasSet(I->first); *AS; ++AS) 00238 RelatedRegClasses.unionSets(I->second, OneClassForEachPhysReg[*AS]); 00239 } 00240 00241 /// attemptTrivialCoalescing - If a simple interval is defined by a copy, 00242 /// try allocate the definition the same register as the source register 00243 /// if the register is not defined during live time of the interval. This 00244 /// eliminate a copy. This is used to coalesce copies which were not 00245 /// coalesced away before allocation either due to dest and src being in 00246 /// different register classes or because the coalescer was overly 00247 /// conservative. 00248 unsigned RALinScan::attemptTrivialCoalescing(LiveInterval &cur, unsigned Reg) { 00249 if ((cur.preference && cur.preference == Reg) || !cur.containsOneValue()) 00250 return Reg; 00251 00252 VNInfo *vni = cur.begin()->valno; 00253 if (!vni->def || vni->def == ~1U || vni->def == ~0U) 00254 return Reg; 00255 MachineInstr *CopyMI = li_->getInstructionFromIndex(vni->def); 00256 unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; 00257 if (!CopyMI || 00258 !tii_->isMoveInstr(*CopyMI, SrcReg, DstReg, SrcSubReg, DstSubReg)) 00259 return Reg; 00260 if (TargetRegisterInfo::isVirtualRegister(SrcReg)) { 00261 if (!vrm_->isAssignedReg(SrcReg)) 00262 return Reg; 00263 else 00264 SrcReg = vrm_->getPhys(SrcReg); 00265 } 00266 if (Reg == SrcReg) 00267 return Reg; 00268 00269 const TargetRegisterClass *RC = mri_->getRegClass(cur.reg); 00270 if (!RC->contains(SrcReg)) 00271 return Reg; 00272 00273 // Try to coalesce. 00274 if (!li_->conflictsWithPhysRegDef(cur, *vrm_, SrcReg)) { 00275 DOUT << "Coalescing: " << cur << " -> " << tri_->getName(SrcReg) 00276 << '\n'; 00277 vrm_->clearVirt(cur.reg); 00278 vrm_->assignVirt2Phys(cur.reg, SrcReg); 00279 ++NumCoalesce; 00280 return SrcReg; 00281 } 00282 00283 return Reg; 00284 } 00285 00286 bool RALinScan::runOnMachineFunction(MachineFunction &fn) { 00287 mf_ = &fn; 00288 mri_ = &fn.getRegInfo(); 00289 tm_ = &fn.getTarget(); 00290 tri_ = tm_->getRegisterInfo(); 00291 tii_ = tm_->getInstrInfo(); 00292 allocatableRegs_ = tri_->getAllocatableSet(fn); 00293 li_ = &getAnalysis<LiveIntervals>(); 00294 ls_ = &getAnalysis<LiveStacks>(); 00295 loopInfo = &getAnalysis<MachineLoopInfo>(); 00296 00297 // We don't run the coalescer here because we have no reason to 00298 // interact with it. If the coalescer requires interaction, it 00299 // won't do anything. If it doesn't require interaction, we assume 00300 // it was run as a separate pass. 00301 00302 // If this is the first function compiled, compute the related reg classes. 00303 if (RelatedRegClasses.empty()) 00304 ComputeRelatedRegClasses(); 00305 00306 if (!prt_.get()) prt_.reset(new PhysRegTracker(*tri_)); 00307 vrm_.reset(new VirtRegMap(*mf_)); 00308 if (!spiller_.get()) spiller_.reset(createSpiller()); 00309 00310 initIntervalSets(); 00311 00312 linearScan(); 00313 00314 // Rewrite spill code and update the PhysRegsUsed set. 00315 spiller_->runOnMachineFunction(*mf_, *vrm_); 00316 vrm_.reset(); // Free the VirtRegMap 00317 00318 assert(unhandled_.empty() && "Unhandled live intervals remain!"); 00319 fixed_.clear(); 00320 active_.clear(); 00321 inactive_.clear(); 00322 handled_.clear(); 00323 00324 return true; 00325 } 00326 00327 /// initIntervalSets - initialize the interval sets. 00328 /// 00329 void RALinScan::initIntervalSets() 00330 { 00331 assert(unhandled_.empty() && fixed_.empty() && 00332 active_.empty() && inactive_.empty() && 00333 "interval sets should be empty on initialization"); 00334 00335 handled_.reserve(li_->getNumIntervals()); 00336 00337 for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i) { 00338 if (TargetRegisterInfo::isPhysicalRegister(i->second->reg)) { 00339 mri_->setPhysRegUsed(i->second->reg); 00340 fixed_.push_back(std::make_pair(i->second, i->second->begin())); 00341 } else 00342 unhandled_.push(i->second); 00343 } 00344 } 00345 00346 void RALinScan::linearScan() 00347 { 00348 // linear scan algorithm 00349 DOUT << "********** LINEAR SCAN **********\n"; 00350 DOUT << "********** Function: " << mf_->getFunction()->getName() << '\n'; 00351 00352 DEBUG(printIntervals("fixed", fixed_.begin(), fixed_.end())); 00353 00354 while (!unhandled_.empty()) { 00355 // pick the interval with the earliest start point 00356 LiveInterval* cur = unhandled_.top(); 00357 unhandled_.pop(); 00358 ++NumIters; 00359 DOUT << "\n*** CURRENT ***: " << *cur << '\n'; 00360 00361 if (!cur->empty()) { 00362 processActiveIntervals(cur->beginNumber()); 00363 processInactiveIntervals(cur->beginNumber()); 00364 00365 assert(TargetRegisterInfo::isVirtualRegister(cur->reg) && 00366 "Can only allocate virtual registers!"); 00367 } 00368 00369 // Allocating a virtual register. try to find a free 00370 // physical register or spill an interval (possibly this one) in order to 00371 // assign it one. 00372 assignRegOrStackSlotAtInterval(cur); 00373 00374 DEBUG(printIntervals("active", active_.begin(), active_.end())); 00375 DEBUG(printIntervals("inactive", inactive_.begin(), inactive_.end())); 00376 } 00377 00378 // expire any remaining active intervals 00379 while (!active_.empty()) { 00380 IntervalPtr &IP = active_.back(); 00381 unsigned reg = IP.first->reg; 00382 DOUT << "\tinterval " << *IP.first << " expired\n"; 00383 assert(TargetRegisterInfo::isVirtualRegister(reg) && 00384 "Can only allocate virtual registers!"); 00385 reg = vrm_->getPhys(reg); 00386 prt_->delRegUse(reg); 00387 active_.pop_back(); 00388 } 00389 00390 // expire any remaining inactive intervals 00391 DEBUG(for (IntervalPtrs::reverse_iterator 00392 i = inactive_.rbegin(); i != inactive_.rend(); ++i) 00393 DOUT << "\tinterval " << *i->first << " expired\n"); 00394 inactive_.clear(); 00395 00396 // Add live-ins to every BB except for entry. Also perform trivial coalescing. 00397 MachineFunction::iterator EntryMBB = mf_->begin(); 00398 SmallVector<MachineBasicBlock*, 8> LiveInMBBs; 00399 for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i) { 00400 LiveInterval &cur = *i->second; 00401 unsigned Reg = 0; 00402 bool isPhys = TargetRegisterInfo::isPhysicalRegister(cur.reg); 00403 if (isPhys) 00404 Reg = cur.reg; 00405 else if (vrm_->isAssignedReg(cur.reg)) 00406 Reg = attemptTrivialCoalescing(cur, vrm_->getPhys(cur.reg)); 00407 if (!Reg) 00408 continue; 00409 // Ignore splited live intervals. 00410 if (!isPhys && vrm_->getPreSplitReg(cur.reg)) 00411 continue; 00412 for (LiveInterval::Ranges::const_iterator I = cur.begin(), E = cur.end(); 00413 I != E; ++I) { 00414 const LiveRange &LR = *I; 00415 if (li_->findLiveInMBBs(LR.start, LR.end, LiveInMBBs)) { 00416 for (unsigned i = 0, e = LiveInMBBs.size(); i != e; ++i) 00417 if (LiveInMBBs[i] != EntryMBB) 00418 LiveInMBBs[i]->addLiveIn(Reg); 00419 LiveInMBBs.clear(); 00420 } 00421 } 00422 } 00423 00424 DOUT << *vrm_; 00425 } 00426 00427 /// processActiveIntervals - expire old intervals and move non-overlapping ones 00428 /// to the inactive list. 00429 void RALinScan::processActiveIntervals(unsigned CurPoint) 00430 { 00431 DOUT << "\tprocessing active intervals:\n"; 00432 00433 for (unsigned i = 0, e = active_.size(); i != e; ++i) { 00434 LiveInterval *Interval = active_[i].first; 00435 LiveInterval::iterator IntervalPos = active_[i].second; 00436 unsigned reg = Interval->reg; 00437 00438 IntervalPos = Interval->advanceTo(IntervalPos, CurPoint); 00439 00440 if (IntervalPos == Interval->end()) { // Remove expired intervals. 00441 DOUT << "\t\tinterval " << *Interval << " expired\n"; 00442 assert(TargetRegisterInfo::isVirtualRegister(reg) && 00443 "Can only allocate virtual registers!"); 00444 reg = vrm_->getPhys(reg); 00445 prt_->delRegUse(reg); 00446 00447 // Pop off the end of the list. 00448 active_[i] = active_.back(); 00449 active_.pop_back(); 00450 --i; --e; 00451 00452 } else if (IntervalPos->start > CurPoint) { 00453 // Move inactive intervals to inactive list. 00454 DOUT << "\t\tinterval " << *Interval << " inactive\n"; 00455 assert(TargetRegisterInfo::isVirtualRegister(reg) && 00456 "Can only allocate virtual registers!"); 00457 reg = vrm_->getPhys(reg); 00458 prt_->delRegUse(reg); 00459 // add to inactive. 00460 inactive_.push_back(std::make_pair(Interval, IntervalPos)); 00461 00462 // Pop off the end of the list. 00463 active_[i] = active_.back(); 00464 active_.pop_back(); 00465 --i; --e; 00466 } else { 00467 // Otherwise, just update the iterator position. 00468 active_[i].second = IntervalPos; 00469 } 00470 } 00471 } 00472 00473 /// processInactiveIntervals - expire old intervals and move overlapping 00474 /// ones to the active list. 00475 void RALinScan::processInactiveIntervals(unsigned CurPoint) 00476 { 00477 DOUT << "\tprocessing inactive intervals:\n"; 00478 00479 for (unsigned i = 0, e = inactive_.size(); i != e; ++i) { 00480 LiveInterval *Interval = inactive_[i].first; 00481 LiveInterval::iterator IntervalPos = inactive_[i].second; 00482 unsigned reg = Interval->reg; 00483 00484 IntervalPos = Interval->advanceTo(IntervalPos, CurPoint); 00485 00486 if (IntervalPos == Interval->end()) { // remove expired intervals. 00487 DOUT << "\t\tinterval " << *Interval << " expired\n"; 00488 00489 // Pop off the end of the list. 00490 inactive_[i] = inactive_.back(); 00491 inactive_.pop_back(); 00492 --i; --e; 00493 } else if (IntervalPos->start <= CurPoint) { 00494 // move re-activated intervals in active list 00495 DOUT << "\t\tinterval " << *Interval << " active\n"; 00496 assert(TargetRegisterInfo::isVirtualRegister(reg) && 00497 "Can only allocate virtual registers!"); 00498 reg = vrm_->getPhys(reg); 00499 prt_->addRegUse(reg); 00500 // add to active 00501 active_.push_back(std::make_pair(Interval, IntervalPos)); 00502 00503 // Pop off the end of the list. 00504 inactive_[i] = inactive_.back(); 00505 inactive_.pop_back(); 00506 --i; --e; 00507 } else { 00508 // Otherwise, just update the iterator position. 00509 inactive_[i].second = IntervalPos; 00510 } 00511 } 00512 } 00513 00514 /// updateSpillWeights - updates the spill weights of the specifed physical 00515 /// register and its weight. 00516 static void updateSpillWeights(std::vector<float> &Weights, 00517 unsigned reg, float weight, 00518 const TargetRegisterInfo *TRI) { 00519 Weights[reg] += weight; 00520 for (const unsigned* as = TRI->getAliasSet(reg); *as; ++as) 00521 Weights[*as] += weight; 00522 } 00523 00524 static 00525 RALinScan::IntervalPtrs::iterator 00526 FindIntervalInVector(RALinScan::IntervalPtrs &IP, LiveInterval *LI) { 00527 for (RALinScan::IntervalPtrs::iterator I = IP.begin(), E = IP.end(); 00528 I != E; ++I) 00529 if (I->first == LI) return I; 00530 return IP.end(); 00531 } 00532 00533 static void RevertVectorIteratorsTo(RALinScan::IntervalPtrs &V, unsigned Point){ 00534 for (unsigned i = 0, e = V.size(); i != e; ++i) { 00535 RALinScan::IntervalPtr &IP = V[i]; 00536 LiveInterval::iterator I = std::upper_bound(IP.first->begin(), 00537 IP.second, Point); 00538 if (I != IP.first->begin()) --I; 00539 IP.second = I; 00540 } 00541 } 00542 00543 /// addStackInterval - Create a LiveInterval for stack if the specified live 00544 /// interval has been spilled. 00545 static void addStackInterval(LiveInterval *cur, LiveStacks *ls_, 00546 LiveIntervals *li_, float &Weight, 00547 VirtRegMap &vrm_) { 00548 int SS = vrm_.getStackSlot(cur->reg); 00549 if (SS == VirtRegMap::NO_STACK_SLOT) 00550 return; 00551 LiveInterval &SI = ls_->getOrCreateInterval(SS); 00552 SI.weight += Weight; 00553 00554 VNInfo *VNI; 00555 if (SI.hasAtLeastOneValue()) 00556 VNI = SI.getValNumInfo(0); 00557 else 00558 VNI = SI.getNextValue(~0U, 0, ls_->getVNInfoAllocator()); 00559 00560 LiveInterval &RI = li_->getInterval(cur->reg); 00561 // FIXME: This may be overly conservative. 00562 SI.MergeRangesInAsValue(RI, VNI); 00563 } 00564 00565 /// getConflictWeight - Return the number of conflicts between cur 00566 /// live interval and defs and uses of Reg weighted by loop depthes. 00567 static float getConflictWeight(LiveInterval *cur, unsigned Reg, 00568 LiveIntervals *li_, 00569 MachineRegisterInfo *mri_, 00570 const MachineLoopInfo *loopInfo) { 00571 float Conflicts = 0; 00572 for (MachineRegisterInfo::reg_iterator I = mri_->reg_begin(Reg), 00573 E = mri_->reg_end(); I != E; ++I) { 00574 MachineInstr *MI = &*I; 00575 if (cur->liveAt(li_->getInstructionIndex(MI))) { 00576 unsigned loopDepth = loopInfo->getLoopDepth(MI->getParent()); 00577 Conflicts += powf(10.0f, (float)loopDepth); 00578 } 00579 } 00580 return Conflicts; 00581 } 00582 00583 /// findIntervalsToSpill - Determine the intervals to spill for the 00584 /// specified interval. It's passed the physical registers whose spill 00585 /// weight is the lowest among all the registers whose live intervals 00586 /// conflict with the interval. 00587 void RALinScan::findIntervalsToSpill(LiveInterval *cur, 00588 std::vector<std::pair<unsigned,float> > &Candidates, 00589 unsigned NumCands, 00590 SmallVector<LiveInterval*, 8> &SpillIntervals) { 00591 // We have figured out the *best* register to spill. But there are other 00592 // registers that are pretty good as well (spill weight within 3%). Spill 00593 // the one that has fewest defs and uses that conflict with cur. 00594 float Conflicts[3] = { 0.0f, 0.0f, 0.0f }; 00595 SmallVector<LiveInterval*, 8> SLIs[3]; 00596 00597 DOUT << "\tConsidering " << NumCands << " candidates: "; 00598 DEBUG(for (unsigned i = 0; i != NumCands; ++i) 00599 DOUT << tri_->getName(Candidates[i].first) << " "; 00600 DOUT << "\n";); 00601 00602 // Calculate the number of conflicts of each candidate. 00603 for (IntervalPtrs::iterator i = active_.begin(); i != active_.end(); ++i) { 00604 unsigned Reg = i->first->reg; 00605 unsigned PhysReg = vrm_->getPhys(Reg); 00606 if (!cur->overlapsFrom(*i->first, i->second)) 00607 continue; 00608 for (unsigned j = 0; j < NumCands; ++j) { 00609 unsigned Candidate = Candidates[j].first; 00610 if (tri_->regsOverlap(PhysReg, Candidate)) { 00611 if (NumCands > 1) 00612 Conflicts[j] += getConflictWeight(cur, Reg, li_, mri_, loopInfo); 00613 SLIs[j].push_back(i->first); 00614 } 00615 } 00616 } 00617 00618 for (IntervalPtrs::iterator i = inactive_.begin(); i != inactive_.end(); ++i){ 00619 unsigned Reg = i->first->reg; 00620 unsigned PhysReg = vrm_->getPhys(Reg); 00621 if (!cur->overlapsFrom(*i->first, i->second-1)) 00622 continue; 00623 for (unsigned j = 0; j < NumCands; ++j) { 00624 unsigned Candidate = Candidates[j].first; 00625 if (tri_->regsOverlap(PhysReg, Candidate)) { 00626 if (NumCands > 1) 00627 Conflicts[j] += getConflictWeight(cur, Reg, li_, mri_, loopInfo); 00628 SLIs[j].push_back(i->first); 00629 } 00630 } 00631 } 00632 00633 // Which is the best candidate? 00634 unsigned BestCandidate = 0; 00635 float MinConflicts = Conflicts[0]; 00636 for (unsigned i = 1; i != NumCands; ++i) { 00637 if (Conflicts[i] < MinConflicts) { 00638 BestCandidate = i; 00639 MinConflicts = Conflicts[i]; 00640 } 00641 } 00642 00643 std::copy(SLIs[BestCandidate].begin(), SLIs[BestCandidate].end(), 00644 std::back_inserter(SpillIntervals)); 00645 } 00646 00647 namespace { 00648 struct WeightCompare { 00649 typedef std::pair<unsigned, float> RegWeightPair; 00650 bool operator()(const RegWeightPair &LHS, const RegWeightPair &RHS) const { 00651 return LHS.second < RHS.second; 00652 } 00653 }; 00654 } 00655 00656 static bool weightsAreClose(float w1, float w2) { 00657 if (!NewHeuristic) 00658 return false; 00659 00660 float diff = w1 - w2; 00661 if (diff <= 0.02f) // Within 0.02f 00662 return true; 00663 return (diff / w2) <= 0.05f; // Within 5%. 00664 } 00665 00666 /// assignRegOrStackSlotAtInterval - assign a register if one is available, or 00667 /// spill. 00668 void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur) 00669 { 00670 DOUT << "\tallocating current interval: "; 00671 00672 // This is an implicitly defined live interval, just assign any register. 00673 const TargetRegisterClass *RC = mri_->getRegClass(cur->reg); 00674 if (cur->empty()) { 00675 unsigned physReg = cur->preference; 00676 if (!physReg) 00677 physReg = *RC->allocation_order_begin(*mf_); 00678 DOUT << tri_->getName(physReg) << '\n'; 00679 // Note the register is not really in use. 00680 vrm_->assignVirt2Phys(cur->reg, physReg); 00681 return; 00682 } 00683 00684 PhysRegTracker backupPrt = *prt_; 00685 00686 std::vector<std::pair<unsigned, float> > SpillWeightsToAdd; 00687 unsigned StartPosition = cur->beginNumber(); 00688 const TargetRegisterClass *RCLeader = RelatedRegClasses.getLeaderValue(RC); 00689 00690 // If start of this live interval is defined by a move instruction and its 00691 // source is assigned a physical register that is compatible with the target 00692 // register class, then we should try to assign it the same register. 00693 // This can happen when the move is from a larger register class to a smaller 00694 // one, e.g. X86::mov32to32_. These move instructions are not coalescable. 00695 if (!cur->preference && cur->hasAtLeastOneValue()) { 00696 VNInfo *vni = cur->begin()->valno; 00697 if (vni->def && vni->def != ~1U && vni->def != ~0U) { 00698 MachineInstr *CopyMI = li_->getInstructionFromIndex(vni->def); 00699 unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; 00700 if (CopyMI && 00701 tii_->isMoveInstr(*CopyMI, SrcReg, DstReg, SrcSubReg, DstSubReg)) { 00702 unsigned Reg = 0; 00703 if (TargetRegisterInfo::isPhysicalRegister(SrcReg)) 00704 Reg = SrcReg; 00705 else if (vrm_->isAssignedReg(SrcReg)) 00706 Reg = vrm_->getPhys(SrcReg); 00707 if (Reg && allocatableRegs_[Reg] && RC->contains(Reg)) 00708 cur->preference = Reg; 00709 } 00710 } 00711 } 00712 00713 // for every interval in inactive we overlap with, mark the 00714 // register as not free and update spill weights. 00715 for (IntervalPtrs::const_iterator i = inactive_.begin(), 00716 e = inactive_.end(); i != e; ++i) { 00717 unsigned Reg = i->first->reg; 00718 assert(TargetRegisterInfo::isVirtualRegister(Reg) && 00719 "Can only allocate virtual registers!"); 00720 const TargetRegisterClass *RegRC = mri_->getRegClass(Reg); 00721 // If this is not in a related reg class to the register we're allocating, 00722 // don't check it. 00723 if (RelatedRegClasses.getLeaderValue(RegRC) == RCLeader && 00724 cur->overlapsFrom(*i->first, i->second-1)) { 00725 Reg = vrm_->getPhys(Reg); 00726 prt_->addRegUse(Reg); 00727 SpillWeightsToAdd.push_back(std::make_pair(Reg, i->first->weight)); 00728 } 00729 } 00730 00731 // Speculatively check to see if we can get a register right now. If not, 00732 // we know we won't be able to by adding more constraints. If so, we can 00733 // check to see if it is valid. Doing an exhaustive search of the fixed_ list 00734 // is very bad (it contains all callee clobbered registers for any functions 00735 // with a call), so we want to avoid doing that if possible. 00736 unsigned physReg = getFreePhysReg(cur); 00737 unsigned BestPhysReg = physReg; 00738 if (physReg) { 00739 // We got a register. However, if it's in the fixed_ list, we might 00740 // conflict with it. Check to see if we conflict with it or any of its 00741 // aliases. 00742 SmallSet<unsigned, 8> RegAliases; 00743 for (const unsigned *AS = tri_->getAliasSet(physReg); *AS; ++AS) 00744 RegAliases.insert(*AS); 00745 00746 bool ConflictsWithFixed = false; 00747 for (unsigned i = 0, e = fixed_.size(); i != e; ++i) { 00748 IntervalPtr &IP = fixed_[i]; 00749 if (physReg == IP.first->reg || RegAliases.count(IP.first->reg)) { 00750 // Okay, this reg is on the fixed list. Check to see if we actually 00751 // conflict. 00752 LiveInterval *I = IP.first; 00753 if (I->endNumber() > StartPosition) { 00754 LiveInterval::iterator II = I->advanceTo(IP.second, StartPosition); 00755 IP.second = II; 00756 if (II != I->begin() && II->start > StartPosition) 00757 --II; 00758 if (cur->overlapsFrom(*I, II)) { 00759 ConflictsWithFixed = true; 00760 break; 00761 } 00762 } 00763 } 00764 } 00765 00766 // Okay, the register picked by our speculative getFreePhysReg call turned 00767 // out to be in use. Actually add all of the conflicting fixed registers to 00768 // prt so we can do an accurate query. 00769 if (ConflictsWithFixed) { 00770 // For every interval in fixed we overlap with, mark the register as not 00771 // free and update spill weights. 00772 for (unsigned i = 0, e = fixed_.size(); i != e; ++i) { 00773 IntervalPtr &IP = fixed_[i]; 00774 LiveInterval *I = IP.first; 00775 00776 const TargetRegisterClass *RegRC = OneClassForEachPhysReg[I->reg]; 00777 if (RelatedRegClasses.getLeaderValue(RegRC) == RCLeader && 00778 I->endNumber() > StartPosition) { 00779 LiveInterval::iterator II = I->advanceTo(IP.second, StartPosition); 00780 IP.second = II; 00781 if (II != I->begin() && II->start > StartPosition) 00782 --II; 00783 if (cur->overlapsFrom(*I, II)) { 00784 unsigned reg = I->reg; 00785 prt_->addRegUse(reg); 00786 SpillWeightsToAdd.push_back(std::make_pair(reg, I->weight)); 00787 } 00788 } 00789 } 00790 00791 // Using the newly updated prt_ object, which includes conflicts in the 00792 // future, see if there are any registers available. 00793 physReg = getFreePhysReg(cur); 00794 } 00795 } 00796 00797 // Restore the physical register tracker, removing information about the 00798 // future. 00799 *prt_ = backupPrt; 00800 00801 // if we find a free register, we are done: assign this virtual to 00802 // the free physical register and add this interval to the active 00803 // list. 00804 if (physReg) { 00805 DOUT << tri_->getName(physReg) << '\n'; 00806 vrm_->assignVirt2Phys(cur->reg, physReg); 00807 prt_->addRegUse(physReg); 00808 active_.push_back(std::make_pair(cur, cur->begin())); 00809 handled_.push_back(cur); 00810 return; 00811 } 00812 DOUT << "no free registers\n"; 00813 00814 // Compile the spill weights into an array that is better for scanning. 00815 std::vector<float> SpillWeights(tri_->getNumRegs(), 0.0f); 00816 for (std::vector<std::pair<unsigned, float> >::iterator 00817 I = SpillWeightsToAdd.begin(), E = SpillWeightsToAdd.end(); I != E; ++I) 00818 updateSpillWeights(SpillWeights, I->first, I->second, tri_); 00819 00820 // for each interval in active, update spill weights. 00821 for (IntervalPtrs::const_iterator i = active_.begin(), e = active_.end(); 00822 i != e; ++i) { 00823 unsigned reg = i->first->reg; 00824 assert(TargetRegisterInfo::isVirtualRegister(reg) && 00825 "Can only allocate virtual registers!"); 00826 reg = vrm_->getPhys(reg); 00827 updateSpillWeights(SpillWeights, reg, i->first->weight, tri_); 00828 } 00829 00830 DOUT << "\tassigning stack slot at interval "<< *cur << ":\n"; 00831 00832 // Find a register to spill. 00833 float minWeight = HUGE_VALF; 00834 unsigned minReg = 0; /*cur->preference*/; // Try the preferred register first. 00835 00836 bool Found = false; 00837 std::vector<std::pair<unsigned,float> > RegsWeights; 00838 if (!minReg || SpillWeights[minReg] == HUGE_VALF) 00839 for (TargetRegisterClass::iterator i = RC->allocation_order_begin(*mf_), 00840 e = RC->allocation_order_end(*mf_); i != e; ++i) { 00841 unsigned reg = *i; 00842 float regWeight = SpillWeights[reg]; 00843 if (minWeight > regWeight) 00844 Found = true; 00845 RegsWeights.push_back(std::make_pair(reg, regWeight)); 00846 } 00847 00848 // If we didn't find a register that is spillable, try aliases? 00849 if (!Found) { 00850 for (TargetRegisterClass::iterator i = RC->allocation_order_begin(*mf_), 00851 e = RC->allocation_order_end(*mf_); i != e; ++i) { 00852 unsigned reg = *i; 00853 // No need to worry about if the alias register size < regsize of RC. 00854 // We are going to spill all registers that alias it anyway. 00855 for (const unsigned* as = tri_->getAliasSet(reg); *as; ++as) 00856 RegsWeights.push_back(std::make_pair(*as, SpillWeights[*as])); 00857 } 00858 } 00859 00860 // Sort all potential spill candidates by weight. 00861 std::sort(RegsWeights.begin(), RegsWeights.end(), WeightCompare()); 00862 minReg = RegsWeights[0].first; 00863 minWeight = RegsWeights[0].second; 00864 if (minWeight == HUGE_VALF) { 00865 // All registers must have inf weight. Just grab one! 00866 minReg = BestPhysReg ? BestPhysReg : *RC->allocation_order_begin(*mf_); 00867 if (cur->weight == HUGE_VALF || 00868 li_->getApproximateInstructionCount(*cur) == 0) { 00869 // Spill a physical register around defs and uses. 00870 li_->spillPhysRegAroundRegDefsUses(*cur, minReg, *vrm_); 00871 assignRegOrStackSlotAtInterval(cur); 00872 return; 00873 } 00874 } 00875 00876 // Find up to 3 registers to consider as spill candidates. 00877 unsigned LastCandidate = RegsWeights.size() >= 3 ? 3 : 1; 00878 while (LastCandidate > 1) { 00879 if (weightsAreClose(RegsWeights[LastCandidate-1].second, minWeight)) 00880 break; 00881 --LastCandidate; 00882 } 00883 00884 DOUT << "\t\tregister(s) with min weight(s): "; 00885 DEBUG(for (unsigned i = 0; i != LastCandidate; ++i) 00886 DOUT << tri_->getName(RegsWeights[i].first) 00887 << " (" << RegsWeights[i].second << ")\n"); 00888 00889 // if the current has the minimum weight, we need to spill it and 00890 // add any added intervals back to unhandled, and restart 00891 // linearscan. 00892 if (cur->weight != HUGE_VALF && cur->weight <= minWeight) { 00893 DOUT << "\t\t\tspilling(c): " << *cur << '\n'; 00894 float SSWeight; 00895 SmallVector<LiveInterval*, 8> spillIs; 00896 std::vector<LiveInterval*> added = 00897 li_->addIntervalsForSpills(*cur, spillIs, loopInfo, *vrm_, SSWeight); 00898 addStackInterval(cur, ls_, li_, SSWeight, *vrm_); 00899 if (added.empty()) 00900 return; // Early exit if all spills were folded. 00901 00902 // Merge added with unhandled. Note that we know that 00903 // addIntervalsForSpills returns intervals sorted by their starting 00904 // point. 00905 for (unsigned i = 0, e = added.size(); i != e; ++i) 00906 unhandled_.push(added[i]); 00907 return; 00908 } 00909 00910 ++NumBacktracks; 00911 00912 // push the current interval back to unhandled since we are going 00913 // to re-run at least this iteration. Since we didn't modify it it 00914 // should go back right in the front of the list 00915 unhandled_.push(cur); 00916 00917 assert(TargetRegisterInfo::isPhysicalRegister(minReg) && 00918 "did not choose a register to spill?"); 00919 00920 // We spill all intervals aliasing the register with 00921 // minimum weight, rollback to the interval with the earliest 00922 // start point and let the linear scan algorithm run again 00923 SmallVector<LiveInterval*, 8> spillIs; 00924 00925 // Determine which intervals have to be spilled. 00926 findIntervalsToSpill(cur, RegsWeights, LastCandidate, spillIs); 00927 00928 // Set of spilled vregs (used later to rollback properly) 00929 SmallSet<unsigned, 8> spilled; 00930 00931 // The earliest start of a Spilled interval indicates up to where 00932 // in handled we need to roll back 00933 unsigned earliestStart = cur->beginNumber(); 00934 00935 // Spill live intervals of virtual regs mapped to the physical register we 00936 // want to clear (and its aliases). We only spill those that overlap with the 00937 // current interval as the rest do not affect its allocation. we also keep 00938 // track of the earliest start of all spilled live intervals since this will 00939 // mark our rollback point. 00940 std::vector<LiveInterval*> added; 00941 while (!spillIs.empty()) { 00942 LiveInterval *sli = spillIs.back(); 00943 spillIs.pop_back(); 00944 DOUT << "\t\t\tspilling(a): " << *sli << '\n'; 00945 earliestStart = std::min(earliestStart, sli->beginNumber()); 00946 float SSWeight; 00947 std::vector<LiveInterval*> newIs = 00948 li_->addIntervalsForSpills(*sli, spillIs, loopInfo, *vrm_, SSWeight); 00949 addStackInterval(sli, ls_, li_, SSWeight, *vrm_); 00950 std::copy(newIs.begin(), newIs.end(), std::back_inserter(added)); 00951 spilled.insert(sli->reg); 00952 } 00953 00954 DOUT << "\t\trolling back to: " << earliestStart << '\n'; 00955 00956 // Scan handled in reverse order up to the earliest start of a 00957 // spilled live interval and undo each one, restoring the state of 00958 // unhandled. 00959 while (!handled_.empty()) { 00960 LiveInterval* i = handled_.back(); 00961 // If this interval starts before t we are done. 00962 if (i->beginNumber() < earliestStart) 00963 break; 00964 DOUT << "\t\t\tundo changes for: " << *i << '\n'; 00965 handled_.pop_back(); 00966 00967 // When undoing a live interval allocation we must know if it is active or 00968 // inactive to properly update the PhysRegTracker and the VirtRegMap. 00969 IntervalPtrs::iterator it; 00970 if ((it = FindIntervalInVector(active_, i)) != active_.end()) { 00971 active_.erase(it); 00972 assert(!TargetRegisterInfo::isPhysicalRegister(i->reg)); 00973 if (!spilled.count(i->reg)) 00974 unhandled_.push(i); 00975 prt_->delRegUse(vrm_->getPhys(i->reg)); 00976 vrm_->clearVirt(i->reg); 00977 } else if ((it = FindIntervalInVector(inactive_, i)) != inactive_.end()) { 00978 inactive_.erase(it); 00979 assert(!TargetRegisterInfo::isPhysicalRegister(i->reg)); 00980 if (!spilled.count(i->reg)) 00981 unhandled_.push(i); 00982 vrm_->clearVirt(i->reg); 00983 } else { 00984 assert(TargetRegisterInfo::isVirtualRegister(i->reg) && 00985 "Can only allocate virtual registers!"); 00986 vrm_->clearVirt(i->reg); 00987 unhandled_.push(i); 00988 } 00989 00990 // It interval has a preference, it must be defined by a copy. Clear the 00991 // preference now since the source interval allocation may have been undone 00992 // as well. 00993 i->preference = 0; 00994 } 00995 00996 // Rewind the iterators in the active, inactive, and fixed lists back to the 00997 // point we reverted to. 00998 RevertVectorIteratorsTo(active_, earliestStart); 00999 RevertVectorIteratorsTo(inactive_, earliestStart); 01000 RevertVectorIteratorsTo(fixed_, earliestStart); 01001 01002 // scan the rest and undo each interval that expired after t and 01003 // insert it in active (the next iteration of the algorithm will 01004 // put it in inactive if required) 01005 for (unsigned i = 0, e = handled_.size(); i != e; ++i) { 01006 LiveInterval *HI = handled_[i]; 01007 if (!HI->expiredAt(earliestStart) && 01008 HI->expiredAt(cur->beginNumber())) { 01009 DOUT << "\t\t\tundo changes for: " << *HI << '\n'; 01010 active_.push_back(std::make_pair(HI, HI->begin())); 01011 assert(!TargetRegisterInfo::isPhysicalRegister(HI->reg)); 01012 prt_->addRegUse(vrm_->getPhys(HI->reg)); 01013 } 01014 } 01015 01016 // merge added with unhandled 01017 for (unsigned i = 0, e = added.size(); i != e; ++i) 01018 unhandled_.push(added[i]); 01019 } 01020 01021 /// getFreePhysReg - return a free physical register for this virtual register 01022 /// interval if we have one, otherwise return 0. 01023 unsigned RALinScan::getFreePhysReg(LiveInterval *cur) { 01024 SmallVector<unsigned, 256> inactiveCounts; 01025 unsigned MaxInactiveCount = 0; 01026 01027 const TargetRegisterClass *RC = mri_->getRegClass(cur->reg); 01028 const TargetRegisterClass *RCLeader = RelatedRegClasses.getLeaderValue(RC); 01029 01030 for (IntervalPtrs::iterator i = inactive_.begin(), e = inactive_.end(); 01031 i != e; ++i) { 01032 unsigned reg = i->first->reg; 01033 assert(TargetRegisterInfo::isVirtualRegister(reg) && 01034 "Can only allocate virtual registers!"); 01035 01036 // If this is not in a related reg class to the register we're allocating, 01037 // don't check it. 01038 const TargetRegisterClass *RegRC = mri_->getRegClass(reg); 01039 if (RelatedRegClasses.getLeaderValue(RegRC) == RCLeader) { 01040 reg = vrm_->getPhys(reg); 01041 if (inactiveCounts.size() <= reg) 01042 inactiveCounts.resize(reg+1); 01043 ++inactiveCounts[reg]; 01044 MaxInactiveCount = std::max(MaxInactiveCount, inactiveCounts[reg]); 01045 } 01046 } 01047 01048 unsigned FreeReg = 0; 01049 unsigned FreeRegInactiveCount = 0; 01050 01051 // If copy coalescer has assigned a "preferred" register, check if it's 01052 // available first. 01053 if (cur->preference) { 01054 if (prt_->isRegAvail(cur->preference) && 01055 RC->contains(cur->preference)) { 01056 DOUT << "\t\tassigned the preferred register: " 01057 << tri_->getName(cur->preference) << "\n"; 01058 return cur->preference; 01059 } else 01060 DOUT << "\t\tunable to assign the preferred register: " 01061 << tri_->getName(cur->preference) << "\n"; 01062 } 01063 01064 // Scan for the first available register. 01065 TargetRegisterClass::iterator I = RC->allocation_order_begin(*mf_); 01066 TargetRegisterClass::iterator E = RC->allocation_order_end(*mf_); 01067 assert(I != E && "No allocatable register in this register class!"); 01068 for (; I != E; ++I) 01069 if (prt_->isRegAvail(*I)) { 01070 FreeReg = *I; 01071 if (FreeReg < inactiveCounts.size()) 01072 FreeRegInactiveCount = inactiveCounts[FreeReg]; 01073 else 01074 FreeRegInactiveCount = 0; 01075 break; 01076 } 01077 01078 // If there are no free regs, or if this reg has the max inactive count, 01079 // return this register. 01080 if (FreeReg == 0 || FreeRegInactiveCount == MaxInactiveCount) return FreeReg; 01081 01082 // Continue scanning the registers, looking for the one with the highest 01083 // inactive count. Alkis found that this reduced register pressure very 01084 // slightly on X86 (in rev 1.94 of this file), though this should probably be 01085 // reevaluated now. 01086 for (; I != E; ++I) { 01087 unsigned Reg = *I; 01088 if (prt_->isRegAvail(Reg) && Reg < inactiveCounts.size() && 01089 FreeRegInactiveCount < inactiveCounts[Reg]) { 01090 FreeReg = Reg; 01091 FreeRegInactiveCount = inactiveCounts[Reg]; 01092 if (FreeRegInactiveCount == MaxInactiveCount) 01093 break; // We found the one with the max inactive count. 01094 } 01095 } 01096 01097 return FreeReg; 01098 } 01099 01100 FunctionPass* llvm::createLinearScanRegisterAllocator() { 01101 return new RALinScan(); 01102 }