1 //===----- SchedulePostRAList.cpp - list scheduler ------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This implements a top-down list scheduler, using standard algorithms.
11 // The basic approach uses a priority queue of available nodes to schedule.
12 // One at a time, nodes are taken from the priority queue (thus in priority
13 // order), checked for legality to schedule, and emitted if legal.
15 // Nodes may not be legal to schedule either due to structural hazards (e.g.
16 // pipeline or resource constraints) or because an input to the instruction has
17 // not completed execution.
19 //===----------------------------------------------------------------------===//
21 #define DEBUG_TYPE "post-RA-sched"
22 #include "ExactHazardRecognizer.h"
23 #include "SimpleHazardRecognizer.h"
24 #include "ScheduleDAGInstrs.h"
25 #include "llvm/CodeGen/Passes.h"
26 #include "llvm/CodeGen/LatencyPriorityQueue.h"
27 #include "llvm/CodeGen/SchedulerRegistry.h"
28 #include "llvm/CodeGen/MachineDominators.h"
29 #include "llvm/CodeGen/MachineFrameInfo.h"
30 #include "llvm/CodeGen/MachineFunctionPass.h"
31 #include "llvm/CodeGen/MachineLoopInfo.h"
32 #include "llvm/CodeGen/MachineRegisterInfo.h"
33 #include "llvm/CodeGen/ScheduleHazardRecognizer.h"
34 #include "llvm/Analysis/AliasAnalysis.h"
35 #include "llvm/Target/TargetLowering.h"
36 #include "llvm/Target/TargetMachine.h"
37 #include "llvm/Target/TargetInstrInfo.h"
38 #include "llvm/Target/TargetRegisterInfo.h"
39 #include "llvm/Target/TargetSubtarget.h"
40 #include "llvm/Support/Compiler.h"
41 #include "llvm/Support/Debug.h"
42 #include "llvm/Support/ErrorHandling.h"
43 #include "llvm/Support/raw_ostream.h"
44 #include "llvm/ADT/Statistic.h"
49 STATISTIC(NumNoops, "Number of noops inserted");
50 STATISTIC(NumStalls, "Number of pipeline stalls");
51 STATISTIC(NumFixedAnti, "Number of fixed anti-dependencies");
53 // Post-RA scheduling is enabled with
54 // TargetSubtarget.enablePostRAScheduler(). This flag can be used to
55 // override the target.
57 EnablePostRAScheduler("post-RA-scheduler",
58 cl::desc("Enable scheduling after register allocation"),
59 cl::init(false), cl::Hidden);
60 static cl::opt<std::string>
61 EnableAntiDepBreaking("break-anti-dependencies",
62 cl::desc("Break post-RA scheduling anti-dependencies: "
63 "\"critical\", \"all\", or \"none\""),
64 cl::init("critical"), cl::Hidden);
66 EnablePostRAHazardAvoidance("avoid-hazards",
67 cl::desc("Enable exact hazard avoidance"),
68 cl::init(true), cl::Hidden);
70 // If DebugDiv > 0 then only schedule MBB with (ID % DebugDiv) == DebugMod
72 DebugDiv("postra-sched-debugdiv",
73 cl::desc("Debug control MBBs that are scheduled"),
74 cl::init(0), cl::Hidden);
76 DebugMod("postra-sched-debugmod",
77 cl::desc("Debug control MBBs that are scheduled"),
78 cl::init(0), cl::Hidden);
81 class VISIBILITY_HIDDEN PostRAScheduler : public MachineFunctionPass {
83 CodeGenOpt::Level OptLevel;
87 PostRAScheduler(CodeGenOpt::Level ol) :
88 MachineFunctionPass(&ID), OptLevel(ol) {}
90 void getAnalysisUsage(AnalysisUsage &AU) const {
92 AU.addRequired<AliasAnalysis>();
93 AU.addRequired<MachineDominatorTree>();
94 AU.addPreserved<MachineDominatorTree>();
95 AU.addRequired<MachineLoopInfo>();
96 AU.addPreserved<MachineLoopInfo>();
97 MachineFunctionPass::getAnalysisUsage(AU);
100 const char *getPassName() const {
101 return "Post RA top-down list latency scheduler";
104 bool runOnMachineFunction(MachineFunction &Fn);
106 char PostRAScheduler::ID = 0;
108 class VISIBILITY_HIDDEN SchedulePostRATDList : public ScheduleDAGInstrs {
109 /// RegisterReference - Information about a register reference
110 /// within a liverange
112 /// Operand - The registers operand
113 MachineOperand *Operand;
114 /// RC - The register class
115 const TargetRegisterClass *RC;
118 /// AvailableQueue - The priority queue to use for the available SUnits.
119 LatencyPriorityQueue AvailableQueue;
121 /// PendingQueue - This contains all of the instructions whose operands have
122 /// been issued, but their results are not ready yet (due to the latency of
123 /// the operation). Once the operands becomes available, the instruction is
124 /// added to the AvailableQueue.
125 std::vector<SUnit*> PendingQueue;
127 /// Topo - A topological ordering for SUnits.
128 ScheduleDAGTopologicalSort Topo;
130 /// HazardRec - The hazard recognizer to use.
131 ScheduleHazardRecognizer *HazardRec;
133 /// AA - AliasAnalysis for making memory reference queries.
136 /// AllocatableSet - The set of allocatable registers.
137 /// We'll be ignoring anti-dependencies on non-allocatable registers,
138 /// because they may not be safe to break.
139 const BitVector AllocatableSet;
141 /// GroupNodes - Implements a disjoint-union data structure to
142 /// form register groups. A node is represented by an index into
143 /// the vector. A node can "point to" itself to indicate that it
144 /// is the parent of a group, or point to another node to indicate
145 /// that it is a member of the same group as that node.
146 std::vector<unsigned> GroupNodes;
148 /// GroupNodeIndices - For each register, the index of the GroupNode
149 /// currently representing the group that the register belongs to.
150 /// Register 0 is always represented by the 0 group, a group
151 /// composed of registers that are not eligible for anti-aliasing.
152 unsigned GroupNodeIndices[TargetRegisterInfo::FirstVirtualRegister];
154 /// RegRegs - Map registers to all their references within a live range.
155 std::multimap<unsigned, RegisterReference> RegRefs;
157 /// KillIndices - The index of the most recent kill (proceding
158 /// bottom-up), or ~0u if no kill of the register has been
159 /// seen. The register is live if this index != ~0u and DefIndices
161 unsigned KillIndices[TargetRegisterInfo::FirstVirtualRegister];
163 /// DefIndices - The index of the most recent complete def (proceding bottom
164 /// up), or ~0u if the register is live.
165 unsigned DefIndices[TargetRegisterInfo::FirstVirtualRegister];
168 SchedulePostRATDList(MachineFunction &MF,
169 const MachineLoopInfo &MLI,
170 const MachineDominatorTree &MDT,
171 ScheduleHazardRecognizer *HR,
173 : ScheduleDAGInstrs(MF, MLI, MDT), Topo(SUnits),
174 HazardRec(HR), AA(aa),
175 AllocatableSet(TRI->getAllocatableSet(MF)),
176 GroupNodes(TargetRegisterInfo::FirstVirtualRegister, 0) {}
178 ~SchedulePostRATDList() {
182 /// StartBlock - Initialize register live-range state for scheduling in
185 void StartBlock(MachineBasicBlock *BB);
187 /// FinishBlock - Clean up register live-range state.
191 /// Observe - Update liveness information to account for the current
192 /// instruction, which will not be scheduled.
194 void Observe(MachineInstr *MI, unsigned Count);
196 /// Schedule - Schedule the instruction range using list scheduling.
200 /// FixupKills - Fix register kill flags that have been made
201 /// invalid due to scheduling
203 void FixupKills(MachineBasicBlock *MBB);
206 /// IsLive - Return true if Reg is live
207 bool IsLive(unsigned Reg);
209 void PrescanInstruction(MachineInstr *MI, unsigned Count);
210 void ScanInstruction(MachineInstr *MI, unsigned Count);
211 bool BreakAntiDependencies(bool CriticalPathOnly);
212 unsigned FindSuitableFreeRegister(unsigned AntiDepReg,
213 unsigned LastNewReg);
215 void ReleaseSucc(SUnit *SU, SDep *SuccEdge);
216 void ReleaseSuccessors(SUnit *SU);
217 void ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle);
218 void ListScheduleTopDown();
220 void StartBlockForKills(MachineBasicBlock *BB);
222 // ToggleKillFlag - Toggle a register operand kill flag. Other
223 // adjustments may be made to the instruction if necessary. Return
224 // true if the operand has been deleted, false if not.
225 bool ToggleKillFlag(MachineInstr *MI, MachineOperand &MO);
227 // GetGroup - Get the group for a register. The returned value is
228 // the index of the GroupNode representing the group.
229 unsigned GetGroup(unsigned Reg);
231 // GetGroupRegs - Return a vector of the registers belonging to a
233 void GetGroupRegs(unsigned Group, std::vector<unsigned> &Regs);
235 // UnionGroups - Union Reg1's and Reg2's groups to form a new
236 // group. Return the index of the GroupNode representing the
238 unsigned UnionGroups(unsigned Reg1, unsigned Reg2);
240 // LeaveGroup - Remove a register from its current group and place
241 // it alone in its own group. Return the index of the GroupNode
242 // representing the registers new group.
243 unsigned LeaveGroup(unsigned Reg);
247 /// isSchedulingBoundary - Test if the given instruction should be
248 /// considered a scheduling boundary. This primarily includes labels
251 static bool isSchedulingBoundary(const MachineInstr *MI,
252 const MachineFunction &MF) {
253 // Terminators and labels can't be scheduled around.
254 if (MI->getDesc().isTerminator() || MI->isLabel())
257 // Don't attempt to schedule around any instruction that modifies
258 // a stack-oriented pointer, as it's unlikely to be profitable. This
259 // saves compile time, because it doesn't require every single
260 // stack slot reference to depend on the instruction that does the
262 const TargetLowering &TLI = *MF.getTarget().getTargetLowering();
263 if (MI->modifiesRegister(TLI.getStackPointerRegisterToSaveRestore()))
269 bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) {
270 AA = &getAnalysis<AliasAnalysis>();
272 // Check for explicit enable/disable of post-ra scheduling.
273 if (EnablePostRAScheduler.getPosition() > 0) {
274 if (!EnablePostRAScheduler)
277 // Check that post-RA scheduling is enabled for this target.
278 const TargetSubtarget &ST = Fn.getTarget().getSubtarget<TargetSubtarget>();
279 if (!ST.enablePostRAScheduler(OptLevel))
283 DEBUG(errs() << "PostRAScheduler\n");
285 const MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>();
286 const MachineDominatorTree &MDT = getAnalysis<MachineDominatorTree>();
287 const InstrItineraryData &InstrItins = Fn.getTarget().getInstrItineraryData();
288 ScheduleHazardRecognizer *HR = EnablePostRAHazardAvoidance ?
289 (ScheduleHazardRecognizer *)new ExactHazardRecognizer(InstrItins) :
290 (ScheduleHazardRecognizer *)new SimpleHazardRecognizer();
292 SchedulePostRATDList Scheduler(Fn, MLI, MDT, HR, AA);
294 // Loop over all of the basic blocks
295 for (MachineFunction::iterator MBB = Fn.begin(), MBBe = Fn.end();
296 MBB != MBBe; ++MBB) {
298 // If DebugDiv > 0 then only schedule MBB with (ID % DebugDiv) == DebugMod
300 static int bbcnt = 0;
301 if (bbcnt++ % DebugDiv != DebugMod)
303 errs() << "*** DEBUG scheduling " << Fn.getFunction()->getNameStr() <<
304 ":MBB ID#" << MBB->getNumber() << " ***\n";
308 // Initialize register live-range state for scheduling in this block.
309 Scheduler.StartBlock(MBB);
311 // Schedule each sequence of instructions not interrupted by a label
312 // or anything else that effectively needs to shut down scheduling.
313 MachineBasicBlock::iterator Current = MBB->end();
314 unsigned Count = MBB->size(), CurrentCount = Count;
315 for (MachineBasicBlock::iterator I = Current; I != MBB->begin(); ) {
316 MachineInstr *MI = prior(I);
317 if (isSchedulingBoundary(MI, Fn)) {
318 Scheduler.Run(MBB, I, Current, CurrentCount);
319 Scheduler.EmitSchedule(0);
321 CurrentCount = Count - 1;
322 Scheduler.Observe(MI, CurrentCount);
327 assert(Count == 0 && "Instruction count mismatch!");
328 assert((MBB->begin() == Current || CurrentCount != 0) &&
329 "Instruction count mismatch!");
330 Scheduler.Run(MBB, MBB->begin(), Current, CurrentCount);
331 Scheduler.EmitSchedule(0);
333 // Clean up register live-range state.
334 Scheduler.FinishBlock();
336 // Update register kills
337 Scheduler.FixupKills(MBB);
343 unsigned SchedulePostRATDList::GetGroup(unsigned Reg)
345 unsigned Node = GroupNodeIndices[Reg];
346 while (GroupNodes[Node] != Node)
347 Node = GroupNodes[Node];
352 void SchedulePostRATDList::GetGroupRegs(unsigned Group, std::vector<unsigned> &Regs)
354 for (unsigned Reg = 0; Reg != TargetRegisterInfo::FirstVirtualRegister; ++Reg) {
355 if (GetGroup(Reg) == Group)
360 unsigned SchedulePostRATDList::UnionGroups(unsigned Reg1, unsigned Reg2)
362 assert(GroupNodes[0] == 0 && "GroupNode 0 not parent!");
363 assert(GroupNodeIndices[0] == 0 && "Reg 0 not in Group 0!");
365 // find group for each register
366 unsigned Group1 = GetGroup(Reg1);
367 unsigned Group2 = GetGroup(Reg2);
369 // if either group is 0, then that must become the parent
370 unsigned Parent = (Group1 == 0) ? Group1 : Group2;
371 unsigned Other = (Parent == Group1) ? Group2 : Group1;
372 GroupNodes.at(Other) = Parent;
376 unsigned SchedulePostRATDList::LeaveGroup(unsigned Reg)
378 // Create a new GroupNode for Reg. Reg's existing GroupNode must
379 // stay as is because there could be other GroupNodes referring to
381 unsigned idx = GroupNodes.size();
382 GroupNodes.push_back(idx);
383 GroupNodeIndices[Reg] = idx;
387 bool SchedulePostRATDList::IsLive(unsigned Reg)
389 // KillIndex must be defined and DefIndex not defined for a register
391 return((KillIndices[Reg] != ~0u) && (DefIndices[Reg] == ~0u));
394 /// StartBlock - Initialize register live-range state for scheduling in
397 void SchedulePostRATDList::StartBlock(MachineBasicBlock *BB) {
398 // Call the superclass.
399 ScheduleDAGInstrs::StartBlock(BB);
401 // Reset the hazard recognizer.
404 // Initialize all registers to be in their own group. Initially we
405 // assign the register to the same-indexed GroupNode.
406 for (unsigned i = 0; i < TargetRegisterInfo::FirstVirtualRegister; ++i)
407 GroupNodeIndices[i] = i;
409 // Initialize the indices to indicate that no registers are live.
410 std::fill(KillIndices, array_endof(KillIndices), ~0u);
411 std::fill(DefIndices, array_endof(DefIndices), BB->size());
413 bool IsReturnBlock = (!BB->empty() && BB->back().getDesc().isReturn());
415 // Determine the live-out physregs for this block.
417 // In a return block, examine the function live-out regs.
418 for (MachineRegisterInfo::liveout_iterator I = MRI.liveout_begin(),
419 E = MRI.liveout_end(); I != E; ++I) {
422 KillIndices[Reg] = BB->size();
423 DefIndices[Reg] = ~0u;
424 // Repeat, for all aliases.
425 for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) {
426 unsigned AliasReg = *Alias;
427 UnionGroups(AliasReg, 0);
428 KillIndices[AliasReg] = BB->size();
429 DefIndices[AliasReg] = ~0u;
433 // In a non-return block, examine the live-in regs of all successors.
434 for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
435 SE = BB->succ_end(); SI != SE; ++SI)
436 for (MachineBasicBlock::livein_iterator I = (*SI)->livein_begin(),
437 E = (*SI)->livein_end(); I != E; ++I) {
440 KillIndices[Reg] = BB->size();
441 DefIndices[Reg] = ~0u;
442 // Repeat, for all aliases.
443 for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) {
444 unsigned AliasReg = *Alias;
445 UnionGroups(AliasReg, 0);
446 KillIndices[AliasReg] = BB->size();
447 DefIndices[AliasReg] = ~0u;
452 // Mark live-out callee-saved registers. In a return block this is
453 // all callee-saved registers. In non-return this is any
454 // callee-saved register that is not saved in the prolog.
455 const MachineFrameInfo *MFI = MF.getFrameInfo();
456 BitVector Pristine = MFI->getPristineRegs(BB);
457 for (const unsigned *I = TRI->getCalleeSavedRegs(); *I; ++I) {
459 if (!IsReturnBlock && !Pristine.test(Reg)) continue;
461 KillIndices[Reg] = BB->size();
462 DefIndices[Reg] = ~0u;
463 // Repeat, for all aliases.
464 for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) {
465 unsigned AliasReg = *Alias;
466 UnionGroups(AliasReg, 0);
467 KillIndices[AliasReg] = BB->size();
468 DefIndices[AliasReg] = ~0u;
473 /// Schedule - Schedule the instruction range using list scheduling.
475 void SchedulePostRATDList::Schedule() {
476 DEBUG(errs() << "********** List Scheduling **********\n");
478 // Build the scheduling graph.
481 if (EnableAntiDepBreaking != "none") {
482 if (BreakAntiDependencies((EnableAntiDepBreaking == "all") ? false : true)) {
483 // We made changes. Update the dependency graph.
484 // Theoretically we could update the graph in place:
485 // When a live range is changed to use a different register, remove
486 // the def's anti-dependence *and* output-dependence edges due to
487 // that register, and add new anti-dependence and output-dependence
488 // edges based on the next live range of the register.
496 DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su)
497 SUnits[su].dumpAll(this));
499 AvailableQueue.initNodes(SUnits);
501 ListScheduleTopDown();
503 AvailableQueue.releaseState();
506 /// Observe - Update liveness information to account for the current
507 /// instruction, which will not be scheduled.
509 void SchedulePostRATDList::Observe(MachineInstr *MI, unsigned Count) {
510 assert(Count < InsertPosIndex && "Instruction index out of expected range!");
512 DEBUG(errs() << "Observe: ");
515 for (unsigned Reg = 0; Reg != TargetRegisterInfo::FirstVirtualRegister; ++Reg) {
516 // If Reg is current live, then mark that it can't be renamed as
517 // we don't know the extent of its live-range anymore (now that it
518 // has been scheduled). If it is not live but was defined in the
519 // previous schedule region, then set its def index to the most
520 // conservative location (i.e. the beginning of the previous
523 DEBUG(if (GetGroup(Reg) != 0)
524 errs() << " " << TRI->getName(Reg) << "=g" <<
525 GetGroup(Reg) << "->g0(region live-out)");
527 } else if ((DefIndices[Reg] < InsertPosIndex) && (DefIndices[Reg] >= Count)) {
528 DefIndices[Reg] = Count;
532 PrescanInstruction(MI, Count);
533 ScanInstruction(MI, Count);
536 /// FinishBlock - Clean up register live-range state.
538 void SchedulePostRATDList::FinishBlock() {
541 // Call the superclass.
542 ScheduleDAGInstrs::FinishBlock();
545 /// CriticalPathStep - Return the next SUnit after SU on the bottom-up
547 static SDep *CriticalPathStep(SUnit *SU) {
549 unsigned NextDepth = 0;
550 // Find the predecessor edge with the greatest depth.
551 for (SUnit::pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end();
553 SUnit *PredSU = P->getSUnit();
554 unsigned PredLatency = P->getLatency();
555 unsigned PredTotalLatency = PredSU->getDepth() + PredLatency;
556 // In the case of a latency tie, prefer an anti-dependency edge over
557 // other types of edges.
558 if (NextDepth < PredTotalLatency ||
559 (NextDepth == PredTotalLatency && P->getKind() == SDep::Anti)) {
560 NextDepth = PredTotalLatency;
567 /// AntiDepPathStep - Return SUnit that SU has an anti-dependence on.
568 static SDep *AntiDepPathStep(SUnit *SU) {
569 for (SUnit::pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end();
571 if (P->getKind() == SDep::Anti) {
578 void SchedulePostRATDList::PrescanInstruction(MachineInstr *MI, unsigned Count) {
579 // Scan the register defs for this instruction and update
580 // live-ranges, groups and RegRefs.
581 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
582 MachineOperand &MO = MI->getOperand(i);
583 if (!MO.isReg() || !MO.isDef()) continue;
584 unsigned Reg = MO.getReg();
585 if (Reg == 0) continue;
586 // Ignore two-addr defs for liveness...
587 if (MI->isRegTiedToUseOperand(i)) continue;
589 // Update Def for Reg and subregs.
590 DefIndices[Reg] = Count;
591 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
593 unsigned SubregReg = *Subreg;
594 DefIndices[SubregReg] = Count;
598 DEBUG(errs() << "\tGroups:");
599 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
600 MachineOperand &MO = MI->getOperand(i);
601 if (!MO.isReg() || !MO.isDef()) continue;
602 unsigned Reg = MO.getReg();
603 if (Reg == 0) continue;
605 DEBUG(errs() << " " << TRI->getName(Reg) << "=g" << GetGroup(Reg));
607 // If MI's defs have special allocation requirement, don't allow
608 // any def registers to be changed. Also assume all registers
609 // defined in a call must not be changed (ABI).
610 if (MI->getDesc().isCall() || MI->getDesc().hasExtraDefRegAllocReq()) {
611 DEBUG(if (GetGroup(Reg) != 0) errs() << "->g0(alloc-req)");
615 // Any subregisters that are live at this point are defined here,
616 // so group those subregisters with Reg.
617 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
619 unsigned SubregReg = *Subreg;
620 if (IsLive(SubregReg)) {
621 UnionGroups(Reg, SubregReg);
622 DEBUG(errs() << "->g" << GetGroup(Reg) << "(via " <<
623 TRI->getName(SubregReg) << ")");
627 // Note register reference...
628 const TargetRegisterClass *RC = NULL;
629 if (i < MI->getDesc().getNumOperands())
630 RC = MI->getDesc().OpInfo[i].getRegClass(TRI);
631 RegisterReference RR = { &MO, RC };
632 RegRefs.insert(std::make_pair(Reg, RR));
635 DEBUG(errs() << '\n');
638 void SchedulePostRATDList::ScanInstruction(MachineInstr *MI,
640 // Scan the register uses for this instruction and update
641 // live-ranges, groups and RegRefs.
642 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
643 MachineOperand &MO = MI->getOperand(i);
644 if (!MO.isReg() || !MO.isUse()) continue;
645 unsigned Reg = MO.getReg();
646 if (Reg == 0) continue;
648 // It wasn't previously live but now it is, this is a kill. Forget
649 // the previous live-range information and start a new live-range
652 KillIndices[Reg] = Count;
653 DefIndices[Reg] = ~0u;
657 // Repeat, for subregisters.
658 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
660 unsigned SubregReg = *Subreg;
661 if (!IsLive(SubregReg)) {
662 KillIndices[SubregReg] = Count;
663 DefIndices[SubregReg] = ~0u;
664 RegRefs.erase(SubregReg);
665 LeaveGroup(SubregReg);
669 // Note register reference...
670 const TargetRegisterClass *RC = NULL;
671 if (i < MI->getDesc().getNumOperands())
672 RC = MI->getDesc().OpInfo[i].getRegClass(TRI);
673 RegisterReference RR = { &MO, RC };
674 RegRefs.insert(std::make_pair(Reg, RR));
677 // Form a group of all defs and uses of a KILL instruction to ensure
678 // that all registers are renamed as a group.
679 if (MI->getOpcode() == TargetInstrInfo::KILL) {
680 unsigned FirstReg = 0;
681 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
682 MachineOperand &MO = MI->getOperand(i);
683 if (!MO.isReg()) continue;
684 unsigned Reg = MO.getReg();
685 if (Reg == 0) continue;
688 UnionGroups(FirstReg, Reg);
692 DEBUG(if (FirstReg != 0) errs() << "\tKill Group: g" <<
693 GetGroup(FirstReg) << '\n');
697 unsigned SchedulePostRATDList::FindSuitableFreeRegister(unsigned AntiDepReg,
698 unsigned LastNewReg) {
699 // Collect all registers in the same group as AntiDepReg. These all
700 // need to be renamed together if we are to break the
702 std::vector<unsigned> Regs;
703 GetGroupRegs(GetGroup(AntiDepReg), Regs);
705 DEBUG(errs() << "\tRename Register Group:");
706 DEBUG(for (unsigned i = 0, e = Regs.size(); i != e; ++i)
707 DEBUG(errs() << " " << TRI->getName(Regs[i])));
708 DEBUG(errs() << "\n");
710 // If there is a single register that needs to be renamed then we
711 // can do it ourselves.
712 if (Regs.size() == 1) {
713 assert(Regs[0] == AntiDepReg && "Register group does not contain register!");
715 // Check all references that need rewriting. Gather up all the
716 // register classes for the register references.
717 const TargetRegisterClass *FirstRC = NULL;
718 std::set<const TargetRegisterClass *> RCs;
719 std::pair<std::multimap<unsigned, RegisterReference>::iterator,
720 std::multimap<unsigned, RegisterReference>::iterator>
721 Range = RegRefs.equal_range(AntiDepReg);
722 for (std::multimap<unsigned, RegisterReference>::iterator
723 Q = Range.first, QE = Range.second; Q != QE; ++Q) {
724 const TargetRegisterClass *RC = Q->second.RC;
725 if (RC == NULL) continue;
728 else if (FirstRC != RC)
735 DEBUG(errs() << "\tChecking Regclasses: " << FirstRC->getName());
736 DEBUG(for (std::set<const TargetRegisterClass *>::iterator S =
737 RCs.begin(), E = RCs.end(); S != E; ++S)
738 errs() << " " << (*S)->getName());
739 DEBUG(errs() << '\n');
741 // Using the allocation order for one of the register classes,
742 // find the first register that belongs to all the register
743 // classes that is available over the liverange of the register.
744 DEBUG(errs() << "\tFind Register:");
745 for (TargetRegisterClass::iterator R = FirstRC->allocation_order_begin(MF),
746 RE = FirstRC->allocation_order_end(MF); R != RE; ++R) {
747 unsigned NewReg = *R;
749 // Don't replace a register with itself.
750 if (NewReg == AntiDepReg) continue;
752 DEBUG(errs() << " " << TRI->getName(NewReg));
754 // Make sure NewReg is in all required register classes.
755 for (std::set<const TargetRegisterClass *>::iterator S =
756 RCs.begin(), E = RCs.end(); S != E; ++S) {
757 const TargetRegisterClass *RC = *S;
758 if (!RC->contains(NewReg)) {
759 DEBUG(errs() << "(not in " << RC->getName() << ")");
765 // If NewReg is dead and NewReg's most recent def is not before
766 // AntiDepReg's kill, it's safe to replace AntiDepReg with
767 // NewReg. We must also check all subregisters of NewReg.
768 if (IsLive(NewReg) || (KillIndices[AntiDepReg] > DefIndices[NewReg])) {
769 DEBUG(errs() << "(live)");
774 for (const unsigned *Subreg = TRI->getSubRegisters(NewReg);
776 unsigned SubregReg = *Subreg;
777 if (IsLive(SubregReg) || (KillIndices[AntiDepReg] > DefIndices[SubregReg])) {
778 DEBUG(errs() << "(subreg " << TRI->getName(SubregReg) << " live)");
787 DEBUG(errs() << '\n');
792 DEBUG(errs() << '\n');
795 // No registers are free and available!
799 /// BreakAntiDependencies - Identifiy anti-dependencies along the critical path
800 /// of the ScheduleDAG and break them by renaming registers.
802 bool SchedulePostRATDList::BreakAntiDependencies(bool CriticalPathOnly) {
803 // The code below assumes that there is at least one instruction,
804 // so just duck out immediately if the block is empty.
805 if (SUnits.empty()) return false;
807 // If breaking anti-dependencies only along the critical path, track
808 // progress along the critical path through the SUnit graph as we
809 // walk the instructions.
810 SUnit *CriticalPathSU = 0;
811 MachineInstr *CriticalPathMI = 0;
813 // If breaking all anti-dependencies need a map from MI to SUnit.
814 std::map<MachineInstr *, SUnit *> MISUnitMap;
816 // Find the node at the bottom of the critical path.
817 if (CriticalPathOnly) {
819 for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
820 SUnit *SU = &SUnits[i];
821 if (!Max || SU->getDepth() + SU->Latency > Max->getDepth() + Max->Latency)
825 DEBUG(errs() << "Critical path has total latency "
826 << (Max->getDepth() + Max->Latency) << "\n");
827 CriticalPathSU = Max;
828 CriticalPathMI = CriticalPathSU->getInstr();
830 for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
831 SUnit *SU = &SUnits[i];
832 MISUnitMap.insert(std::pair<MachineInstr *, SUnit *>(SU->getInstr(), SU));
834 DEBUG(errs() << "Breaking all anti-dependencies\n");
839 DEBUG(errs() << "Available regs:");
840 for (unsigned Reg = 0; Reg < TRI->getNumRegs(); ++Reg) {
842 DEBUG(errs() << " " << TRI->getName(Reg));
844 DEBUG(errs() << '\n');
849 // TODO: If we tracked more than one register here, we could potentially
850 // fix that remaining critical edge too. This is a little more involved,
851 // because unlike the most recent register, less recent registers should
852 // still be considered, though only if no other registers are available.
853 unsigned LastNewReg[TargetRegisterInfo::FirstVirtualRegister] = {};
855 // Attempt to break anti-dependence edges. Walk the instructions
856 // from the bottom up, tracking information about liveness as we go
857 // to help determine which registers are available.
858 bool Changed = false;
859 unsigned Count = InsertPosIndex - 1;
860 for (MachineBasicBlock::iterator I = InsertPos, E = Begin;
862 MachineInstr *MI = --I;
864 DEBUG(errs() << "Anti: ");
867 // Process the defs in MI...
868 PrescanInstruction(MI, Count);
870 // Check if this instruction has an anti-dependence that we may be
871 // able to break. If it is, set AntiDepReg to the non-zero
872 // register associated with the anti-dependence.
874 unsigned AntiDepReg = 0;
876 // Limiting our attention to the critical path is a heuristic to avoid
877 // breaking anti-dependence edges that aren't going to significantly
878 // impact the overall schedule. There are a limited number of registers
879 // and we want to save them for the important edges.
881 // We can also break all anti-dependencies because they can
882 // occur along the non-critical path but are still detrimental for
885 // TODO: Instructions with multiple defs could have multiple
886 // anti-dependencies. The current code here only knows how to break one
887 // edge per instruction. Note that we'd have to be able to break all of
888 // the anti-dependencies in an instruction in order to be effective.
889 if (!CriticalPathOnly || (MI == CriticalPathMI)) {
890 DEBUG(dbgStr.clear());
894 if (CriticalPathOnly) {
895 PathSU = CriticalPathSU;
896 Edge = CriticalPathStep(PathSU);
898 PathSU = MISUnitMap[MI];
899 Edge = (PathSU) ? AntiDepPathStep(PathSU) : 0;
903 SUnit *NextSU = Edge->getSUnit();
905 // Only consider anti-dependence edges, and ignore KILL
906 // instructions (they form a group in ScanInstruction but
907 // don't cause any anti-dependence breaking themselves)
908 if ((Edge->getKind() == SDep::Anti) &&
909 (MI->getOpcode() != TargetInstrInfo::KILL)) {
910 AntiDepReg = Edge->getReg();
911 DEBUG(dbgStr += "\tAntidep reg: ");
912 DEBUG(dbgStr += TRI->getName(AntiDepReg));
913 assert(AntiDepReg != 0 && "Anti-dependence on reg0?");
914 if (!AllocatableSet.test(AntiDepReg)) {
915 // Don't break anti-dependencies on non-allocatable registers.
916 DEBUG(dbgStr += " (non-allocatable)");
919 int OpIdx = MI->findRegisterDefOperandIdx(AntiDepReg);
920 assert(OpIdx != -1 && "Can't find index for defined register operand");
921 if (MI->isRegTiedToUseOperand(OpIdx)) {
922 // If the anti-dep register is tied to a use, then don't try to
923 // change it. It will be changed along with the use if required
924 // to break an earlier antidep.
925 DEBUG(dbgStr += " (tied-to-use)");
928 // If the SUnit has other dependencies on the SUnit that
929 // it anti-depends on, don't bother breaking the
930 // anti-dependency since those edges would prevent such
931 // units from being scheduled past each other
934 // Also, if there are dependencies on other SUnits with
935 // the same register as the anti-dependency, don't
936 // attempt to break it.
937 for (SUnit::pred_iterator P = PathSU->Preds.begin(),
938 PE = PathSU->Preds.end(); P != PE; ++P) {
939 if (P->getSUnit() == NextSU ?
940 (P->getKind() != SDep::Anti || P->getReg() != AntiDepReg) :
941 (P->getKind() == SDep::Data && P->getReg() == AntiDepReg)) {
942 DEBUG(dbgStr += " (real dependency)");
951 if (CriticalPathOnly) {
952 CriticalPathSU = NextSU;
953 CriticalPathMI = CriticalPathSU->getInstr();
956 // We've reached the end of the critical path.
962 // Determine AntiDepReg's register group.
963 const unsigned GroupIndex = AntiDepReg != 0 ? GetGroup(AntiDepReg) : 0;
964 if (GroupIndex == 0) {
965 DEBUG(if (AntiDepReg != 0) dbgStr += " (zero group)");
969 DEBUG(if (!dbgStr.empty()) errs() << dbgStr << '\n');
971 // Look for a suitable register to use to break the anti-dependence.
973 // TODO: Instead of picking the first free register, consider which might
975 if (AntiDepReg != 0) {
976 if (unsigned NewReg = FindSuitableFreeRegister(AntiDepReg,
977 LastNewReg[AntiDepReg])) {
978 DEBUG(errs() << "\tBreaking anti-dependence edge on "
979 << TRI->getName(AntiDepReg)
980 << " with " << RegRefs.count(AntiDepReg) << " references"
981 << " using " << TRI->getName(NewReg) << "!\n");
983 // Update the references to the old register to refer to the new
985 std::pair<std::multimap<unsigned, RegisterReference>::iterator,
986 std::multimap<unsigned, RegisterReference>::iterator>
987 Range = RegRefs.equal_range(AntiDepReg);
988 for (std::multimap<unsigned, RegisterReference>::iterator
989 Q = Range.first, QE = Range.second; Q != QE; ++Q)
990 Q->second.Operand->setReg(NewReg);
992 // We just went back in time and modified history; the
993 // liveness information for the anti-dependence reg is now
994 // inconsistent. Set the state as if it were dead.
995 // FIXME forall in group
996 UnionGroups(NewReg, 0);
997 RegRefs.erase(NewReg);
998 DefIndices[NewReg] = DefIndices[AntiDepReg];
999 KillIndices[NewReg] = KillIndices[AntiDepReg];
1001 // FIXME forall in group
1002 UnionGroups(AntiDepReg, 0);
1003 RegRefs.erase(AntiDepReg);
1004 DefIndices[AntiDepReg] = KillIndices[AntiDepReg];
1005 KillIndices[AntiDepReg] = ~0u;
1006 assert(((KillIndices[AntiDepReg] == ~0u) !=
1007 (DefIndices[AntiDepReg] == ~0u)) &&
1008 "Kill and Def maps aren't consistent for AntiDepReg!");
1011 LastNewReg[AntiDepReg] = NewReg;
1016 ScanInstruction(MI, Count);
1022 /// StartBlockForKills - Initialize register live-range state for updating kills
1024 void SchedulePostRATDList::StartBlockForKills(MachineBasicBlock *BB) {
1025 // Initialize the indices to indicate that no registers are live.
1026 std::fill(KillIndices, array_endof(KillIndices), ~0u);
1028 // Determine the live-out physregs for this block.
1029 if (!BB->empty() && BB->back().getDesc().isReturn()) {
1030 // In a return block, examine the function live-out regs.
1031 for (MachineRegisterInfo::liveout_iterator I = MRI.liveout_begin(),
1032 E = MRI.liveout_end(); I != E; ++I) {
1034 KillIndices[Reg] = BB->size();
1035 // Repeat, for all subregs.
1036 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
1037 *Subreg; ++Subreg) {
1038 KillIndices[*Subreg] = BB->size();
1043 // In a non-return block, examine the live-in regs of all successors.
1044 for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
1045 SE = BB->succ_end(); SI != SE; ++SI) {
1046 for (MachineBasicBlock::livein_iterator I = (*SI)->livein_begin(),
1047 E = (*SI)->livein_end(); I != E; ++I) {
1049 KillIndices[Reg] = BB->size();
1050 // Repeat, for all subregs.
1051 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
1052 *Subreg; ++Subreg) {
1053 KillIndices[*Subreg] = BB->size();
1060 bool SchedulePostRATDList::ToggleKillFlag(MachineInstr *MI,
1061 MachineOperand &MO) {
1062 // Setting kill flag...
1068 // If MO itself is live, clear the kill flag...
1069 if (KillIndices[MO.getReg()] != ~0u) {
1070 MO.setIsKill(false);
1074 // If any subreg of MO is live, then create an imp-def for that
1075 // subreg and keep MO marked as killed.
1076 MO.setIsKill(false);
1077 bool AllDead = true;
1078 const unsigned SuperReg = MO.getReg();
1079 for (const unsigned *Subreg = TRI->getSubRegisters(SuperReg);
1080 *Subreg; ++Subreg) {
1081 if (KillIndices[*Subreg] != ~0u) {
1082 MI->addOperand(MachineOperand::CreateReg(*Subreg,
1096 /// FixupKills - Fix the register kill flags, they may have been made
1097 /// incorrect by instruction reordering.
1099 void SchedulePostRATDList::FixupKills(MachineBasicBlock *MBB) {
1100 DEBUG(errs() << "Fixup kills for BB ID#" << MBB->getNumber() << '\n');
1102 std::set<unsigned> killedRegs;
1103 BitVector ReservedRegs = TRI->getReservedRegs(MF);
1105 StartBlockForKills(MBB);
1107 // Examine block from end to start...
1108 unsigned Count = MBB->size();
1109 for (MachineBasicBlock::iterator I = MBB->end(), E = MBB->begin();
1111 MachineInstr *MI = --I;
1113 // Update liveness. Registers that are defed but not used in this
1114 // instruction are now dead. Mark register and all subregs as they
1115 // are completely defined.
1116 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
1117 MachineOperand &MO = MI->getOperand(i);
1118 if (!MO.isReg()) continue;
1119 unsigned Reg = MO.getReg();
1120 if (Reg == 0) continue;
1121 if (!MO.isDef()) continue;
1122 // Ignore two-addr defs.
1123 if (MI->isRegTiedToUseOperand(i)) continue;
1125 KillIndices[Reg] = ~0u;
1127 // Repeat for all subregs.
1128 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
1129 *Subreg; ++Subreg) {
1130 KillIndices[*Subreg] = ~0u;
1134 // Examine all used registers and set/clear kill flag. When a
1135 // register is used multiple times we only set the kill flag on
1138 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
1139 MachineOperand &MO = MI->getOperand(i);
1140 if (!MO.isReg() || !MO.isUse()) continue;
1141 unsigned Reg = MO.getReg();
1142 if ((Reg == 0) || ReservedRegs.test(Reg)) continue;
1145 if (killedRegs.find(Reg) == killedRegs.end()) {
1147 // A register is not killed if any subregs are live...
1148 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
1149 *Subreg; ++Subreg) {
1150 if (KillIndices[*Subreg] != ~0u) {
1156 // If subreg is not live, then register is killed if it became
1157 // live in this instruction
1159 kill = (KillIndices[Reg] == ~0u);
1162 if (MO.isKill() != kill) {
1163 bool removed = ToggleKillFlag(MI, MO);
1165 DEBUG(errs() << "Fixed <removed> in ");
1167 DEBUG(errs() << "Fixed " << MO << " in ");
1172 killedRegs.insert(Reg);
1175 // Mark any used register (that is not using undef) and subregs as
1177 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
1178 MachineOperand &MO = MI->getOperand(i);
1179 if (!MO.isReg() || !MO.isUse() || MO.isUndef()) continue;
1180 unsigned Reg = MO.getReg();
1181 if ((Reg == 0) || ReservedRegs.test(Reg)) continue;
1183 KillIndices[Reg] = Count;
1185 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
1186 *Subreg; ++Subreg) {
1187 KillIndices[*Subreg] = Count;
1193 //===----------------------------------------------------------------------===//
1194 // Top-Down Scheduling
1195 //===----------------------------------------------------------------------===//
1197 /// ReleaseSucc - Decrement the NumPredsLeft count of a successor. Add it to
1198 /// the PendingQueue if the count reaches zero. Also update its cycle bound.
1199 void SchedulePostRATDList::ReleaseSucc(SUnit *SU, SDep *SuccEdge) {
1200 SUnit *SuccSU = SuccEdge->getSUnit();
1203 if (SuccSU->NumPredsLeft == 0) {
1204 errs() << "*** Scheduling failed! ***\n";
1206 errs() << " has been released too many times!\n";
1207 llvm_unreachable(0);
1210 --SuccSU->NumPredsLeft;
1212 // Compute how many cycles it will be before this actually becomes
1213 // available. This is the max of the start time of all predecessors plus
1215 SuccSU->setDepthToAtLeast(SU->getDepth() + SuccEdge->getLatency());
1217 // If all the node's predecessors are scheduled, this node is ready
1218 // to be scheduled. Ignore the special ExitSU node.
1219 if (SuccSU->NumPredsLeft == 0 && SuccSU != &ExitSU)
1220 PendingQueue.push_back(SuccSU);
1223 /// ReleaseSuccessors - Call ReleaseSucc on each of SU's successors.
1224 void SchedulePostRATDList::ReleaseSuccessors(SUnit *SU) {
1225 for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
1227 ReleaseSucc(SU, &*I);
1230 /// ScheduleNodeTopDown - Add the node to the schedule. Decrement the pending
1231 /// count of its successors. If a successor pending count is zero, add it to
1232 /// the Available queue.
1233 void SchedulePostRATDList::ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle) {
1234 DEBUG(errs() << "*** Scheduling [" << CurCycle << "]: ");
1235 DEBUG(SU->dump(this));
1237 Sequence.push_back(SU);
1238 assert(CurCycle >= SU->getDepth() && "Node scheduled above its depth!");
1239 SU->setDepthToAtLeast(CurCycle);
1241 ReleaseSuccessors(SU);
1242 SU->isScheduled = true;
1243 AvailableQueue.ScheduledNode(SU);
1246 /// ListScheduleTopDown - The main loop of list scheduling for top-down
1248 void SchedulePostRATDList::ListScheduleTopDown() {
1249 unsigned CurCycle = 0;
1251 // Release any successors of the special Entry node.
1252 ReleaseSuccessors(&EntrySU);
1254 // All leaves to Available queue.
1255 for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
1256 // It is available if it has no predecessors.
1257 if (SUnits[i].Preds.empty()) {
1258 AvailableQueue.push(&SUnits[i]);
1259 SUnits[i].isAvailable = true;
1263 // In any cycle where we can't schedule any instructions, we must
1264 // stall or emit a noop, depending on the target.
1265 bool CycleHasInsts = false;
1267 // While Available queue is not empty, grab the node with the highest
1268 // priority. If it is not ready put it back. Schedule the node.
1269 std::vector<SUnit*> NotReady;
1270 Sequence.reserve(SUnits.size());
1271 while (!AvailableQueue.empty() || !PendingQueue.empty()) {
1272 // Check to see if any of the pending instructions are ready to issue. If
1273 // so, add them to the available queue.
1274 unsigned MinDepth = ~0u;
1275 for (unsigned i = 0, e = PendingQueue.size(); i != e; ++i) {
1276 if (PendingQueue[i]->getDepth() <= CurCycle) {
1277 AvailableQueue.push(PendingQueue[i]);
1278 PendingQueue[i]->isAvailable = true;
1279 PendingQueue[i] = PendingQueue.back();
1280 PendingQueue.pop_back();
1282 } else if (PendingQueue[i]->getDepth() < MinDepth)
1283 MinDepth = PendingQueue[i]->getDepth();
1286 DEBUG(errs() << "\n*** Examining Available\n";
1287 LatencyPriorityQueue q = AvailableQueue;
1288 while (!q.empty()) {
1289 SUnit *su = q.pop();
1290 errs() << "Height " << su->getHeight() << ": ";
1294 SUnit *FoundSUnit = 0;
1296 bool HasNoopHazards = false;
1297 while (!AvailableQueue.empty()) {
1298 SUnit *CurSUnit = AvailableQueue.pop();
1300 ScheduleHazardRecognizer::HazardType HT =
1301 HazardRec->getHazardType(CurSUnit);
1302 if (HT == ScheduleHazardRecognizer::NoHazard) {
1303 FoundSUnit = CurSUnit;
1307 // Remember if this is a noop hazard.
1308 HasNoopHazards |= HT == ScheduleHazardRecognizer::NoopHazard;
1310 NotReady.push_back(CurSUnit);
1313 // Add the nodes that aren't ready back onto the available list.
1314 if (!NotReady.empty()) {
1315 AvailableQueue.push_all(NotReady);
1319 // If we found a node to schedule, do it now.
1321 ScheduleNodeTopDown(FoundSUnit, CurCycle);
1322 HazardRec->EmitInstruction(FoundSUnit);
1323 CycleHasInsts = true;
1325 // If we are using the target-specific hazards, then don't
1326 // advance the cycle time just because we schedule a node. If
1327 // the target allows it we can schedule multiple nodes in the
1329 if (!EnablePostRAHazardAvoidance) {
1330 if (FoundSUnit->Latency) // Don't increment CurCycle for pseudo-ops!
1334 if (CycleHasInsts) {
1335 DEBUG(errs() << "*** Finished cycle " << CurCycle << '\n');
1336 HazardRec->AdvanceCycle();
1337 } else if (!HasNoopHazards) {
1338 // Otherwise, we have a pipeline stall, but no other problem,
1339 // just advance the current cycle and try again.
1340 DEBUG(errs() << "*** Stall in cycle " << CurCycle << '\n');
1341 HazardRec->AdvanceCycle();
1344 // Otherwise, we have no instructions to issue and we have instructions
1345 // that will fault if we don't do this right. This is the case for
1346 // processors without pipeline interlocks and other cases.
1347 DEBUG(errs() << "*** Emitting noop in cycle " << CurCycle << '\n');
1348 HazardRec->EmitNoop();
1349 Sequence.push_back(0); // NULL here means noop
1354 CycleHasInsts = false;
1359 VerifySchedule(/*isBottomUp=*/false);
1363 //===----------------------------------------------------------------------===//
1364 // Public Constructor Functions
1365 //===----------------------------------------------------------------------===//
1367 FunctionPass *llvm::createPostRAScheduler(CodeGenOpt::Level OptLevel) {
1368 return new PostRAScheduler(OptLevel);