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 "AntiDepBreaker.h"
23 #include "AggressiveAntiDepBreaker.h"
24 #include "CriticalAntiDepBreaker.h"
25 #include "ExactHazardRecognizer.h"
26 #include "SimpleHazardRecognizer.h"
27 #include "ScheduleDAGInstrs.h"
28 #include "llvm/CodeGen/Passes.h"
29 #include "llvm/CodeGen/LatencyPriorityQueue.h"
30 #include "llvm/CodeGen/SchedulerRegistry.h"
31 #include "llvm/CodeGen/MachineDominators.h"
32 #include "llvm/CodeGen/MachineFrameInfo.h"
33 #include "llvm/CodeGen/MachineFunctionPass.h"
34 #include "llvm/CodeGen/MachineLoopInfo.h"
35 #include "llvm/CodeGen/MachineRegisterInfo.h"
36 #include "llvm/CodeGen/ScheduleHazardRecognizer.h"
37 #include "llvm/Analysis/AliasAnalysis.h"
38 #include "llvm/Target/TargetLowering.h"
39 #include "llvm/Target/TargetMachine.h"
40 #include "llvm/Target/TargetInstrInfo.h"
41 #include "llvm/Target/TargetRegisterInfo.h"
42 #include "llvm/Target/TargetSubtarget.h"
43 #include "llvm/Support/CommandLine.h"
44 #include "llvm/Support/Debug.h"
45 #include "llvm/Support/ErrorHandling.h"
46 #include "llvm/Support/raw_ostream.h"
47 #include "llvm/ADT/BitVector.h"
48 #include "llvm/ADT/Statistic.h"
52 STATISTIC(NumNoops, "Number of noops inserted");
53 STATISTIC(NumStalls, "Number of pipeline stalls");
54 STATISTIC(NumFixedAnti, "Number of fixed anti-dependencies");
56 // Post-RA scheduling is enabled with
57 // TargetSubtarget.enablePostRAScheduler(). This flag can be used to
58 // override the target.
60 EnablePostRAScheduler("post-RA-scheduler",
61 cl::desc("Enable scheduling after register allocation"),
62 cl::init(false), cl::Hidden);
63 static cl::opt<std::string>
64 EnableAntiDepBreaking("break-anti-dependencies",
65 cl::desc("Break post-RA scheduling anti-dependencies: "
66 "\"critical\", \"all\", or \"none\""),
67 cl::init("none"), cl::Hidden);
69 EnablePostRAHazardAvoidance("avoid-hazards",
70 cl::desc("Enable exact hazard avoidance"),
71 cl::init(true), cl::Hidden);
73 // If DebugDiv > 0 then only schedule MBB with (ID % DebugDiv) == DebugMod
75 DebugDiv("postra-sched-debugdiv",
76 cl::desc("Debug control MBBs that are scheduled"),
77 cl::init(0), cl::Hidden);
79 DebugMod("postra-sched-debugmod",
80 cl::desc("Debug control MBBs that are scheduled"),
81 cl::init(0), cl::Hidden);
83 AntiDepBreaker::~AntiDepBreaker() { }
86 class PostRAScheduler : public MachineFunctionPass {
88 CodeGenOpt::Level OptLevel;
92 PostRAScheduler(CodeGenOpt::Level ol) :
93 MachineFunctionPass(&ID), OptLevel(ol) {}
95 void getAnalysisUsage(AnalysisUsage &AU) const {
97 AU.addRequired<AliasAnalysis>();
98 AU.addRequired<MachineDominatorTree>();
99 AU.addPreserved<MachineDominatorTree>();
100 AU.addRequired<MachineLoopInfo>();
101 AU.addPreserved<MachineLoopInfo>();
102 MachineFunctionPass::getAnalysisUsage(AU);
105 const char *getPassName() const {
106 return "Post RA top-down list latency scheduler";
109 bool runOnMachineFunction(MachineFunction &Fn);
111 char PostRAScheduler::ID = 0;
113 class SchedulePostRATDList : public ScheduleDAGInstrs {
114 /// AvailableQueue - The priority queue to use for the available SUnits.
116 LatencyPriorityQueue AvailableQueue;
118 /// PendingQueue - This contains all of the instructions whose operands have
119 /// been issued, but their results are not ready yet (due to the latency of
120 /// the operation). Once the operands becomes available, the instruction is
121 /// added to the AvailableQueue.
122 std::vector<SUnit*> PendingQueue;
124 /// Topo - A topological ordering for SUnits.
125 ScheduleDAGTopologicalSort Topo;
127 /// HazardRec - The hazard recognizer to use.
128 ScheduleHazardRecognizer *HazardRec;
130 /// AntiDepBreak - Anti-dependence breaking object, or NULL if none
131 AntiDepBreaker *AntiDepBreak;
133 /// AA - AliasAnalysis for making memory reference queries.
136 /// KillIndices - The index of the most recent kill (proceding bottom-up),
137 /// or ~0u if the register is not live.
138 unsigned KillIndices[TargetRegisterInfo::FirstVirtualRegister];
141 SchedulePostRATDList(MachineFunction &MF,
142 const MachineLoopInfo &MLI,
143 const MachineDominatorTree &MDT,
144 ScheduleHazardRecognizer *HR,
147 : ScheduleDAGInstrs(MF, MLI, MDT), Topo(SUnits),
148 HazardRec(HR), AntiDepBreak(ADB), AA(aa) {}
150 ~SchedulePostRATDList() {
153 /// StartBlock - Initialize register live-range state for scheduling in
156 void StartBlock(MachineBasicBlock *BB);
158 /// Schedule - Schedule the instruction range using list scheduling.
162 /// Observe - Update liveness information to account for the current
163 /// instruction, which will not be scheduled.
165 void Observe(MachineInstr *MI, unsigned Count);
167 /// FinishBlock - Clean up register live-range state.
171 /// FixupKills - Fix register kill flags that have been made
172 /// invalid due to scheduling
174 void FixupKills(MachineBasicBlock *MBB);
177 void ReleaseSucc(SUnit *SU, SDep *SuccEdge);
178 void ReleaseSuccessors(SUnit *SU);
179 void ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle);
180 void ListScheduleTopDown();
181 void StartBlockForKills(MachineBasicBlock *BB);
183 // ToggleKillFlag - Toggle a register operand kill flag. Other
184 // adjustments may be made to the instruction if necessary. Return
185 // true if the operand has been deleted, false if not.
186 bool ToggleKillFlag(MachineInstr *MI, MachineOperand &MO);
190 /// isSchedulingBoundary - Test if the given instruction should be
191 /// considered a scheduling boundary. This primarily includes labels
194 static bool isSchedulingBoundary(const MachineInstr *MI,
195 const MachineFunction &MF) {
196 // Terminators and labels can't be scheduled around.
197 if (MI->getDesc().isTerminator() || MI->isLabel())
200 // Don't attempt to schedule around any instruction that modifies
201 // a stack-oriented pointer, as it's unlikely to be profitable. This
202 // saves compile time, because it doesn't require every single
203 // stack slot reference to depend on the instruction that does the
205 const TargetLowering &TLI = *MF.getTarget().getTargetLowering();
206 if (MI->modifiesRegister(TLI.getStackPointerRegisterToSaveRestore()))
212 bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) {
213 AA = &getAnalysis<AliasAnalysis>();
215 // Check for explicit enable/disable of post-ra scheduling.
216 TargetSubtarget::AntiDepBreakMode AntiDepMode = TargetSubtarget::ANTIDEP_NONE;
217 SmallVector<TargetRegisterClass*, 4> CriticalPathRCs;
218 if (EnablePostRAScheduler.getPosition() > 0) {
219 if (!EnablePostRAScheduler)
222 // Check that post-RA scheduling is enabled for this target.
223 const TargetSubtarget &ST = Fn.getTarget().getSubtarget<TargetSubtarget>();
224 if (!ST.enablePostRAScheduler(OptLevel, AntiDepMode, CriticalPathRCs))
228 // Check for antidep breaking override...
229 if (EnableAntiDepBreaking.getPosition() > 0) {
230 AntiDepMode = (EnableAntiDepBreaking == "all") ? TargetSubtarget::ANTIDEP_ALL :
231 (EnableAntiDepBreaking == "critical") ? TargetSubtarget::ANTIDEP_CRITICAL :
232 TargetSubtarget::ANTIDEP_NONE;
235 DEBUG(dbgs() << "PostRAScheduler\n");
237 const MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>();
238 const MachineDominatorTree &MDT = getAnalysis<MachineDominatorTree>();
239 const InstrItineraryData &InstrItins = Fn.getTarget().getInstrItineraryData();
240 ScheduleHazardRecognizer *HR = EnablePostRAHazardAvoidance ?
241 (ScheduleHazardRecognizer *)new ExactHazardRecognizer(InstrItins) :
242 (ScheduleHazardRecognizer *)new SimpleHazardRecognizer();
243 AntiDepBreaker *ADB =
244 ((AntiDepMode == TargetSubtarget::ANTIDEP_ALL) ?
245 (AntiDepBreaker *)new AggressiveAntiDepBreaker(Fn, CriticalPathRCs) :
246 ((AntiDepMode == TargetSubtarget::ANTIDEP_CRITICAL) ?
247 (AntiDepBreaker *)new CriticalAntiDepBreaker(Fn) : NULL));
249 SchedulePostRATDList Scheduler(Fn, MLI, MDT, HR, ADB, AA);
251 // Loop over all of the basic blocks
252 for (MachineFunction::iterator MBB = Fn.begin(), MBBe = Fn.end();
253 MBB != MBBe; ++MBB) {
255 // If DebugDiv > 0 then only schedule MBB with (ID % DebugDiv) == DebugMod
257 static int bbcnt = 0;
258 if (bbcnt++ % DebugDiv != DebugMod)
260 dbgs() << "*** DEBUG scheduling " << Fn.getFunction()->getNameStr() <<
261 ":BB#" << MBB->getNumber() << " ***\n";
265 // Initialize register live-range state for scheduling in this block.
266 Scheduler.StartBlock(MBB);
268 // FIXME: Temporary workaround for <rdar://problem/7759363>: The post-RA
269 // scheduler has some sort of problem with DebugValue instructions that
270 // causes an assertion in LeaksContext.h to fail occasionally. Just
271 // remove all those instructions for now.
272 for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
274 MachineInstr *MI = &*I++;
275 if (MI->isDebugValue())
276 MI->eraseFromParent();
279 // Schedule each sequence of instructions not interrupted by a label
280 // or anything else that effectively needs to shut down scheduling.
281 MachineBasicBlock::iterator Current = MBB->end();
282 unsigned Count = MBB->size(), CurrentCount = Count;
283 for (MachineBasicBlock::iterator I = Current; I != MBB->begin(); ) {
284 MachineInstr *MI = prior(I);
285 if (isSchedulingBoundary(MI, Fn)) {
286 Scheduler.Run(MBB, I, Current, CurrentCount);
287 Scheduler.EmitSchedule(0);
289 CurrentCount = Count - 1;
290 Scheduler.Observe(MI, CurrentCount);
295 assert(Count == 0 && "Instruction count mismatch!");
296 assert((MBB->begin() == Current || CurrentCount != 0) &&
297 "Instruction count mismatch!");
298 Scheduler.Run(MBB, MBB->begin(), Current, CurrentCount);
299 Scheduler.EmitSchedule(0);
301 // Clean up register live-range state.
302 Scheduler.FinishBlock();
304 // Update register kills
305 Scheduler.FixupKills(MBB);
314 /// StartBlock - Initialize register live-range state for scheduling in
317 void SchedulePostRATDList::StartBlock(MachineBasicBlock *BB) {
318 // Call the superclass.
319 ScheduleDAGInstrs::StartBlock(BB);
321 // Reset the hazard recognizer and anti-dep breaker.
323 if (AntiDepBreak != NULL)
324 AntiDepBreak->StartBlock(BB);
327 /// Schedule - Schedule the instruction range using list scheduling.
329 void SchedulePostRATDList::Schedule() {
330 // Build the scheduling graph.
333 if (AntiDepBreak != NULL) {
335 AntiDepBreak->BreakAntiDependencies(SUnits, Begin, InsertPos,
339 // We made changes. Update the dependency graph.
340 // Theoretically we could update the graph in place:
341 // When a live range is changed to use a different register, remove
342 // the def's anti-dependence *and* output-dependence edges due to
343 // that register, and add new anti-dependence and output-dependence
344 // edges based on the next live range of the register.
351 NumFixedAnti += Broken;
355 DEBUG(dbgs() << "********** List Scheduling **********\n");
356 DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su)
357 SUnits[su].dumpAll(this));
359 AvailableQueue.initNodes(SUnits);
360 ListScheduleTopDown();
361 AvailableQueue.releaseState();
364 /// Observe - Update liveness information to account for the current
365 /// instruction, which will not be scheduled.
367 void SchedulePostRATDList::Observe(MachineInstr *MI, unsigned Count) {
368 if (AntiDepBreak != NULL)
369 AntiDepBreak->Observe(MI, Count, InsertPosIndex);
372 /// FinishBlock - Clean up register live-range state.
374 void SchedulePostRATDList::FinishBlock() {
375 if (AntiDepBreak != NULL)
376 AntiDepBreak->FinishBlock();
378 // Call the superclass.
379 ScheduleDAGInstrs::FinishBlock();
382 /// StartBlockForKills - Initialize register live-range state for updating kills
384 void SchedulePostRATDList::StartBlockForKills(MachineBasicBlock *BB) {
385 // Initialize the indices to indicate that no registers are live.
386 for (unsigned i = 0; i < TRI->getNumRegs(); ++i)
387 KillIndices[i] = ~0u;
389 // Determine the live-out physregs for this block.
390 if (!BB->empty() && BB->back().getDesc().isReturn()) {
391 // In a return block, examine the function live-out regs.
392 for (MachineRegisterInfo::liveout_iterator I = MRI.liveout_begin(),
393 E = MRI.liveout_end(); I != E; ++I) {
395 KillIndices[Reg] = BB->size();
396 // Repeat, for all subregs.
397 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
399 KillIndices[*Subreg] = BB->size();
404 // In a non-return block, examine the live-in regs of all successors.
405 for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
406 SE = BB->succ_end(); SI != SE; ++SI) {
407 for (MachineBasicBlock::livein_iterator I = (*SI)->livein_begin(),
408 E = (*SI)->livein_end(); I != E; ++I) {
410 KillIndices[Reg] = BB->size();
411 // Repeat, for all subregs.
412 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
414 KillIndices[*Subreg] = BB->size();
421 bool SchedulePostRATDList::ToggleKillFlag(MachineInstr *MI,
422 MachineOperand &MO) {
423 // Setting kill flag...
429 // If MO itself is live, clear the kill flag...
430 if (KillIndices[MO.getReg()] != ~0u) {
435 // If any subreg of MO is live, then create an imp-def for that
436 // subreg and keep MO marked as killed.
439 const unsigned SuperReg = MO.getReg();
440 for (const unsigned *Subreg = TRI->getSubRegisters(SuperReg);
442 if (KillIndices[*Subreg] != ~0u) {
443 MI->addOperand(MachineOperand::CreateReg(*Subreg,
457 /// FixupKills - Fix the register kill flags, they may have been made
458 /// incorrect by instruction reordering.
460 void SchedulePostRATDList::FixupKills(MachineBasicBlock *MBB) {
461 DEBUG(dbgs() << "Fixup kills for BB#" << MBB->getNumber() << '\n');
463 std::set<unsigned> killedRegs;
464 BitVector ReservedRegs = TRI->getReservedRegs(MF);
466 StartBlockForKills(MBB);
468 // Examine block from end to start...
469 unsigned Count = MBB->size();
470 for (MachineBasicBlock::iterator I = MBB->end(), E = MBB->begin();
472 MachineInstr *MI = --I;
473 if (MI->isDebugValue())
476 // Update liveness. Registers that are defed but not used in this
477 // instruction are now dead. Mark register and all subregs as they
478 // are completely defined.
479 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
480 MachineOperand &MO = MI->getOperand(i);
481 if (!MO.isReg()) continue;
482 unsigned Reg = MO.getReg();
483 if (Reg == 0) continue;
484 if (!MO.isDef()) continue;
485 // Ignore two-addr defs.
486 if (MI->isRegTiedToUseOperand(i)) continue;
488 KillIndices[Reg] = ~0u;
490 // Repeat for all subregs.
491 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
493 KillIndices[*Subreg] = ~0u;
497 // Examine all used registers and set/clear kill flag. When a
498 // register is used multiple times we only set the kill flag on
501 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
502 MachineOperand &MO = MI->getOperand(i);
503 if (!MO.isReg() || !MO.isUse()) continue;
504 unsigned Reg = MO.getReg();
505 if ((Reg == 0) || ReservedRegs.test(Reg)) continue;
508 if (killedRegs.find(Reg) == killedRegs.end()) {
510 // A register is not killed if any subregs are live...
511 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
513 if (KillIndices[*Subreg] != ~0u) {
519 // If subreg is not live, then register is killed if it became
520 // live in this instruction
522 kill = (KillIndices[Reg] == ~0u);
525 if (MO.isKill() != kill) {
526 DEBUG(dbgs() << "Fixing " << MO << " in ");
527 // Warning: ToggleKillFlag may invalidate MO.
528 ToggleKillFlag(MI, MO);
532 killedRegs.insert(Reg);
535 // Mark any used register (that is not using undef) and subregs as
537 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
538 MachineOperand &MO = MI->getOperand(i);
539 if (!MO.isReg() || !MO.isUse() || MO.isUndef()) continue;
540 unsigned Reg = MO.getReg();
541 if ((Reg == 0) || ReservedRegs.test(Reg)) continue;
543 KillIndices[Reg] = Count;
545 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
547 KillIndices[*Subreg] = Count;
553 //===----------------------------------------------------------------------===//
554 // Top-Down Scheduling
555 //===----------------------------------------------------------------------===//
557 /// ReleaseSucc - Decrement the NumPredsLeft count of a successor. Add it to
558 /// the PendingQueue if the count reaches zero. Also update its cycle bound.
559 void SchedulePostRATDList::ReleaseSucc(SUnit *SU, SDep *SuccEdge) {
560 SUnit *SuccSU = SuccEdge->getSUnit();
563 if (SuccSU->NumPredsLeft == 0) {
564 dbgs() << "*** Scheduling failed! ***\n";
566 dbgs() << " has been released too many times!\n";
570 --SuccSU->NumPredsLeft;
572 // Compute how many cycles it will be before this actually becomes
573 // available. This is the max of the start time of all predecessors plus
575 SuccSU->setDepthToAtLeast(SU->getDepth() + SuccEdge->getLatency());
577 // If all the node's predecessors are scheduled, this node is ready
578 // to be scheduled. Ignore the special ExitSU node.
579 if (SuccSU->NumPredsLeft == 0 && SuccSU != &ExitSU)
580 PendingQueue.push_back(SuccSU);
583 /// ReleaseSuccessors - Call ReleaseSucc on each of SU's successors.
584 void SchedulePostRATDList::ReleaseSuccessors(SUnit *SU) {
585 for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
587 ReleaseSucc(SU, &*I);
591 /// ScheduleNodeTopDown - Add the node to the schedule. Decrement the pending
592 /// count of its successors. If a successor pending count is zero, add it to
593 /// the Available queue.
594 void SchedulePostRATDList::ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle) {
595 DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: ");
596 DEBUG(SU->dump(this));
598 Sequence.push_back(SU);
599 assert(CurCycle >= SU->getDepth() &&
600 "Node scheduled above its depth!");
601 SU->setDepthToAtLeast(CurCycle);
603 ReleaseSuccessors(SU);
604 SU->isScheduled = true;
605 AvailableQueue.ScheduledNode(SU);
608 /// ListScheduleTopDown - The main loop of list scheduling for top-down
610 void SchedulePostRATDList::ListScheduleTopDown() {
611 unsigned CurCycle = 0;
613 // We're scheduling top-down but we're visiting the regions in
614 // bottom-up order, so we don't know the hazards at the start of a
615 // region. So assume no hazards (this should usually be ok as most
616 // blocks are a single region).
619 // Release any successors of the special Entry node.
620 ReleaseSuccessors(&EntrySU);
622 // Add all leaves to Available queue.
623 for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
624 // It is available if it has no predecessors.
625 bool available = SUnits[i].Preds.empty();
627 AvailableQueue.push(&SUnits[i]);
628 SUnits[i].isAvailable = true;
632 // In any cycle where we can't schedule any instructions, we must
633 // stall or emit a noop, depending on the target.
634 bool CycleHasInsts = false;
636 // While Available queue is not empty, grab the node with the highest
637 // priority. If it is not ready put it back. Schedule the node.
638 std::vector<SUnit*> NotReady;
639 Sequence.reserve(SUnits.size());
640 while (!AvailableQueue.empty() || !PendingQueue.empty()) {
641 // Check to see if any of the pending instructions are ready to issue. If
642 // so, add them to the available queue.
643 unsigned MinDepth = ~0u;
644 for (unsigned i = 0, e = PendingQueue.size(); i != e; ++i) {
645 if (PendingQueue[i]->getDepth() <= CurCycle) {
646 AvailableQueue.push(PendingQueue[i]);
647 PendingQueue[i]->isAvailable = true;
648 PendingQueue[i] = PendingQueue.back();
649 PendingQueue.pop_back();
651 } else if (PendingQueue[i]->getDepth() < MinDepth)
652 MinDepth = PendingQueue[i]->getDepth();
655 DEBUG(dbgs() << "\n*** Examining Available\n";
656 LatencyPriorityQueue q = AvailableQueue;
659 dbgs() << "Height " << su->getHeight() << ": ";
663 SUnit *FoundSUnit = 0;
664 bool HasNoopHazards = false;
665 while (!AvailableQueue.empty()) {
666 SUnit *CurSUnit = AvailableQueue.pop();
668 ScheduleHazardRecognizer::HazardType HT =
669 HazardRec->getHazardType(CurSUnit);
670 if (HT == ScheduleHazardRecognizer::NoHazard) {
671 FoundSUnit = CurSUnit;
675 // Remember if this is a noop hazard.
676 HasNoopHazards |= HT == ScheduleHazardRecognizer::NoopHazard;
678 NotReady.push_back(CurSUnit);
681 // Add the nodes that aren't ready back onto the available list.
682 if (!NotReady.empty()) {
683 AvailableQueue.push_all(NotReady);
687 // If we found a node to schedule...
689 // ... schedule the node...
690 ScheduleNodeTopDown(FoundSUnit, CurCycle);
691 HazardRec->EmitInstruction(FoundSUnit);
692 CycleHasInsts = true;
694 // If we are using the target-specific hazards, then don't
695 // advance the cycle time just because we schedule a node. If
696 // the target allows it we can schedule multiple nodes in the
698 if (!EnablePostRAHazardAvoidance) {
699 if (FoundSUnit->Latency) // Don't increment CurCycle for pseudo-ops!
704 DEBUG(dbgs() << "*** Finished cycle " << CurCycle << '\n');
705 HazardRec->AdvanceCycle();
706 } else if (!HasNoopHazards) {
707 // Otherwise, we have a pipeline stall, but no other problem,
708 // just advance the current cycle and try again.
709 DEBUG(dbgs() << "*** Stall in cycle " << CurCycle << '\n');
710 HazardRec->AdvanceCycle();
713 // Otherwise, we have no instructions to issue and we have instructions
714 // that will fault if we don't do this right. This is the case for
715 // processors without pipeline interlocks and other cases.
716 DEBUG(dbgs() << "*** Emitting noop in cycle " << CurCycle << '\n');
717 HazardRec->EmitNoop();
718 Sequence.push_back(0); // NULL here means noop
723 CycleHasInsts = false;
728 VerifySchedule(/*isBottomUp=*/false);
732 //===----------------------------------------------------------------------===//
733 // Public Constructor Functions
734 //===----------------------------------------------------------------------===//
736 FunctionPass *llvm::createPostRAScheduler(CodeGenOpt::Level OptLevel) {
737 return new PostRAScheduler(OptLevel);