[llvm] 8ea5eac - [MISched] Fix off-by-one error in debug output with -misched-cutoff=<n> flag (#137988)
via llvm-commits
llvm-commits at lists.llvm.org
Tue May 6 03:12:27 PDT 2025
Author: Cullen Rhodes
Date: 2025-05-06T11:12:23+01:00
New Revision: 8ea5eacea263ed5c2c4b0950a4d1d6ef863444bc
URL: https://github.com/llvm/llvm-project/commit/8ea5eacea263ed5c2c4b0950a4d1d6ef863444bc
DIFF: https://github.com/llvm/llvm-project/commit/8ea5eacea263ed5c2c4b0950a4d1d6ef863444bc.diff
LOG: [MISched] Fix off-by-one error in debug output with -misched-cutoff=<n> flag (#137988)
This flag instructs the scheduler to stop scheduling after N
instructions, but
in the debug output it appears as if it's scheduling N+1 instructions,
e.g.
$ llc -misched-cutoff=10 -debug-only=machine-scheduler
example.ll 2>&1 | grep "^Scheduling SU" | wc -l
11
as it calls pickNode before calling checkSchedLimit.
Added:
Modified:
llvm/lib/CodeGen/MachineScheduler.cpp
llvm/test/CodeGen/AArch64/misched-cutoff.mir
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 0c3ffb1bbaa6f..31acfef45cfee 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -1003,13 +1003,14 @@ void ScheduleDAGMI::schedule() {
bool IsTopNode = false;
while (true) {
+ if (!checkSchedLimit())
+ break;
+
LLVM_DEBUG(dbgs() << "** ScheduleDAGMI::schedule picking next node\n");
SUnit *SU = SchedImpl->pickNode(IsTopNode);
if (!SU) break;
assert(!SU->isScheduled && "Node already scheduled");
- if (!checkSchedLimit())
- break;
MachineInstr *MI = SU->getInstr();
if (IsTopNode) {
@@ -1637,13 +1638,14 @@ void ScheduleDAGMILive::schedule() {
bool IsTopNode = false;
while (true) {
+ if (!checkSchedLimit())
+ break;
+
LLVM_DEBUG(dbgs() << "** ScheduleDAGMILive::schedule picking next node\n");
SUnit *SU = SchedImpl->pickNode(IsTopNode);
if (!SU) break;
assert(!SU->isScheduled && "Node already scheduled");
- if (!checkSchedLimit())
- break;
scheduleMI(SU, IsTopNode);
diff --git a/llvm/test/CodeGen/AArch64/misched-cutoff.mir b/llvm/test/CodeGen/AArch64/misched-cutoff.mir
index a81fe1102ac9f..a61eb64318a39 100644
--- a/llvm/test/CodeGen/AArch64/misched-cutoff.mir
+++ b/llvm/test/CodeGen/AArch64/misched-cutoff.mir
@@ -4,7 +4,7 @@
# REQUIRES: asserts
-# CHECK-CUTOFF-COUNT-2: Scheduling SU
+# CHECK-CUTOFF-COUNT-1: Scheduling SU
# NOTE: copied from machine-scheduler.mir
More information about the llvm-commits
mailing list