[llvm-commits] [llvm] r153045 - /llvm/trunk/lib/CodeGen/MachineScheduler.cpp

Lang Hames lhames at gmail.com
Mon Mar 19 11:38:39 PDT 2012


Author: lhames
Date: Mon Mar 19 13:38:38 2012
New Revision: 153045

URL: http://llvm.org/viewvc/llvm-project?rev=153045&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/CodeGen/MachineScheduler.cpp

Modified: llvm/trunk/lib/CodeGen/MachineScheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineScheduler.cpp?rev=153045&r1=153044&r2=153045&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineScheduler.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineScheduler.cpp Mon Mar 19 13:38:38 2012
@@ -39,6 +39,9 @@
 #ifndef NDEBUG
 static cl::opt<bool> ViewMISchedDAGs("view-misched-dags", cl::Hidden,
   cl::desc("Pop up a window to show MISched dags after they are processed"));
+
+static cl::opt<unsigned> 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 @@
 
   /// 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 @@
   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));
 





More information about the llvm-commits mailing list