diff --git a/llvm/lib/CodeGen/ScheduleDAG.cpp b/llvm/lib/CodeGen/ScheduleDAG.cpp --- a/llvm/lib/CodeGen/ScheduleDAG.cpp +++ b/llvm/lib/CodeGen/ScheduleDAG.cpp @@ -46,6 +46,10 @@ static cl::opt StressSchedOpt( "stress-sched", cl::Hidden, cl::init(false), cl::desc("Stress test instruction scheduling")); + +static cl::opt SchedPrintCycles( + "sched-print-cycles", cl::Hidden, cl::init(false), + cl::desc("Report top/bottom cycles when dumping SUnit instances")); #endif void SchedulingPriorityQueue::anchor() {} @@ -356,8 +360,12 @@ dbgs() << "EntrySU"; else if (&SU == &ExitSU) dbgs() << "ExitSU"; - else - dbgs() << "SU(" << SU.NodeNum << ")"; + else { + dbgs() << "SU(" << SU.NodeNum; + if (SchedPrintCycles) + dbgs() << " " << SU.TopReadyCycle << " " << SU.BotReadyCycle; + dbgs()<< ")"; + } } LLVM_DUMP_METHOD void ScheduleDAG::dumpNodeAll(const SUnit &SU) const { diff --git a/llvm/test/CodeGen/AArch64/sched-print-cycle.mir b/llvm/test/CodeGen/AArch64/sched-print-cycle.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/sched-print-cycle.mir @@ -0,0 +1,23 @@ +# RUN: llc -mtriple=arm64-apple-macos -mcpu=apple-m1 -sched-print-cycles=true \ +# RUN: -run-pass=machine-scheduler -debug-only=machine-scheduler -o - %s 2>&1 | FileCheck %s + +# RUN: llc -mtriple=arm64-apple-macos -mcpu=apple-m1 -sched-print-cycles=false \ +# RUN: -run-pass=machine-scheduler -debug-only=machine-scheduler -o - %s 2>&1 | FileCheck %s --check-prefix=NOCYCLES + +# REQUIRES: asserts +--- +name: mul_mul +tracksRegLiveness: true +body: | + bb.0: + liveins: $x0 + $x1 = ADDXrr $x0, $x0 + $x2 = ADDXrr $x1, $x1 + +# CHECK-LABEL: *** Final schedule for %bb.0 *** +# CHECK: SU(0 0 0): $x1 = ADDXrr $x0, $x0 +# CHECK: SU(1 0 0): $x2 = ADDXrr $x1, $x1 + +# NOCYCLES-LABEL: *** Final schedule for %bb.0 *** +# NOCYCLES: SU(0): $x1 = ADDXrr $x0, $x0 +# NOCYCLES: SU(1): $x2 = ADDXrr $x1, $x1