[llvm] [MISched] Fix off-by-one error with -misched-cutoff=<n> flag (PR #137988)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 30 12:01:12 PDT 2025


https://github.com/mshockwave commented:

The "Scheduling SU" message you grep-ed was from `pickNode`. The reason you saw 11 messages when the cut-off was 10 is because `checkSchedLimit` is placed _after_ `pickNode`: https://github.com/llvm/llvm-project/blob/fa769655e73d70b480be8034a1cbc101115c1678/llvm/lib/CodeGen/MachineScheduler.cpp#L1007-L1012

So basically what happened was that although it showed 11 "Scheduling SU", the scheduler indeed only scheduled 10 instructions as it stopped right before it made any actual changes.

Therefore, following the same logic, I think your current patch will actually scheduled one _less_ instruction then the cut-off value provided by the user, which is probably undesired.

I think a better solution might be putting `checkSchedLimit` before `pickNode`.

https://github.com/llvm/llvm-project/pull/137988


More information about the llvm-commits mailing list