When a virtual register is folded into an instruction, keep track of whether
[oota-llvm.git] / lib / CodeGen / VirtRegMap.cpp
1 //===-- llvm/CodeGen/VirtRegMap.cpp - Virtual Register Map ----------------===//
2 //
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 VirtRegMap class.
11 //
12 // It also contains implementations of the the Spiller interface, which, given a
13 // virtual register map and a machine function, eliminates all virtual
14 // references by replacing them with physical register references - adding spill
15 // code as necessary.
16 //
17 //===----------------------------------------------------------------------===//
18
19 #define DEBUG_TYPE "spiller"
20 #include "VirtRegMap.h"
21 #include "llvm/Function.h"
22 #include "llvm/CodeGen/MachineFrameInfo.h"
23 #include "llvm/CodeGen/MachineFunction.h"
24 #include "llvm/CodeGen/SSARegMap.h"
25 #include "llvm/Target/TargetMachine.h"
26 #include "llvm/Target/TargetInstrInfo.h"
27 #include "llvm/Support/CommandLine.h"
28 #include "llvm/Support/Debug.h"
29 #include "llvm/ADT/Statistic.h"
30 #include "llvm/ADT/STLExtras.h"
31 using namespace llvm;
32
33 namespace {
34   Statistic<> NumSpills("spiller", "Number of register spills");
35   Statistic<> NumStores("spiller", "Number of stores added");
36   Statistic<> NumLoads ("spiller", "Number of loads added");
37   Statistic<> NumReused("spiller", "Number of values reused");
38   Statistic<> NumDSE   ("spiller", "Number of dead stores elided");
39
40   enum SpillerName { simple, local };
41
42   cl::opt<SpillerName>
43   SpillerOpt("spiller",
44              cl::desc("Spiller to use: (default: local)"),
45              cl::Prefix,
46              cl::values(clEnumVal(simple, "  simple spiller"),
47                         clEnumVal(local,  "  local spiller"),
48                         clEnumValEnd),
49              cl::init(local));
50 }
51
52 //===----------------------------------------------------------------------===//
53 //  VirtRegMap implementation
54 //===----------------------------------------------------------------------===//
55
56 void VirtRegMap::grow() {
57   Virt2PhysMap.grow(MF.getSSARegMap()->getLastVirtReg());
58   Virt2StackSlotMap.grow(MF.getSSARegMap()->getLastVirtReg());
59 }
60
61 int VirtRegMap::assignVirt2StackSlot(unsigned virtReg) {
62   assert(MRegisterInfo::isVirtualRegister(virtReg));
63   assert(Virt2StackSlotMap[virtReg] == NO_STACK_SLOT &&
64          "attempt to assign stack slot to already spilled register");
65   const TargetRegisterClass* RC = MF.getSSARegMap()->getRegClass(virtReg);
66   int frameIndex = MF.getFrameInfo()->CreateStackObject(RC->getSize(),
67                                                         RC->getAlignment());
68   Virt2StackSlotMap[virtReg] = frameIndex;
69   ++NumSpills;
70   return frameIndex;
71 }
72
73 void VirtRegMap::assignVirt2StackSlot(unsigned virtReg, int frameIndex) {
74   assert(MRegisterInfo::isVirtualRegister(virtReg));
75   assert(Virt2StackSlotMap[virtReg] == NO_STACK_SLOT &&
76          "attempt to assign stack slot to already spilled register");
77   Virt2StackSlotMap[virtReg] = frameIndex;
78 }
79
80 void VirtRegMap::virtFolded(unsigned VirtReg, MachineInstr *OldMI,
81                             unsigned OpNo, MachineInstr *NewMI) {
82   // Move previous memory references folded to new instruction.
83   MI2VirtMapTy::iterator IP = MI2VirtMap.lower_bound(NewMI);
84   for (MI2VirtMapTy::iterator I = MI2VirtMap.lower_bound(OldMI), 
85          E = MI2VirtMap.end(); I != E && I->first == OldMI; ) {
86     MI2VirtMap.insert(IP, std::make_pair(NewMI, I->second));
87     MI2VirtMap.erase(I++);
88   }
89
90   ModRef MRInfo;
91   if (!OldMI->getOperand(OpNo).isDef()) {
92     assert(OldMI->getOperand(OpNo).isUse() && "Operand is not use or def?");
93     MRInfo = isRef;
94   } else {
95     MRInfo = OldMI->getOperand(OpNo).isUse() ? isModRef : isMod;
96   }
97
98   // add new memory reference
99   MI2VirtMap.insert(IP, std::make_pair(NewMI, std::make_pair(VirtReg, MRInfo)));
100 }
101
102 void VirtRegMap::print(std::ostream &OS) const {
103   const MRegisterInfo* MRI = MF.getTarget().getRegisterInfo();
104
105   OS << "********** REGISTER MAP **********\n";
106   for (unsigned i = MRegisterInfo::FirstVirtualRegister,
107          e = MF.getSSARegMap()->getLastVirtReg(); i <= e; ++i) {
108     if (Virt2PhysMap[i] != (unsigned)VirtRegMap::NO_PHYS_REG)
109       OS << "[reg" << i << " -> " << MRI->getName(Virt2PhysMap[i]) << "]\n";
110          
111   }
112
113   for (unsigned i = MRegisterInfo::FirstVirtualRegister,
114          e = MF.getSSARegMap()->getLastVirtReg(); i <= e; ++i)
115     if (Virt2StackSlotMap[i] != VirtRegMap::NO_STACK_SLOT)
116       OS << "[reg" << i << " -> fi#" << Virt2StackSlotMap[i] << "]\n";
117   OS << '\n';
118 }
119
120 void VirtRegMap::dump() const { print(std::cerr); }
121
122
123 //===----------------------------------------------------------------------===//
124 // Simple Spiller Implementation
125 //===----------------------------------------------------------------------===//
126
127 Spiller::~Spiller() {}
128
129 namespace {
130   struct SimpleSpiller : public Spiller {
131     bool runOnMachineFunction(MachineFunction& mf, const VirtRegMap &VRM);
132   };
133 }
134
135 bool SimpleSpiller::runOnMachineFunction(MachineFunction& MF,
136                                          const VirtRegMap& VRM) {
137   DEBUG(std::cerr << "********** REWRITE MACHINE CODE **********\n");
138   DEBUG(std::cerr << "********** Function: "
139                   << MF.getFunction()->getName() << '\n');
140   const TargetMachine& TM = MF.getTarget();
141   const MRegisterInfo& MRI = *TM.getRegisterInfo();
142
143   // LoadedRegs - Keep track of which vregs are loaded, so that we only load
144   // each vreg once (in the case where a spilled vreg is used by multiple
145   // operands).  This is always smaller than the number of operands to the
146   // current machine instr, so it should be small.
147   std::vector<unsigned> LoadedRegs;
148
149   for (MachineFunction::iterator MBBI = MF.begin(), E = MF.end();
150        MBBI != E; ++MBBI) {
151     DEBUG(std::cerr << MBBI->getBasicBlock()->getName() << ":\n");
152     MachineBasicBlock &MBB = *MBBI;
153     for (MachineBasicBlock::iterator MII = MBB.begin(),
154            E = MBB.end(); MII != E; ++MII) {
155       MachineInstr &MI = *MII;
156       for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
157         MachineOperand &MO = MI.getOperand(i);
158         if (MO.isRegister() && MO.getReg() &&
159             MRegisterInfo::isVirtualRegister(MO.getReg())) {
160           unsigned VirtReg = MO.getReg();
161           unsigned PhysReg = VRM.getPhys(VirtReg);
162           if (VRM.hasStackSlot(VirtReg)) {
163             int StackSlot = VRM.getStackSlot(VirtReg);
164
165             if (MO.isUse() &&
166                 std::find(LoadedRegs.begin(), LoadedRegs.end(), VirtReg)
167                            == LoadedRegs.end()) {
168               MRI.loadRegFromStackSlot(MBB, &MI, PhysReg, StackSlot);
169               LoadedRegs.push_back(VirtReg);
170               ++NumLoads;
171               DEBUG(std::cerr << '\t' << *prior(MII));
172             }
173
174             if (MO.isDef()) {
175               MRI.storeRegToStackSlot(MBB, next(MII), PhysReg, StackSlot);
176               ++NumStores;
177             }
178           }
179           MI.SetMachineOperandReg(i, PhysReg);
180         }
181       }
182       DEBUG(std::cerr << '\t' << MI);
183       LoadedRegs.clear();
184     }
185   }
186   return true;
187 }
188
189 //===----------------------------------------------------------------------===//
190 //  Local Spiller Implementation
191 //===----------------------------------------------------------------------===//
192
193 namespace {
194   /// LocalSpiller - This spiller does a simple pass over the machine basic
195   /// block to attempt to keep spills in registers as much as possible for
196   /// blocks that have low register pressure (the vreg may be spilled due to
197   /// register pressure in other blocks).
198   class LocalSpiller : public Spiller {
199     const MRegisterInfo *MRI;
200     const TargetInstrInfo *TII;
201   public:
202     bool runOnMachineFunction(MachineFunction &MF, const VirtRegMap &VRM) {
203       MRI = MF.getTarget().getRegisterInfo();
204       TII = MF.getTarget().getInstrInfo();
205       DEBUG(std::cerr << "\n**** Local spiller rewriting function '"
206                       << MF.getFunction()->getName() << "':\n");
207
208       for (MachineFunction::iterator MBB = MF.begin(), E = MF.end();
209            MBB != E; ++MBB)
210         RewriteMBB(*MBB, VRM);
211       return true;
212     }
213   private:
214     void RewriteMBB(MachineBasicBlock &MBB, const VirtRegMap &VRM);
215     void ClobberPhysReg(unsigned PR, std::map<int, unsigned> &SpillSlots,
216                         std::map<unsigned, int> &PhysRegs);
217     void ClobberPhysRegOnly(unsigned PR, std::map<int, unsigned> &SpillSlots,
218                             std::map<unsigned, int> &PhysRegs);
219   };
220 }
221
222 void LocalSpiller::ClobberPhysRegOnly(unsigned PhysReg,
223                                       std::map<int, unsigned> &SpillSlots,
224                                       std::map<unsigned, int> &PhysRegs) {
225   std::map<unsigned, int>::iterator I = PhysRegs.find(PhysReg);
226   if (I != PhysRegs.end()) {
227     int Slot = I->second;
228     PhysRegs.erase(I);
229     assert(SpillSlots[Slot] == PhysReg && "Bidirectional map mismatch!");
230     SpillSlots.erase(Slot);
231     DEBUG(std::cerr << "PhysReg " << MRI->getName(PhysReg)
232           << " clobbered, invalidating SS#" << Slot << "\n");
233
234   }
235 }
236
237 void LocalSpiller::ClobberPhysReg(unsigned PhysReg,
238                                   std::map<int, unsigned> &SpillSlots,
239                                   std::map<unsigned, int> &PhysRegs) {
240   for (const unsigned *AS = MRI->getAliasSet(PhysReg); *AS; ++AS)
241     ClobberPhysRegOnly(*AS, SpillSlots, PhysRegs);
242   ClobberPhysRegOnly(PhysReg, SpillSlots, PhysRegs);
243 }
244
245
246 // ReusedOp - For each reused operand, we keep track of a bit of information, in
247 // case we need to rollback upon processing a new operand.  See comments below.
248 namespace {
249   struct ReusedOp {
250     // The MachineInstr operand that reused an available value.
251     unsigned Operand;
252     
253     // StackSlot - The spill slot of the value being reused.
254     unsigned StackSlot;
255     
256     // PhysRegReused - The physical register the value was available in.
257     unsigned PhysRegReused;
258     
259     // AssignedPhysReg - The physreg that was assigned for use by the reload.
260     unsigned AssignedPhysReg;
261     
262     ReusedOp(unsigned o, unsigned ss, unsigned prr, unsigned apr)
263       : Operand(o), StackSlot(ss), PhysRegReused(prr), AssignedPhysReg(apr) {}
264   };
265 }
266
267
268 /// rewriteMBB - Keep track of which spills are available even after the
269 /// register allocator is done with them.  If possible, avoid reloading vregs.
270 void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, const VirtRegMap &VRM) {
271
272   // SpillSlotsAvailable - This map keeps track of all of the spilled virtual
273   // register values that are still available, due to being loaded to stored to,
274   // but not invalidated yet.
275   std::map<int, unsigned> SpillSlotsAvailable;
276
277   // PhysRegsAvailable - This is the inverse of SpillSlotsAvailable, indicating
278   // which physregs are in use holding a stack slot value.
279   std::map<unsigned, int> PhysRegsAvailable;
280
281   DEBUG(std::cerr << MBB.getBasicBlock()->getName() << ":\n");
282
283   std::vector<ReusedOp> ReusedOperands;
284
285   // DefAndUseVReg - When we see a def&use operand that is spilled, keep track
286   // of it.  ".first" is the machine operand index (should always be 0 for now),
287   // and ".second" is the virtual register that is spilled.
288   std::vector<std::pair<unsigned, unsigned> > DefAndUseVReg;
289
290   // MaybeDeadStores - When we need to write a value back into a stack slot,
291   // keep track of the inserted store.  If the stack slot value is never read
292   // (because the value was used from some available register, for example), and
293   // subsequently stored to, the original store is dead.  This map keeps track
294   // of inserted stores that are not used.  If we see a subsequent store to the
295   // same stack slot, the original store is deleted.
296   std::map<int, MachineInstr*> MaybeDeadStores;
297
298   for (MachineBasicBlock::iterator MII = MBB.begin(), E = MBB.end();
299        MII != E; ) {
300     MachineInstr &MI = *MII;
301     MachineBasicBlock::iterator NextMII = MII; ++NextMII;
302
303     ReusedOperands.clear();
304     DefAndUseVReg.clear();
305
306     // Process all of the spilled uses and all non spilled reg references.
307     for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
308       MachineOperand &MO = MI.getOperand(i);
309       if (MO.isRegister() && MO.getReg() &&
310           MRegisterInfo::isVirtualRegister(MO.getReg())) {
311         unsigned VirtReg = MO.getReg();
312
313         if (!VRM.hasStackSlot(VirtReg)) {
314           // This virtual register was assigned a physreg!
315           MI.SetMachineOperandReg(i, VRM.getPhys(VirtReg));
316         } else {
317           // Is this virtual register a spilled value?
318           if (MO.isUse()) {
319             int StackSlot = VRM.getStackSlot(VirtReg);
320             unsigned PhysReg;
321
322             // Check to see if this stack slot is available.
323             std::map<int, unsigned>::iterator SSI =
324               SpillSlotsAvailable.find(StackSlot);
325             if (SSI != SpillSlotsAvailable.end()) {
326               // If this stack slot value is already available, reuse it!
327               PhysReg = SSI->second;
328               MI.SetMachineOperandReg(i, PhysReg);
329               DEBUG(std::cerr << "Reusing SS#" << StackSlot << " from physreg "
330                               << MRI->getName(SSI->second) << "\n");
331
332               // The only technical detail we have is that we don't know that
333               // PhysReg won't be clobbered by a reloaded stack slot that occurs
334               // later in the instruction.  In particular, consider 'op V1, V2'.
335               // If V1 is available in physreg R0, we would choose to reuse it
336               // here, instead of reloading it into the register the allocator
337               // indicated (say R1).  However, V2 might have to be reloaded
338               // later, and it might indicate that it needs to live in R0.  When
339               // this occurs, we need to have information available that
340               // indicates it is safe to use R1 for the reload instead of R0.
341               //
342               // To further complicate matters, we might conflict with an alias,
343               // or R0 and R1 might not be compatible with each other.  In this
344               // case, we actually insert a reload for V1 in R1, ensuring that
345               // we can get at R0 or its alias.
346               ReusedOperands.push_back(ReusedOp(i, StackSlot, PhysReg,
347                                                 VRM.getPhys(VirtReg)));
348               ++NumReused;
349             } else {
350               // Otherwise, reload it and remember that we have it.
351               PhysReg = VRM.getPhys(VirtReg);
352
353               // Note that, if we reused a register for a previous operand, the
354               // register we want to reload into might not actually be
355               // available.  If this occurs, use the register indicated by the
356               // reuser.
357               if (!ReusedOperands.empty())   // This is most often empty.
358                 for (unsigned ro = 0, e = ReusedOperands.size(); ro != e; ++ro)
359                   if (ReusedOperands[ro].PhysRegReused == PhysReg) {
360                     // Yup, use the reload register that we didn't use before.
361                     PhysReg = ReusedOperands[ro].AssignedPhysReg;
362                     break;
363                   } else {
364                     ReusedOp &Op = ReusedOperands[ro];
365                     unsigned PRRU = Op.PhysRegReused;
366                     for (const unsigned *AS = MRI->getAliasSet(PRRU); *AS; ++AS)
367                       if (*AS == PhysReg) {
368                         // Okay, we found out that an alias of a reused register
369                         // was used.  This isn't good because it means we have
370                         // to undo a previous reuse.
371                         MRI->loadRegFromStackSlot(MBB, &MI, Op.AssignedPhysReg, 
372                                                   Op.StackSlot);
373                         ClobberPhysReg(Op.AssignedPhysReg, SpillSlotsAvailable,
374                                        PhysRegsAvailable);
375
376                         // Any stores to this stack slot are not dead anymore.
377                         MaybeDeadStores.erase(Op.StackSlot);
378
379                         MI.SetMachineOperandReg(Op.Operand, Op.AssignedPhysReg);
380                         PhysRegsAvailable[Op.AssignedPhysReg] = Op.StackSlot;
381                         SpillSlotsAvailable[Op.StackSlot] = Op.AssignedPhysReg;
382                         PhysRegsAvailable.erase(Op.PhysRegReused);
383                         DEBUG(std::cerr << "Remembering SS#" << Op.StackSlot
384                               << " in physreg "
385                               << MRI->getName(Op.AssignedPhysReg) << "\n");
386                         ++NumLoads;
387                         DEBUG(std::cerr << '\t' << *prior(MII));
388
389                         DEBUG(std::cerr << "Reuse undone!\n");
390                         ReusedOperands.erase(ReusedOperands.begin()+ro);
391                         --NumReused;
392                         goto ContinueReload;
393                       }
394                   }
395             ContinueReload:
396
397               MRI->loadRegFromStackSlot(MBB, &MI, PhysReg, StackSlot);
398               // This invalidates PhysReg.
399               ClobberPhysReg(PhysReg, SpillSlotsAvailable, PhysRegsAvailable);
400
401               // Any stores to this stack slot are not dead anymore.
402               MaybeDeadStores.erase(StackSlot);
403
404               MI.SetMachineOperandReg(i, PhysReg);
405               PhysRegsAvailable[PhysReg] = StackSlot;
406               SpillSlotsAvailable[StackSlot] = PhysReg;
407               DEBUG(std::cerr << "Remembering SS#" << StackSlot <<" in physreg "
408                               << MRI->getName(PhysReg) << "\n");
409               ++NumLoads;
410               DEBUG(std::cerr << '\t' << *prior(MII));
411             }
412
413             // If this is both a def and a use, we need to emit a store to the
414             // stack slot after the instruction.  Keep track of D&U operands
415             // because we already changed it to a physreg here.
416             if (MO.isDef()) {
417               // Remember that this was a def-and-use operand, and that the
418               // stack slot is live after this instruction executes.
419               DefAndUseVReg.push_back(std::make_pair(i, VirtReg));
420             }
421           }
422         }
423       }
424     }
425
426     // Loop over all of the implicit defs, clearing them from our available
427     // sets.
428     const TargetInstrDescriptor &InstrDesc = TII->get(MI.getOpcode());
429     for (const unsigned* ImpDef = InstrDesc.ImplicitDefs; *ImpDef; ++ImpDef)
430       ClobberPhysReg(*ImpDef, SpillSlotsAvailable, PhysRegsAvailable);
431
432     DEBUG(std::cerr << '\t' << MI);
433
434     // If we have folded references to memory operands, make sure we clear all
435     // physical registers that may contain the value of the spilled virtual
436     // register
437     VirtRegMap::MI2VirtMapTy::const_iterator I, E;
438     for (tie(I, E) = VRM.getFoldedVirts(&MI); I != E; ++I) {
439       DEBUG(std::cerr << "Folded vreg: " << I->second.first << "  MR: "
440                       << I->second.second);
441       unsigned VirtReg = I->second.first;
442       VirtRegMap::ModRef MR = I->second.second;
443       if (VRM.hasStackSlot(VirtReg)) {
444         int SS = VRM.getStackSlot(VirtReg);
445         DEBUG(std::cerr << " - StackSlot: " << SS << "\n");
446
447         // If this reference is not a use, any previous store is now dead.
448         // Otherwise, the store to this stack slot is not dead anymore.
449         std::map<int, MachineInstr*>::iterator MDSI = MaybeDeadStores.find(SS);
450         if (MDSI != MaybeDeadStores.end()) {
451           if (MR & VirtRegMap::isRef)   // Previous store is not dead.
452             MaybeDeadStores.erase(SS);
453           else {
454             // If we get here, the store is dead, nuke it now.
455             assert(MR == VirtRegMap::isMod && "Can't be modref!");
456             MBB.erase(MDSI->second);
457             MaybeDeadStores.erase(MDSI);
458             ++NumDSE;
459           }
460         }
461
462         // If the spill slot value is available, and this is a new definition of
463         // the value, the value is not available anymore.
464         if (MR & VirtRegMap::isMod) {
465           std::map<int, unsigned>::iterator It = SpillSlotsAvailable.find(SS);
466           if (It != SpillSlotsAvailable.end()) {
467             PhysRegsAvailable.erase(It->second);
468             SpillSlotsAvailable.erase(It);
469           }
470         }
471       } else {
472         DEBUG(std::cerr << ": No stack slot!\n");
473       }
474     }
475
476     // Process all of the spilled defs.
477     for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
478       MachineOperand &MO = MI.getOperand(i);
479       if (MO.isRegister() && MO.getReg() && MO.isDef()) {
480         unsigned VirtReg = MO.getReg();
481
482         bool TakenCareOf = false;
483         if (!MRegisterInfo::isVirtualRegister(VirtReg)) {
484           // Check to see if this is a def-and-use vreg operand that we do need
485           // to insert a store for.
486           bool OpTakenCareOf = false;
487           if (MO.isUse() && !DefAndUseVReg.empty()) {
488             for (unsigned dau = 0, e = DefAndUseVReg.size(); dau != e; ++dau)
489               if (DefAndUseVReg[dau].first == i) {
490                 VirtReg = DefAndUseVReg[dau].second;
491                 OpTakenCareOf = true;
492                 break;
493               }
494           }
495           
496           if (!OpTakenCareOf) {
497             ClobberPhysReg(VirtReg, SpillSlotsAvailable, PhysRegsAvailable);
498             TakenCareOf = true;
499           }
500         }  
501
502         if (!TakenCareOf) {
503           // The only vregs left are stack slot definitions.
504           int StackSlot    = VRM.getStackSlot(VirtReg);
505           unsigned PhysReg;
506
507           // If this is a def&use operand, and we used a different physreg for
508           // it than the one assigned, make sure to execute the store from the
509           // correct physical register.
510           if (MO.getReg() == VirtReg)
511             PhysReg = VRM.getPhys(VirtReg);
512           else
513             PhysReg = MO.getReg();
514
515           MRI->storeRegToStackSlot(MBB, next(MII), PhysReg, StackSlot);
516           DEBUG(std::cerr << "Store:\t" << *next(MII));
517           MI.SetMachineOperandReg(i, PhysReg);
518
519           // If there is a dead store to this stack slot, nuke it now.
520           MachineInstr *&LastStore = MaybeDeadStores[StackSlot];
521           if (LastStore) {
522             ++NumDSE;
523             MBB.erase(LastStore);
524           }
525           LastStore = next(MII);
526
527           // If the stack slot value was previously available in some other
528           // register, change it now.  Otherwise, make the register available,
529           // in PhysReg.
530           std::map<int, unsigned>::iterator SSA =
531             SpillSlotsAvailable.find(StackSlot);
532           if (SSA != SpillSlotsAvailable.end()) {
533             // Remove the record for physreg.
534             PhysRegsAvailable.erase(SSA->second);
535             SpillSlotsAvailable.erase(SSA);
536           }
537           ClobberPhysReg(PhysReg, SpillSlotsAvailable, PhysRegsAvailable);
538
539           PhysRegsAvailable[PhysReg] = StackSlot;
540           SpillSlotsAvailable[StackSlot] = PhysReg;
541           DEBUG(std::cerr << "Updating SS#" << StackSlot <<" in physreg "
542                           << MRI->getName(PhysReg) << "\n");
543
544           ++NumStores;
545           VirtReg = PhysReg;
546         }
547       }
548     }
549     MII = NextMII;
550   }
551 }
552
553
554
555 llvm::Spiller* llvm::createSpiller() {
556   switch (SpillerOpt) {
557   default: assert(0 && "Unreachable!");
558   case local:
559     return new LocalSpiller();
560   case simple:
561     return new SimpleSpiller();
562   }
563 }