xref: /src/contrib/llvm-project/llvm/lib/CodeGen/RegAllocBasic.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
163faed5bSDimitry Andric //===-- RegAllocBasic.cpp - Basic Register Allocator ----------------------===//
2cf099d11SDimitry Andric //
3e6d15924SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e6d15924SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5e6d15924SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6cf099d11SDimitry Andric //
7cf099d11SDimitry Andric //===----------------------------------------------------------------------===//
8cf099d11SDimitry Andric //
9cf099d11SDimitry Andric // This file defines the RABasic function pass, which provides a minimal
10cf099d11SDimitry Andric // implementation of the basic register allocator.
11cf099d11SDimitry Andric //
12cf099d11SDimitry Andric //===----------------------------------------------------------------------===//
13cf099d11SDimitry Andric 
1458b69754SDimitry Andric #include "AllocationOrder.h"
154a16efa3SDimitry Andric #include "RegAllocBase.h"
16cf099d11SDimitry Andric #include "llvm/Analysis/AliasAnalysis.h"
17cf099d11SDimitry Andric #include "llvm/CodeGen/CalcSpillWeights.h"
18ac9a064cSDimitry Andric #include "llvm/CodeGen/LiveDebugVariables.h"
19044eb2f6SDimitry Andric #include "llvm/CodeGen/LiveIntervals.h"
2063faed5bSDimitry Andric #include "llvm/CodeGen/LiveRangeEdit.h"
214a16efa3SDimitry Andric #include "llvm/CodeGen/LiveRegMatrix.h"
22c7dac04cSDimitry Andric #include "llvm/CodeGen/LiveStacks.h"
23f8af5cf6SDimitry Andric #include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
24cf099d11SDimitry Andric #include "llvm/CodeGen/MachineFunctionPass.h"
25cf099d11SDimitry Andric #include "llvm/CodeGen/MachineLoopInfo.h"
267ab83427SDimitry Andric #include "llvm/CodeGen/Passes.h"
27cf099d11SDimitry Andric #include "llvm/CodeGen/RegAllocRegistry.h"
28cfca06d7SDimitry Andric #include "llvm/CodeGen/Spiller.h"
29044eb2f6SDimitry Andric #include "llvm/CodeGen/TargetRegisterInfo.h"
304a16efa3SDimitry Andric #include "llvm/CodeGen/VirtRegMap.h"
31cfca06d7SDimitry Andric #include "llvm/Pass.h"
32cf099d11SDimitry Andric #include "llvm/Support/Debug.h"
33cf099d11SDimitry Andric #include "llvm/Support/raw_ostream.h"
34d0e4e96dSDimitry Andric #include <queue>
35cf099d11SDimitry Andric 
36cf099d11SDimitry Andric using namespace llvm;
37cf099d11SDimitry Andric 
385ca98fd9SDimitry Andric #define DEBUG_TYPE "regalloc"
395ca98fd9SDimitry Andric 
40cf099d11SDimitry Andric static RegisterRegAlloc basicRegAlloc("basic", "basic register allocator",
41cf099d11SDimitry Andric                                       createBasicRegisterAllocator);
42cf099d11SDimitry Andric 
43cf099d11SDimitry Andric namespace {
44d0e4e96dSDimitry Andric   struct CompSpillWeight {
operator ()__anon0d7d51d40111::CompSpillWeight45145449b1SDimitry Andric     bool operator()(const LiveInterval *A, const LiveInterval *B) const {
46b60736ecSDimitry Andric       return A->weight() < B->weight();
47d0e4e96dSDimitry Andric     }
48d0e4e96dSDimitry Andric   };
49d0e4e96dSDimitry Andric }
50d0e4e96dSDimitry Andric 
51d0e4e96dSDimitry Andric namespace {
52cf099d11SDimitry Andric /// RABasic provides a minimal implementation of the basic register allocation
53cf099d11SDimitry Andric /// algorithm. It prioritizes live virtual registers by spill weight and spills
54cf099d11SDimitry Andric /// whenever a register is unavailable. This is not practical in production but
55cf099d11SDimitry Andric /// provides a useful baseline both for measuring other allocators and comparing
56cf099d11SDimitry Andric /// the speed of the basic algorithm against other styles of allocators.
57d288ef4cSDimitry Andric class RABasic : public MachineFunctionPass,
58d288ef4cSDimitry Andric                 public RegAllocBase,
59d288ef4cSDimitry Andric                 private LiveRangeEdit::Delegate {
60cf099d11SDimitry Andric   // context
617fa27ce4SDimitry Andric   MachineFunction *MF = nullptr;
62cf099d11SDimitry Andric 
63cf099d11SDimitry Andric   // state
645ca98fd9SDimitry Andric   std::unique_ptr<Spiller> SpillerInstance;
65145449b1SDimitry Andric   std::priority_queue<const LiveInterval *, std::vector<const LiveInterval *>,
66145449b1SDimitry Andric                       CompSpillWeight>
67145449b1SDimitry Andric       Queue;
6863faed5bSDimitry Andric 
6963faed5bSDimitry Andric   // Scratch space.  Allocated here to avoid repeated malloc calls in
7063faed5bSDimitry Andric   // selectOrSplit().
7163faed5bSDimitry Andric   BitVector UsableRegs;
7263faed5bSDimitry Andric 
73b60736ecSDimitry Andric   bool LRE_CanEraseVirtReg(Register) override;
74b60736ecSDimitry Andric   void LRE_WillShrinkVirtReg(Register) override;
75d288ef4cSDimitry Andric 
76cf099d11SDimitry Andric public:
77ac9a064cSDimitry Andric   RABasic(const RegAllocFilterFunc F = nullptr);
78cf099d11SDimitry Andric 
79cf099d11SDimitry Andric   /// Return the pass name.
getPassName() const80b915e9e0SDimitry Andric   StringRef getPassName() const override { return "Basic Register Allocator"; }
81cf099d11SDimitry Andric 
82cf099d11SDimitry Andric   /// RABasic analysis usage.
835ca98fd9SDimitry Andric   void getAnalysisUsage(AnalysisUsage &AU) const override;
84cf099d11SDimitry Andric 
855ca98fd9SDimitry Andric   void releaseMemory() override;
86cf099d11SDimitry Andric 
spiller()875ca98fd9SDimitry Andric   Spiller &spiller() override { return *SpillerInstance; }
88cf099d11SDimitry Andric 
enqueueImpl(const LiveInterval * LI)89145449b1SDimitry Andric   void enqueueImpl(const LiveInterval *LI) override { Queue.push(LI); }
90d0e4e96dSDimitry Andric 
dequeue()91145449b1SDimitry Andric   const LiveInterval *dequeue() override {
92d0e4e96dSDimitry Andric     if (Queue.empty())
935ca98fd9SDimitry Andric       return nullptr;
94145449b1SDimitry Andric     const LiveInterval *LI = Queue.top();
95d0e4e96dSDimitry Andric     Queue.pop();
96d0e4e96dSDimitry Andric     return LI;
97d0e4e96dSDimitry Andric   }
98d0e4e96dSDimitry Andric 
99145449b1SDimitry Andric   MCRegister selectOrSplit(const LiveInterval &VirtReg,
100cfca06d7SDimitry Andric                            SmallVectorImpl<Register> &SplitVRegs) override;
101cf099d11SDimitry Andric 
102cf099d11SDimitry Andric   /// Perform register allocation.
1035ca98fd9SDimitry Andric   bool runOnMachineFunction(MachineFunction &mf) override;
104cf099d11SDimitry Andric 
getRequiredProperties() const105b915e9e0SDimitry Andric   MachineFunctionProperties getRequiredProperties() const override {
106b915e9e0SDimitry Andric     return MachineFunctionProperties().set(
107b915e9e0SDimitry Andric         MachineFunctionProperties::Property::NoPHIs);
108b915e9e0SDimitry Andric   }
109b915e9e0SDimitry Andric 
getClearedProperties() const110b60736ecSDimitry Andric   MachineFunctionProperties getClearedProperties() const override {
111b60736ecSDimitry Andric     return MachineFunctionProperties().set(
112b60736ecSDimitry Andric       MachineFunctionProperties::Property::IsSSA);
113b60736ecSDimitry Andric   }
114b60736ecSDimitry Andric 
11563faed5bSDimitry Andric   // Helper for spilling all live virtual registers currently unified under preg
11663faed5bSDimitry Andric   // that interfere with the most recently queried lvr.  Return true if spilling
11763faed5bSDimitry Andric   // was successful, and append any new spilled/split intervals to splitLVRs.
118145449b1SDimitry Andric   bool spillInterferences(const LiveInterval &VirtReg, MCRegister PhysReg,
119cfca06d7SDimitry Andric                           SmallVectorImpl<Register> &SplitVRegs);
12063faed5bSDimitry Andric 
121cf099d11SDimitry Andric   static char ID;
122cf099d11SDimitry Andric };
123cf099d11SDimitry Andric 
124cf099d11SDimitry Andric char RABasic::ID = 0;
125cf099d11SDimitry Andric 
126cf099d11SDimitry Andric } // end anonymous namespace
127cf099d11SDimitry Andric 
128d288ef4cSDimitry Andric char &llvm::RABasicID = RABasic::ID;
129d288ef4cSDimitry Andric 
130d288ef4cSDimitry Andric INITIALIZE_PASS_BEGIN(RABasic, "regallocbasic", "Basic Register Allocator",
131d288ef4cSDimitry Andric                       false, false)
INITIALIZE_PASS_DEPENDENCY(LiveDebugVariables)132d288ef4cSDimitry Andric INITIALIZE_PASS_DEPENDENCY(LiveDebugVariables)
133ac9a064cSDimitry Andric INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass)
134ac9a064cSDimitry Andric INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
135d288ef4cSDimitry Andric INITIALIZE_PASS_DEPENDENCY(RegisterCoalescer)
136d288ef4cSDimitry Andric INITIALIZE_PASS_DEPENDENCY(MachineScheduler)
137d288ef4cSDimitry Andric INITIALIZE_PASS_DEPENDENCY(LiveStacks)
1384b4fe385SDimitry Andric INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
139ac9a064cSDimitry Andric INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
140ac9a064cSDimitry Andric INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass)
141d288ef4cSDimitry Andric INITIALIZE_PASS_DEPENDENCY(VirtRegMap)
142d288ef4cSDimitry Andric INITIALIZE_PASS_DEPENDENCY(LiveRegMatrix)
143d288ef4cSDimitry Andric INITIALIZE_PASS_END(RABasic, "regallocbasic", "Basic Register Allocator", false,
144d288ef4cSDimitry Andric                     false)
145d288ef4cSDimitry Andric 
146b60736ecSDimitry Andric bool RABasic::LRE_CanEraseVirtReg(Register VirtReg) {
147d288ef4cSDimitry Andric   LiveInterval &LI = LIS->getInterval(VirtReg);
148044eb2f6SDimitry Andric   if (VRM->hasPhys(VirtReg)) {
149d288ef4cSDimitry Andric     Matrix->unassign(LI);
150d288ef4cSDimitry Andric     aboutToRemoveInterval(LI);
151d288ef4cSDimitry Andric     return true;
152d288ef4cSDimitry Andric   }
153d288ef4cSDimitry Andric   // Unassigned virtreg is probably in the priority queue.
154d288ef4cSDimitry Andric   // RegAllocBase will erase it after dequeueing.
155044eb2f6SDimitry Andric   // Nonetheless, clear the live-range so that the debug
156044eb2f6SDimitry Andric   // dump will show the right state for that VirtReg.
157044eb2f6SDimitry Andric   LI.clear();
158d288ef4cSDimitry Andric   return false;
159d288ef4cSDimitry Andric }
160d288ef4cSDimitry Andric 
LRE_WillShrinkVirtReg(Register VirtReg)161b60736ecSDimitry Andric void RABasic::LRE_WillShrinkVirtReg(Register VirtReg) {
162d288ef4cSDimitry Andric   if (!VRM->hasPhys(VirtReg))
163d288ef4cSDimitry Andric     return;
164d288ef4cSDimitry Andric 
165d288ef4cSDimitry Andric   // Register is assigned, put it back on the queue for reassignment.
166d288ef4cSDimitry Andric   LiveInterval &LI = LIS->getInterval(VirtReg);
167d288ef4cSDimitry Andric   Matrix->unassign(LI);
168d288ef4cSDimitry Andric   enqueue(&LI);
169d288ef4cSDimitry Andric }
170d288ef4cSDimitry Andric 
RABasic(RegAllocFilterFunc F)171ac9a064cSDimitry Andric RABasic::RABasic(RegAllocFilterFunc F)
172ac9a064cSDimitry Andric     : MachineFunctionPass(ID), RegAllocBase(F) {}
173cf099d11SDimitry Andric 
getAnalysisUsage(AnalysisUsage & AU) const174cf099d11SDimitry Andric void RABasic::getAnalysisUsage(AnalysisUsage &AU) const {
175cf099d11SDimitry Andric   AU.setPreservesCFG();
176dd58ef01SDimitry Andric   AU.addRequired<AAResultsWrapperPass>();
177dd58ef01SDimitry Andric   AU.addPreserved<AAResultsWrapperPass>();
178ac9a064cSDimitry Andric   AU.addRequired<LiveIntervalsWrapperPass>();
179ac9a064cSDimitry Andric   AU.addPreserved<LiveIntervalsWrapperPass>();
180ac9a064cSDimitry Andric   AU.addPreserved<SlotIndexesWrapperPass>();
1816b943ff3SDimitry Andric   AU.addRequired<LiveDebugVariables>();
1826b943ff3SDimitry Andric   AU.addPreserved<LiveDebugVariables>();
183cf099d11SDimitry Andric   AU.addRequired<LiveStacks>();
184cf099d11SDimitry Andric   AU.addPreserved<LiveStacks>();
185ac9a064cSDimitry Andric   AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
186ac9a064cSDimitry Andric   AU.addPreserved<MachineBlockFrequencyInfoWrapperPass>();
187cf099d11SDimitry Andric   AU.addRequiredID(MachineDominatorsID);
188cf099d11SDimitry Andric   AU.addPreservedID(MachineDominatorsID);
189ac9a064cSDimitry Andric   AU.addRequired<MachineLoopInfoWrapperPass>();
190ac9a064cSDimitry Andric   AU.addPreserved<MachineLoopInfoWrapperPass>();
191cf099d11SDimitry Andric   AU.addRequired<VirtRegMap>();
192cf099d11SDimitry Andric   AU.addPreserved<VirtRegMap>();
19358b69754SDimitry Andric   AU.addRequired<LiveRegMatrix>();
19458b69754SDimitry Andric   AU.addPreserved<LiveRegMatrix>();
195cf099d11SDimitry Andric   MachineFunctionPass::getAnalysisUsage(AU);
196cf099d11SDimitry Andric }
197cf099d11SDimitry Andric 
releaseMemory()198cf099d11SDimitry Andric void RABasic::releaseMemory() {
1995ca98fd9SDimitry Andric   SpillerInstance.reset();
200cf099d11SDimitry Andric }
201cf099d11SDimitry Andric 
202cf099d11SDimitry Andric 
203cf099d11SDimitry Andric // Spill or split all live virtual registers currently unified under PhysReg
204cf099d11SDimitry Andric // that interfere with VirtReg. The newly spilled or split live intervals are
205cf099d11SDimitry Andric // returned by appending them to SplitVRegs.
spillInterferences(const LiveInterval & VirtReg,MCRegister PhysReg,SmallVectorImpl<Register> & SplitVRegs)206145449b1SDimitry Andric bool RABasic::spillInterferences(const LiveInterval &VirtReg,
207145449b1SDimitry Andric                                  MCRegister PhysReg,
208cfca06d7SDimitry Andric                                  SmallVectorImpl<Register> &SplitVRegs) {
209cf099d11SDimitry Andric   // Record each interference and determine if all are spillable before mutating
210cf099d11SDimitry Andric   // either the union or live intervals.
211145449b1SDimitry Andric   SmallVector<const LiveInterval *, 8> Intfs;
21258b69754SDimitry Andric 
213cf099d11SDimitry Andric   // Collect interferences assigned to any alias of the physical register.
2147fa27ce4SDimitry Andric   for (MCRegUnit Unit : TRI->regunits(PhysReg)) {
2157fa27ce4SDimitry Andric     LiveIntervalUnion::Query &Q = Matrix->query(VirtReg, Unit);
216145449b1SDimitry Andric     for (const auto *Intf : reverse(Q.interferingVRegs())) {
217b60736ecSDimitry Andric       if (!Intf->isSpillable() || Intf->weight() > VirtReg.weight())
21858b69754SDimitry Andric         return false;
21958b69754SDimitry Andric       Intfs.push_back(Intf);
220cf099d11SDimitry Andric     }
221cf099d11SDimitry Andric   }
222eb11fae6SDimitry Andric   LLVM_DEBUG(dbgs() << "spilling " << printReg(PhysReg, TRI)
223044eb2f6SDimitry Andric                     << " interferences with " << VirtReg << "\n");
22458b69754SDimitry Andric   assert(!Intfs.empty() && "expected interference");
225cf099d11SDimitry Andric 
226cf099d11SDimitry Andric   // Spill each interfering vreg allocated to PhysReg or an alias.
227ac9a064cSDimitry Andric   for (const LiveInterval *Spill : Intfs) {
22858b69754SDimitry Andric     // Skip duplicates.
229ac9a064cSDimitry Andric     if (!VRM->hasPhys(Spill->reg()))
23058b69754SDimitry Andric       continue;
23158b69754SDimitry Andric 
23258b69754SDimitry Andric     // Deallocate the interfering vreg by removing it from the union.
23358b69754SDimitry Andric     // A LiveInterval instance may not be in a union during modification!
234ac9a064cSDimitry Andric     Matrix->unassign(*Spill);
23558b69754SDimitry Andric 
23658b69754SDimitry Andric     // Spill the extracted interval.
237ac9a064cSDimitry Andric     LiveRangeEdit LRE(Spill, SplitVRegs, *MF, *LIS, VRM, this, &DeadRemats);
23858b69754SDimitry Andric     spiller().spill(LRE);
23958b69754SDimitry Andric   }
240cf099d11SDimitry Andric   return true;
241cf099d11SDimitry Andric }
242cf099d11SDimitry Andric 
243cf099d11SDimitry Andric // Driver for the register assignment and splitting heuristics.
244cf099d11SDimitry Andric // Manages iteration over the LiveIntervalUnions.
245cf099d11SDimitry Andric //
246cf099d11SDimitry Andric // This is a minimal implementation of register assignment and splitting that
247cf099d11SDimitry Andric // spills whenever we run out of registers.
248cf099d11SDimitry Andric //
249cf099d11SDimitry Andric // selectOrSplit can only be called once per live virtual register. We then do a
250cf099d11SDimitry Andric // single interference test for each register the correct class until we find an
251cf099d11SDimitry Andric // available register. So, the number of interference tests in the worst case is
252cf099d11SDimitry Andric // |vregs| * |machineregs|. And since the number of interference tests is
253cf099d11SDimitry Andric // minimal, there is no value in caching them outside the scope of
254cf099d11SDimitry Andric // selectOrSplit().
selectOrSplit(const LiveInterval & VirtReg,SmallVectorImpl<Register> & SplitVRegs)255145449b1SDimitry Andric MCRegister RABasic::selectOrSplit(const LiveInterval &VirtReg,
256cfca06d7SDimitry Andric                                   SmallVectorImpl<Register> &SplitVRegs) {
257cf099d11SDimitry Andric   // Populate a list of physical register spill candidates.
258b60736ecSDimitry Andric   SmallVector<MCRegister, 8> PhysRegSpillCands;
259cf099d11SDimitry Andric 
260cf099d11SDimitry Andric   // Check for an available register in this class.
261b60736ecSDimitry Andric   auto Order =
262b60736ecSDimitry Andric       AllocationOrder::create(VirtReg.reg(), *VRM, RegClassInfo, Matrix);
263b60736ecSDimitry Andric   for (MCRegister PhysReg : Order) {
264b60736ecSDimitry Andric     assert(PhysReg.isValid());
26558b69754SDimitry Andric     // Check for interference in PhysReg
26658b69754SDimitry Andric     switch (Matrix->checkInterference(VirtReg, PhysReg)) {
26758b69754SDimitry Andric     case LiveRegMatrix::IK_Free:
26858b69754SDimitry Andric       // PhysReg is available, allocate it.
26958b69754SDimitry Andric       return PhysReg;
270cf099d11SDimitry Andric 
27158b69754SDimitry Andric     case LiveRegMatrix::IK_VirtReg:
27258b69754SDimitry Andric       // Only virtual registers in the way, we may be able to spill them.
27358b69754SDimitry Andric       PhysRegSpillCands.push_back(PhysReg);
27463faed5bSDimitry Andric       continue;
27563faed5bSDimitry Andric 
27658b69754SDimitry Andric     default:
27758b69754SDimitry Andric       // RegMask or RegUnit interference.
27858b69754SDimitry Andric       continue;
279cf099d11SDimitry Andric     }
28058b69754SDimitry Andric   }
281cf099d11SDimitry Andric 
282cf099d11SDimitry Andric   // Try to spill another interfering reg with less spill weight.
283344a3780SDimitry Andric   for (MCRegister &PhysReg : PhysRegSpillCands) {
284344a3780SDimitry Andric     if (!spillInterferences(VirtReg, PhysReg, SplitVRegs))
28558b69754SDimitry Andric       continue;
286cf099d11SDimitry Andric 
287344a3780SDimitry Andric     assert(!Matrix->checkInterference(VirtReg, PhysReg) &&
288cf099d11SDimitry Andric            "Interference after spill.");
289cf099d11SDimitry Andric     // Tell the caller to allocate to this newly freed physical register.
290344a3780SDimitry Andric     return PhysReg;
291cf099d11SDimitry Andric   }
29256fe8f14SDimitry Andric 
293cf099d11SDimitry Andric   // No other spill candidates were found, so spill the current VirtReg.
294eb11fae6SDimitry Andric   LLVM_DEBUG(dbgs() << "spilling: " << VirtReg << '\n');
29556fe8f14SDimitry Andric   if (!VirtReg.isSpillable())
29656fe8f14SDimitry Andric     return ~0u;
297d288ef4cSDimitry Andric   LiveRangeEdit LRE(&VirtReg, SplitVRegs, *MF, *LIS, VRM, this, &DeadRemats);
2986b943ff3SDimitry Andric   spiller().spill(LRE);
299cf099d11SDimitry Andric 
300cf099d11SDimitry Andric   // The live virtual register requesting allocation was spilled, so tell
301cf099d11SDimitry Andric   // the caller not to allocate anything during this round.
302cf099d11SDimitry Andric   return 0;
303cf099d11SDimitry Andric }
304cf099d11SDimitry Andric 
runOnMachineFunction(MachineFunction & mf)305cf099d11SDimitry Andric bool RABasic::runOnMachineFunction(MachineFunction &mf) {
306eb11fae6SDimitry Andric   LLVM_DEBUG(dbgs() << "********** BASIC REGISTER ALLOCATION **********\n"
307eb11fae6SDimitry Andric                     << "********** Function: " << mf.getName() << '\n');
308cf099d11SDimitry Andric 
309cf099d11SDimitry Andric   MF = &mf;
31058b69754SDimitry Andric   RegAllocBase::init(getAnalysis<VirtRegMap>(),
311ac9a064cSDimitry Andric                      getAnalysis<LiveIntervalsWrapperPass>().getLIS(),
31258b69754SDimitry Andric                      getAnalysis<LiveRegMatrix>());
313ac9a064cSDimitry Andric   VirtRegAuxInfo VRAI(
314ac9a064cSDimitry Andric       *MF, *LIS, *VRM, getAnalysis<MachineLoopInfoWrapperPass>().getLI(),
315ac9a064cSDimitry Andric       getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI());
316b60736ecSDimitry Andric   VRAI.calculateSpillWeightsAndHints();
317f8af5cf6SDimitry Andric 
318344a3780SDimitry Andric   SpillerInstance.reset(createInlineSpiller(*this, *MF, *VRM, VRAI));
319cf099d11SDimitry Andric 
320cf099d11SDimitry Andric   allocatePhysRegs();
32101095a5dSDimitry Andric   postOptimization();
322cf099d11SDimitry Andric 
323cf099d11SDimitry Andric   // Diagnostic output before rewriting
324eb11fae6SDimitry Andric   LLVM_DEBUG(dbgs() << "Post alloc VirtRegMap:\n" << *VRM << "\n");
325cf099d11SDimitry Andric 
326cf099d11SDimitry Andric   releaseMemory();
327cf099d11SDimitry Andric   return true;
328cf099d11SDimitry Andric }
329cf099d11SDimitry Andric 
createBasicRegisterAllocator()330344a3780SDimitry Andric FunctionPass* llvm::createBasicRegisterAllocator() {
331cf099d11SDimitry Andric   return new RABasic();
332cf099d11SDimitry Andric }
333344a3780SDimitry Andric 
createBasicRegisterAllocator(RegAllocFilterFunc F)334ac9a064cSDimitry Andric FunctionPass *llvm::createBasicRegisterAllocator(RegAllocFilterFunc F) {
335344a3780SDimitry Andric   return new RABasic(F);
336344a3780SDimitry Andric }
337