blob: cd77d1364072e64bae1b1bef87051e6d73dbab65 [file] [log] [blame]
Andrew Trick14e8d712010-10-22 23:09:15 +00001//===-- RegAllocBasic.cpp - basic register allocator ----------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the RABasic function pass, which provides a minimal
11// implementation of the basic register allocator.
12//
13//===----------------------------------------------------------------------===//
14
15#define DEBUG_TYPE "regalloc"
Andrew Tricke16eecc2010-10-26 18:34:01 +000016#include "LiveIntervalUnion.h"
Andrew Trick14e8d712010-10-22 23:09:15 +000017#include "RegAllocBase.h"
18#include "RenderMachineFunction.h"
19#include "Spiller.h"
Andrew Tricke141a492010-11-08 18:02:08 +000020#include "VirtRegMap.h"
Andrew Trick14e8d712010-10-22 23:09:15 +000021#include "VirtRegRewriter.h"
22#include "llvm/Function.h"
23#include "llvm/PassAnalysisSupport.h"
24#include "llvm/CodeGen/CalcSpillWeights.h"
Andrew Tricke141a492010-11-08 18:02:08 +000025#include "llvm/CodeGen/LiveIntervalAnalysis.h"
Andrew Trick14e8d712010-10-22 23:09:15 +000026#include "llvm/CodeGen/LiveStackAnalysis.h"
27#include "llvm/CodeGen/MachineFunctionPass.h"
28#include "llvm/CodeGen/MachineInstr.h"
29#include "llvm/CodeGen/MachineLoopInfo.h"
30#include "llvm/CodeGen/MachineRegisterInfo.h"
31#include "llvm/CodeGen/Passes.h"
32#include "llvm/CodeGen/RegAllocRegistry.h"
33#include "llvm/CodeGen/RegisterCoalescer.h"
34#include "llvm/Target/TargetMachine.h"
35#include "llvm/Target/TargetOptions.h"
Andrew Tricke16eecc2010-10-26 18:34:01 +000036#include "llvm/Target/TargetRegisterInfo.h"
Andrew Trick071d1c02010-11-09 21:04:34 +000037#ifndef NDEBUG
38#include "llvm/ADT/SparseBitVector.h"
39#endif
Andrew Tricke141a492010-11-08 18:02:08 +000040#include "llvm/Support/Debug.h"
41#include "llvm/Support/ErrorHandling.h"
42#include "llvm/Support/raw_ostream.h"
Andrew Tricke16eecc2010-10-26 18:34:01 +000043
44#include <vector>
45#include <queue>
46
Andrew Trick14e8d712010-10-22 23:09:15 +000047using namespace llvm;
48
49static RegisterRegAlloc basicRegAlloc("basic", "basic register allocator",
50 createBasicRegisterAllocator);
51
Andrew Trick071d1c02010-11-09 21:04:34 +000052// Temporary verification option until we can put verification inside
53// MachineVerifier.
54static cl::opt<bool>
55VerifyRegAlloc("verify-regalloc",
56 cl::desc("Verify live intervals before renaming"));
57
58class PhysicalRegisterDescription : public AbstractRegisterDescription {
59 const TargetRegisterInfo *tri_;
60public:
61 PhysicalRegisterDescription(const TargetRegisterInfo *tri): tri_(tri) {}
62 virtual const char *getName(unsigned reg) const { return tri_->getName(reg); }
63};
64
Andrew Trick14e8d712010-10-22 23:09:15 +000065namespace {
66
67/// RABasic provides a minimal implementation of the basic register allocation
68/// algorithm. It prioritizes live virtual registers by spill weight and spills
69/// whenever a register is unavailable. This is not practical in production but
70/// provides a useful baseline both for measuring other allocators and comparing
71/// the speed of the basic algorithm against other styles of allocators.
72class RABasic : public MachineFunctionPass, public RegAllocBase
73{
74 // context
75 MachineFunction *mf_;
76 const TargetMachine *tm_;
77 MachineRegisterInfo *mri_;
78
79 // analyses
80 LiveStacks *ls_;
81 RenderMachineFunction *rmf_;
82
83 // state
84 std::auto_ptr<Spiller> spiller_;
85
86public:
87 RABasic();
88
89 /// Return the pass name.
90 virtual const char* getPassName() const {
91 return "Basic Register Allocator";
92 }
93
94 /// RABasic analysis usage.
95 virtual void getAnalysisUsage(AnalysisUsage &au) const;
96
97 virtual void releaseMemory();
98
Andrew Tricke16eecc2010-10-26 18:34:01 +000099 virtual unsigned selectOrSplit(LiveInterval &lvr,
100 SmallVectorImpl<LiveInterval*> &splitLVRs);
Andrew Trick14e8d712010-10-22 23:09:15 +0000101
Andrew Tricke141a492010-11-08 18:02:08 +0000102 void spillInterferences(unsigned preg,
103 SmallVectorImpl<LiveInterval*> &splitLVRs);
104
Andrew Trick14e8d712010-10-22 23:09:15 +0000105 /// Perform register allocation.
106 virtual bool runOnMachineFunction(MachineFunction &mf);
107
108 static char ID;
109};
110
111char RABasic::ID = 0;
112
113} // end anonymous namespace
114
115// We should not need to publish the initializer as long as no other passes
116// require RABasic.
117#if 0 // disable INITIALIZE_PASS
118INITIALIZE_PASS_BEGIN(RABasic, "basic-regalloc",
119 "Basic Register Allocator", false, false)
120INITIALIZE_PASS_DEPENDENCY(LiveIntervals)
121INITIALIZE_PASS_DEPENDENCY(StrongPHIElimination)
122INITIALIZE_AG_DEPENDENCY(RegisterCoalescer)
123INITIALIZE_PASS_DEPENDENCY(CalculateSpillWeights)
124INITIALIZE_PASS_DEPENDENCY(LiveStacks)
125INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo)
126INITIALIZE_PASS_DEPENDENCY(VirtRegMap)
127#ifndef NDEBUG
128INITIALIZE_PASS_DEPENDENCY(RenderMachineFunction)
129#endif
130INITIALIZE_PASS_END(RABasic, "basic-regalloc",
131 "Basic Register Allocator", false, false)
Andrew Tricke16eecc2010-10-26 18:34:01 +0000132#endif // disable INITIALIZE_PASS
Andrew Trick14e8d712010-10-22 23:09:15 +0000133
134RABasic::RABasic(): MachineFunctionPass(ID) {
135 initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
136 initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
137 initializeStrongPHIEliminationPass(*PassRegistry::getPassRegistry());
138 initializeRegisterCoalescerAnalysisGroup(*PassRegistry::getPassRegistry());
139 initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry());
140 initializeLiveStacksPass(*PassRegistry::getPassRegistry());
Jakob Stoklund Olesen964bc252010-11-03 20:39:26 +0000141 initializeMachineDominatorTreePass(*PassRegistry::getPassRegistry());
Andrew Trick14e8d712010-10-22 23:09:15 +0000142 initializeMachineLoopInfoPass(*PassRegistry::getPassRegistry());
143 initializeVirtRegMapPass(*PassRegistry::getPassRegistry());
144 initializeRenderMachineFunctionPass(*PassRegistry::getPassRegistry());
145}
146
147void RABasic::getAnalysisUsage(AnalysisUsage &au) const {
148 au.setPreservesCFG();
149 au.addRequired<LiveIntervals>();
150 au.addPreserved<SlotIndexes>();
151 if (StrongPHIElim)
152 au.addRequiredID(StrongPHIEliminationID);
153 au.addRequiredTransitive<RegisterCoalescer>();
154 au.addRequired<CalculateSpillWeights>();
155 au.addRequired<LiveStacks>();
156 au.addPreserved<LiveStacks>();
Jakob Stoklund Olesen964bc252010-11-03 20:39:26 +0000157 au.addRequiredID(MachineDominatorsID);
158 au.addPreservedID(MachineDominatorsID);
Andrew Trick14e8d712010-10-22 23:09:15 +0000159 au.addRequired<MachineLoopInfo>();
160 au.addPreserved<MachineLoopInfo>();
161 au.addRequired<VirtRegMap>();
162 au.addPreserved<VirtRegMap>();
163 DEBUG(au.addRequired<RenderMachineFunction>());
164 MachineFunctionPass::getAnalysisUsage(au);
165}
166
167void RABasic::releaseMemory() {
168 spiller_.reset(0);
169 RegAllocBase::releaseMemory();
170}
171
Andrew Trick071d1c02010-11-09 21:04:34 +0000172#ifndef NDEBUG
173// Verify each LiveIntervalUnion.
174void RegAllocBase::verify() {
175 LvrBitSet visitedVRegs;
176 OwningArrayPtr<LvrBitSet> unionVRegs(new LvrBitSet[physReg2liu_.numRegs()]);
177 // Verify disjoint unions.
178 for (unsigned preg = 0; preg < physReg2liu_.numRegs(); ++preg) {
179 DEBUG(PhysicalRegisterDescription prd(tri_); physReg2liu_[preg].dump(&prd));
180 LvrBitSet &vregs = unionVRegs[preg];
181 physReg2liu_[preg].verify(vregs);
182 // Union + intersection test could be done efficiently in one pass, but
183 // don't add a method to SparseBitVector unless we really need it.
184 assert(!visitedVRegs.intersects(vregs) && "vreg in multiple unions");
185 visitedVRegs |= vregs;
186 }
187 // Verify vreg coverage.
188 for (LiveIntervals::iterator liItr = lis_->begin(), liEnd = lis_->end();
189 liItr != liEnd; ++liItr) {
190 unsigned reg = liItr->first;
191 LiveInterval &li = *liItr->second;
192 if (li.empty() ) continue;
193 if (TargetRegisterInfo::isPhysicalRegister(reg)) continue;
194 if (!vrm_->hasPhys(reg)) continue; // spilled?
195 unsigned preg = vrm_->getPhys(reg);
196 if (!unionVRegs[preg].test(reg)) {
197 dbgs() << "LiveVirtReg " << reg << " not in union " <<
198 tri_->getName(preg) << "\n";
199 llvm_unreachable("unallocated live vreg");
200 }
201 }
202 // FIXME: I'm not sure how to verify spilled intervals.
203}
204#endif //!NDEBUG
205
Andrew Trick14e8d712010-10-22 23:09:15 +0000206//===----------------------------------------------------------------------===//
207// RegAllocBase Implementation
208//===----------------------------------------------------------------------===//
209
210// Instantiate a LiveIntervalUnion for each physical register.
211void RegAllocBase::LIUArray::init(unsigned nRegs) {
212 array_.reset(new LiveIntervalUnion[nRegs]);
213 nRegs_ = nRegs;
214 for (unsigned pr = 0; pr < nRegs; ++pr) {
215 array_[pr].init(pr);
216 }
217}
218
219void RegAllocBase::init(const TargetRegisterInfo &tri, VirtRegMap &vrm,
220 LiveIntervals &lis) {
221 tri_ = &tri;
222 vrm_ = &vrm;
223 lis_ = &lis;
224 physReg2liu_.init(tri_->getNumRegs());
Andrew Tricke141a492010-11-08 18:02:08 +0000225 // Cache an interferece query for each physical reg
226 queries_.reset(new LiveIntervalUnion::Query[physReg2liu_.numRegs()]);
Andrew Trick14e8d712010-10-22 23:09:15 +0000227}
228
229void RegAllocBase::LIUArray::clear() {
230 nRegs_ = 0;
231 array_.reset(0);
232}
233
234void RegAllocBase::releaseMemory() {
235 physReg2liu_.clear();
236}
237
Andrew Tricke16eecc2010-10-26 18:34:01 +0000238namespace llvm {
239/// This class defines a queue of live virtual registers prioritized by spill
240/// weight. The heaviest vreg is popped first.
241///
242/// Currently, this is trivial wrapper that gives us an opaque type in the
243/// header, but we may later give it a virtual interface for register allocators
244/// to override the priority queue comparator.
245class LiveVirtRegQueue {
246 typedef std::priority_queue
247 <LiveInterval*, std::vector<LiveInterval*>, LessSpillWeightPriority> PQ;
248 PQ pq_;
249
250public:
251 // Is the queue empty?
252 bool empty() { return pq_.empty(); }
253
254 // Get the highest priority lvr (top + pop)
255 LiveInterval *get() {
256 LiveInterval *lvr = pq_.top();
257 pq_.pop();
258 return lvr;
259 }
260 // Add this lvr to the queue
261 void push(LiveInterval *lvr) {
262 pq_.push(lvr);
263 }
264};
265} // end namespace llvm
266
267// Visit all the live virtual registers. If they are already assigned to a
268// physical register, unify them with the corresponding LiveIntervalUnion,
269// otherwise push them on the priority queue for later assignment.
270void RegAllocBase::seedLiveVirtRegs(LiveVirtRegQueue &lvrQ) {
271 for (LiveIntervals::iterator liItr = lis_->begin(), liEnd = lis_->end();
272 liItr != liEnd; ++liItr) {
273 unsigned reg = liItr->first;
274 LiveInterval &li = *liItr->second;
Andrew Trick071d1c02010-11-09 21:04:34 +0000275 if (li.empty()) continue;
Andrew Tricke16eecc2010-10-26 18:34:01 +0000276 if (TargetRegisterInfo::isPhysicalRegister(reg)) {
277 physReg2liu_[reg].unify(li);
278 }
279 else {
280 lvrQ.push(&li);
281 }
282 }
283}
284
285// Top-level driver to manage the queue of unassigned LiveVirtRegs and call the
286// selectOrSplit implementation.
287void RegAllocBase::allocatePhysRegs() {
288 LiveVirtRegQueue lvrQ;
289 seedLiveVirtRegs(lvrQ);
290 while (!lvrQ.empty()) {
291 LiveInterval *lvr = lvrQ.get();
292 typedef SmallVector<LiveInterval*, 4> LVRVec;
293 LVRVec splitLVRs;
294 unsigned availablePhysReg = selectOrSplit(*lvr, splitLVRs);
295 if (availablePhysReg) {
Andrew Tricke141a492010-11-08 18:02:08 +0000296 DEBUG(dbgs() << "allocating: " << tri_->getName(availablePhysReg) <<
Andrew Trick071d1c02010-11-09 21:04:34 +0000297 " " << *lvr << '\n');
Andrew Tricke16eecc2010-10-26 18:34:01 +0000298 assert(!vrm_->hasPhys(lvr->reg) && "duplicate vreg in interval unions");
299 vrm_->assignVirt2Phys(lvr->reg, availablePhysReg);
300 physReg2liu_[availablePhysReg].unify(*lvr);
301 }
Andrew Tricke141a492010-11-08 18:02:08 +0000302 for (LVRVec::iterator lvrI = splitLVRs.begin(), lvrEnd = splitLVRs.end();
303 lvrI != lvrEnd; ++lvrI) {
Andrew Trick071d1c02010-11-09 21:04:34 +0000304 if ((*lvrI)->empty()) continue;
Andrew Tricke141a492010-11-08 18:02:08 +0000305 DEBUG(dbgs() << "queuing new interval: " << **lvrI << "\n");
306 assert(TargetRegisterInfo::isVirtualRegister((*lvrI)->reg) &&
307 "expect split value in virtual register");
308 lvrQ.push(*lvrI);
Andrew Tricke16eecc2010-10-26 18:34:01 +0000309 }
310 }
311}
312
Andrew Trick14e8d712010-10-22 23:09:15 +0000313// Check if this live virtual reg interferes with a physical register. If not,
314// then check for interference on each register that aliases with the physical
Andrew Tricke141a492010-11-08 18:02:08 +0000315// register. Return the interfering register.
316unsigned RegAllocBase::checkPhysRegInterference(LiveInterval &lvr,
317 unsigned preg) {
318 queries_[preg].init(&lvr, &physReg2liu_[preg]);
319 if (queries_[preg].checkInterference())
320 return preg;
Andrew Trick14e8d712010-10-22 23:09:15 +0000321 for (const unsigned *asI = tri_->getAliasSet(preg); *asI; ++asI) {
Andrew Tricke141a492010-11-08 18:02:08 +0000322 queries_[*asI].init(&lvr, &physReg2liu_[*asI]);
323 if (queries_[*asI].checkInterference())
324 return *asI;
Andrew Trick14e8d712010-10-22 23:09:15 +0000325 }
Andrew Tricke141a492010-11-08 18:02:08 +0000326 return 0;
327}
328
Andrew Trick071d1c02010-11-09 21:04:34 +0000329// Spill or split all live virtual registers currently unified under preg that
330// interfere with lvr. The newly spilled or split live intervals are returned by
331// appending them to splitLVRs.
Andrew Tricke141a492010-11-08 18:02:08 +0000332void RABasic::spillInterferences(unsigned preg,
333 SmallVectorImpl<LiveInterval*> &splitLVRs) {
334 SmallPtrSet<LiveInterval*, 8> spilledLVRs;
335 LiveIntervalUnion::Query &query = queries_[preg];
Andrew Trick071d1c02010-11-09 21:04:34 +0000336 // Record each interference before mutating either the union or live
337 // intervals.
Andrew Tricke141a492010-11-08 18:02:08 +0000338 LiveIntervalUnion::InterferenceResult ir = query.firstInterference();
339 assert(query.isInterference(ir) && "expect interference");
340 do {
Andrew Trick071d1c02010-11-09 21:04:34 +0000341 spilledLVRs.insert(ir.liuSegPos()->liveVirtReg);
Andrew Tricke141a492010-11-08 18:02:08 +0000342 } while (query.nextInterference(ir));
343 for (SmallPtrSetIterator<LiveInterval*> lvrI = spilledLVRs.begin(),
344 lvrEnd = spilledLVRs.end();
345 lvrI != lvrEnd; ++lvrI ) {
Andrew Trick071d1c02010-11-09 21:04:34 +0000346 LiveInterval& lvr = **lvrI;
347 // Spill the previously allocated lvr.
348 DEBUG(dbgs() << "extracting from " << preg << " " << lvr << '\n');
Andrew Tricke141a492010-11-08 18:02:08 +0000349 // Deallocate the interfering lvr by removing it from the preg union.
Andrew Trick071d1c02010-11-09 21:04:34 +0000350 // Live intervals may not be in a union during modification.
351 physReg2liu_[preg].extract(lvr);
352 // Spill the extracted interval.
353 SmallVector<LiveInterval*, 8> spillIs;
354 spiller_->spill(&lvr, splitLVRs, spillIs);
Andrew Tricke141a492010-11-08 18:02:08 +0000355 }
356 // After extracting segments, the query's results are invalid.
357 query.clear();
Andrew Trick14e8d712010-10-22 23:09:15 +0000358}
359
360//===----------------------------------------------------------------------===//
361// RABasic Implementation
362//===----------------------------------------------------------------------===//
363
364// Driver for the register assignment and splitting heuristics.
365// Manages iteration over the LiveIntervalUnions.
366//
367// Minimal implementation of register assignment and splitting--spills whenever
368// we run out of registers.
369//
370// selectOrSplit can only be called once per live virtual register. We then do a
371// single interference test for each register the correct class until we find an
372// available register. So, the number of interference tests in the worst case is
373// |vregs| * |machineregs|. And since the number of interference tests is
374// minimal, there is no value in caching them.
Andrew Tricke16eecc2010-10-26 18:34:01 +0000375unsigned RABasic::selectOrSplit(LiveInterval &lvr,
376 SmallVectorImpl<LiveInterval*> &splitLVRs) {
Andrew Tricke141a492010-11-08 18:02:08 +0000377 // Accumulate the min spill cost among the interferences, in case we spill.
378 unsigned minSpillReg = 0;
379 unsigned minSpillAlias = 0;
380 float minSpillWeight = lvr.weight;
381
Andrew Trick14e8d712010-10-22 23:09:15 +0000382 // Check for an available reg in this class.
383 const TargetRegisterClass *trc = mri_->getRegClass(lvr.reg);
384 for (TargetRegisterClass::iterator trcI = trc->allocation_order_begin(*mf_),
385 trcEnd = trc->allocation_order_end(*mf_);
386 trcI != trcEnd; ++trcI) {
387 unsigned preg = *trcI;
Andrew Tricke141a492010-11-08 18:02:08 +0000388 unsigned interfReg = checkPhysRegInterference(lvr, preg);
389 if (interfReg == 0) {
Andrew Trick14e8d712010-10-22 23:09:15 +0000390 return preg;
391 }
Andrew Tricke141a492010-11-08 18:02:08 +0000392 LiveIntervalUnion::InterferenceResult interf =
393 queries_[interfReg].firstInterference();
394 float interfWeight = interf.liuSegPos()->liveVirtReg->weight;
395 if (interfWeight < minSpillWeight ) {
396 minSpillReg = interfReg;
397 minSpillAlias = preg;
398 minSpillWeight = interfWeight;
399 }
Andrew Trick14e8d712010-10-22 23:09:15 +0000400 }
Andrew Tricke141a492010-11-08 18:02:08 +0000401 if (minSpillReg == 0) {
402 DEBUG(dbgs() << "spilling: " << lvr << '\n');
403 SmallVector<LiveInterval*, 1> spillIs; // ignored
404 spiller_->spill(&lvr, splitLVRs, spillIs);
405 // The live virtual register requesting to be allocated was spilled. So tell
406 // the caller not to allocate anything for this round.
407 return 0;
408 }
409 // Free the cheapest physical register.
410 spillInterferences(minSpillReg, splitLVRs);
411 // Tell the caller to allocate to this newly freed physical register.
412 assert(minSpillAlias != 0 && "need a free register after spilling");
413 // We just spilled the first register that interferes with minSpillAlias. We
414 // now assume minSpillAlias is free because only one register alias may
415 // interfere at a time. e.g. we ignore predication.
416 unsigned interfReg = checkPhysRegInterference(lvr, minSpillAlias);
417 if (interfReg != 0) {
418 dbgs() << "spilling cannot free " << tri_->getName(minSpillAlias) <<
419 " for " << lvr.reg << " with interference " <<
420 *queries_[interfReg].firstInterference().liuSegPos()->liveVirtReg << "\n";
421 llvm_unreachable("Interference after spill.");
422 }
423 return minSpillAlias;
424}
Andrew Trick14e8d712010-10-22 23:09:15 +0000425
Andrew Tricke141a492010-11-08 18:02:08 +0000426namespace llvm {
427Spiller *createInlineSpiller(MachineFunctionPass &pass,
428 MachineFunction &mf,
429 VirtRegMap &vrm);
Andrew Trick14e8d712010-10-22 23:09:15 +0000430}
431
432bool RABasic::runOnMachineFunction(MachineFunction &mf) {
433 DEBUG(dbgs() << "********** BASIC REGISTER ALLOCATION **********\n"
434 << "********** Function: "
435 << ((Value*)mf.getFunction())->getName() << '\n');
436
437 mf_ = &mf;
438 tm_ = &mf.getTarget();
439 mri_ = &mf.getRegInfo();
440
441 DEBUG(rmf_ = &getAnalysis<RenderMachineFunction>());
442
443 RegAllocBase::init(*tm_->getRegisterInfo(), getAnalysis<VirtRegMap>(),
444 getAnalysis<LiveIntervals>());
445
Andrew Tricke141a492010-11-08 18:02:08 +0000446 // We may want to force InlineSpiller for this register allocator. For
447 // now we're also experimenting with the standard spiller.
448 //
449 //spiller_.reset(createInlineSpiller(*this, *mf_, *vrm_));
Andrew Trick14e8d712010-10-22 23:09:15 +0000450 spiller_.reset(createSpiller(*this, *mf_, *vrm_));
451
Andrew Tricke16eecc2010-10-26 18:34:01 +0000452 allocatePhysRegs();
Andrew Trick14e8d712010-10-22 23:09:15 +0000453
454 // Diagnostic output before rewriting
455 DEBUG(dbgs() << "Post alloc VirtRegMap:\n" << *vrm_ << "\n");
456
457 // optional HTML output
458 DEBUG(rmf_->renderMachineFunction("After basic register allocation.", vrm_));
459
Andrew Trick071d1c02010-11-09 21:04:34 +0000460 // FIXME: Verification currently must run before VirtRegRewriter. We should
461 // make the rewriter a separate pass and override verifyAnalysis instead. When
462 // that happens, verification naturally falls under VerifyMachineCode.
463#ifndef NDEBUG
464 if (VerifyRegAlloc) {
465 // Verify accuracy of LiveIntervals. The standard machine code verifier
466 // ensures that each LiveIntervals covers all uses of the virtual reg.
467
468 // FIXME: MachineVerifier is currently broken when using the standard
469 // spiller. Enable it for InlineSpiller only.
470 // mf_->verify(this);
471
472 // Verify that LiveIntervals are partitioned into unions and disjoint within
473 // the unions.
474 verify();
475 }
476#endif // !NDEBUG
477
Andrew Trick14e8d712010-10-22 23:09:15 +0000478 // Run rewriter
479 std::auto_ptr<VirtRegRewriter> rewriter(createVirtRegRewriter());
480 rewriter->runOnMachineFunction(*mf_, *vrm_, lis_);
Andrew Tricke16eecc2010-10-26 18:34:01 +0000481
482 // The pass output is in VirtRegMap. Release all the transient data.
483 releaseMemory();
Andrew Trick14e8d712010-10-22 23:09:15 +0000484
485 return true;
486}
487
488FunctionPass* llvm::createBasicRegisterAllocator()
489{
490 return new RABasic();
491}