From: Lang Hames Date: Mon, 19 Mar 2012 18:38:38 +0000 (+0000) Subject: Add an option to the MI scheduler to cut off scheduling after a fixed number of X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=23f1cbbd686513ae5defbd3afdf5e286befe8a76;p=oota-llvm.git Add an option to the MI scheduler to cut off scheduling after a fixed number of instructions have been scheduled. Handy for tracking down scheduler bugs, or bugs exposed by scheduling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153045 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp index 10a318c46dc..f1a2532200b 100644 --- a/lib/CodeGen/MachineScheduler.cpp +++ b/lib/CodeGen/MachineScheduler.cpp @@ -39,6 +39,9 @@ static cl::opt ForceBottomUp("misched-bottomup", cl::Hidden, #ifndef NDEBUG static cl::opt ViewMISchedDAGs("view-misched-dags", cl::Hidden, cl::desc("Pop up a window to show MISched dags after they are processed")); + +static cl::opt MISchedCutoff("misched-cutoff", cl::Hidden, + cl::desc("Stop scheduling after N instructions"), cl::init(~0U)); #else static bool ViewMISchedDAGs = false; #endif // NDEBUG @@ -281,10 +284,15 @@ class ScheduleDAGMI : public ScheduleDAGInstrs { /// The bottom of the unscheduled zone. MachineBasicBlock::iterator CurrentBottom; + + /// The number of instructions scheduled so far. Used to cut off the + /// scheduler at the point determined by misched-cutoff. + unsigned NumInstrsScheduled; public: ScheduleDAGMI(MachineSchedContext *C, MachineSchedStrategy *S): ScheduleDAGInstrs(*C->MF, *C->MLI, *C->MDT, /*IsPostRA=*/false, C->LIS), - AA(C->AA), SchedImpl(S), CurrentTop(), CurrentBottom() {} + AA(C->AA), SchedImpl(S), CurrentTop(), CurrentBottom(), + NumInstrsScheduled(0) {} ~ScheduleDAGMI() { delete SchedImpl; @@ -398,6 +406,16 @@ void ScheduleDAGMI::schedule() { CurrentBottom = RegionEnd; bool IsTopNode = false; while (SUnit *SU = SchedImpl->pickNode(IsTopNode)) { + +#ifndef NDEBUG + // Enable break + if (NumInstrsScheduled == MISchedCutoff && MISchedCutoff != ~0U) { + CurrentTop = CurrentBottom; + break; + } + ++NumInstrsScheduled; +#endif + DEBUG(dbgs() << "*** " << (IsTopNode ? "Top" : "Bottom") << " Scheduling Instruction:\n"; SU->dump(this));