[MISched] Fix post-RA pickOnlyChoice debug logs - #222927
Open
tomershafir wants to merge 1 commit into
Open
Conversation
On the way, adding a stable test for `pickOnlyOnce()` scheduling paths directly, which has been missing, while filechecking the fixed tracing.
tomershafir
marked this pull request as ready for review
September 11, 2026 12:16
|
@llvm/pr-subscribers-backend-aarch64 Author: Tomer Shafir (tomershafir) ChangesOn the way, adding a stable test for Full diff: https://github.com/llvm/llvm-project/pull/222927.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 4438adfaec2c1..1afbc6a789bb4 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -4532,7 +4532,7 @@ SUnit *PostGenericScheduler::pickNode(bool &IsTopNode) {
if (RegionPolicy.OnlyBottomUp) {
SU = Bot.pickOnlyChoice();
if (SU) {
- tracePick(SU, Only1, /*IsTopNode=*/true, /*IsPostRA=*/true);
+ tracePick(SU, Only1, /*IsTopNode=*/false, /*IsPostRA=*/true);
} else {
CandPolicy NoPolicy;
BotCand.reset(NoPolicy);
diff --git a/llvm/test/CodeGen/AArch64/misched-postra-only1.mir b/llvm/test/CodeGen/AArch64/misched-postra-only1.mir
new file mode 100644
index 0000000000000..c3f61537dd596
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/misched-postra-only1.mir
@@ -0,0 +1,114 @@
+# REQUIRES: asserts
+
+# RUN: llc -mtriple=aarch64 -mcpu=apple-m5 -run-pass=postmisched \
+# RUN: -enable-post-misched -verify-machineinstrs \
+# RUN: -debug-only=machine-scheduler -misched-postra-direction=topdown \
+# RUN: -o - %s 2>&1 | FileCheck --check-prefix=TOPDOWN %s
+# RUN: llc -mtriple=aarch64 -mcpu=apple-m5 -run-pass=postmisched \
+# RUN: -enable-post-misched -verify-machineinstrs \
+# RUN: -debug-only=machine-scheduler -misched-postra-direction=bottomup \
+# RUN: -o - %s 2>&1 | FileCheck --check-prefix=BOTTOMUP %s
+# RUN: llc -mtriple=aarch64 -mcpu=apple-m5 -run-pass=postmisched \
+# RUN: -enable-post-misched -verify-machineinstrs \
+# RUN: -debug-only=machine-scheduler -misched-postra-direction=bidirectional \
+# RUN: -o - %s 2>&1 | FileCheck --check-prefix=BIDIR %s
+
+---
+# A linear dependency chain leaves exactly one node available in either zone at
+# every step, so every pick comes from pickOnlyChoice(). Bidirectional picks
+# bottom-up throughout, because the bottom zone is queried first.
+
+# TOPDOWN: chain:%bb.0
+# TOPDOWN: Pick Top Cand SU(0) ONLY1 [post-RA]
+# TOPDOWN-NEXT: Scheduling SU(0)
+# TOPDOWN: Pick Top Cand SU(1) ONLY1 [post-RA]
+# TOPDOWN-NEXT: Scheduling SU(1)
+# TOPDOWN: Pick Top Cand SU(2) ONLY1 [post-RA]
+# TOPDOWN-NEXT: Scheduling SU(2)
+# TOPDOWN: *** Final schedule for %bb.0 ***
+# TOPDOWN-NEXT: SU(0): renamable $x1 = ADDXri renamable $x0, 1, 0
+# TOPDOWN-NEXT: SU(1): renamable $x2 = ADDXri renamable $x1, 1, 0
+# TOPDOWN-NEXT: SU(2): renamable $x3 = ADDXri renamable $x2, 1, 0
+
+# BOTTOMUP: chain:%bb.0
+# BOTTOMUP: Pick Bot Cand SU(2) ONLY1 [post-RA]
+# BOTTOMUP-NEXT: Scheduling SU(2)
+# BOTTOMUP: Pick Bot Cand SU(1) ONLY1 [post-RA]
+# BOTTOMUP-NEXT: Scheduling SU(1)
+# BOTTOMUP: Pick Bot Cand SU(0) ONLY1 [post-RA]
+# BOTTOMUP-NEXT: Scheduling SU(0)
+# BOTTOMUP: *** Final schedule for %bb.0 ***
+# BOTTOMUP-NEXT: SU(0): renamable $x1 = ADDXri renamable $x0, 1, 0
+# BOTTOMUP-NEXT: SU(1): renamable $x2 = ADDXri renamable $x1, 1, 0
+# BOTTOMUP-NEXT: SU(2): renamable $x3 = ADDXri renamable $x2, 1, 0
+
+# BIDIR: chain:%bb.0
+# BIDIR: Pick Bot Cand SU(2) ONLY1 [post-RA]
+# BIDIR-NEXT: Scheduling SU(2)
+# BIDIR: Pick Bot Cand SU(1) ONLY1 [post-RA]
+# BIDIR-NEXT: Scheduling SU(1)
+# BIDIR: Pick Bot Cand SU(0) ONLY1 [post-RA]
+# BIDIR-NEXT: Scheduling SU(0)
+# BIDIR: *** Final schedule for %bb.0 ***
+# BIDIR-NEXT: SU(0): renamable $x1 = ADDXri renamable $x0, 1, 0
+# BIDIR-NEXT: SU(1): renamable $x2 = ADDXri renamable $x1, 1, 0
+# BIDIR-NEXT: SU(2): renamable $x3 = ADDXri renamable $x2, 1, 0
+name: chain
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $x0
+ renamable $x1 = ADDXri renamable $x0, 1, 0
+ renamable $x2 = ADDXri renamable $x1, 1, 0
+ renamable $x3 = ADDXri renamable $x2, 1, 0
+ RET_ReallyLR implicit $x3
+...
+---
+# A fan-out leaves two nodes available at the bottom but only one at the top,
+# so bidirectional scheduling falls through to Top.pickOnlyChoice().
+
+# TOPDOWN: fanout:%bb.0
+# TOPDOWN: Pick Top Cand SU(0) ONLY1 [post-RA]
+# TOPDOWN-NEXT: Scheduling SU(0)
+# TOPDOWN: Pick Top Cand SU(1) ORDER [post-RA]
+# TOPDOWN-NEXT: Scheduling SU(1)
+# TOPDOWN: Pick Top Cand SU(2) ONLY1 [post-RA]
+# TOPDOWN-NEXT: Scheduling SU(2)
+# TOPDOWN: *** Final schedule for %bb.0 ***
+# TOPDOWN-NEXT: SU(0): renamable $x1 = ADDXri renamable $x0, 1, 0
+# TOPDOWN-NEXT: SU(1): renamable $x2 = ADDXri renamable $x1, 1, 0
+# TOPDOWN-NEXT: SU(2): renamable $x3 = ADDXri renamable $x1, 2, 0
+
+# BOTTOMUP: fanout:%bb.0
+# BOTTOMUP: Pick Bot Cand SU(1) ORDER [post-RA]
+# BOTTOMUP-NEXT: Scheduling SU(1)
+# BOTTOMUP: Pick Bot Cand SU(2) ONLY1 [post-RA]
+# BOTTOMUP-NEXT: Scheduling SU(2)
+# BOTTOMUP: Pick Bot Cand SU(0) ONLY1 [post-RA]
+# BOTTOMUP-NEXT: Scheduling SU(0)
+# BOTTOMUP: *** Final schedule for %bb.0 ***
+# BOTTOMUP-NEXT: SU(0): renamable $x1 = ADDXri renamable $x0, 1, 0
+# BOTTOMUP-NEXT: SU(2): renamable $x3 = ADDXri renamable $x1, 2, 0
+# BOTTOMUP-NEXT: SU(1): renamable $x2 = ADDXri renamable $x1, 1, 0
+
+# BIDIR: fanout:%bb.0
+# BIDIR: Pick Top Cand SU(0) ONLY1 [post-RA]
+# BIDIR-NEXT: Scheduling SU(0)
+# BIDIR: Pick Bot Cand SU(1) ORDER [post-RA]
+# BIDIR-NEXT: Scheduling SU(1)
+# BIDIR: Pick Bot Cand SU(2) ONLY1 [post-RA]
+# BIDIR-NEXT: Scheduling SU(2)
+# BIDIR: *** Final schedule for %bb.0 ***
+# BIDIR-NEXT: SU(0): renamable $x1 = ADDXri renamable $x0, 1, 0
+# BIDIR-NEXT: SU(2): renamable $x3 = ADDXri renamable $x1, 2, 0
+# BIDIR-NEXT: SU(1): renamable $x2 = ADDXri renamable $x1, 1, 0
+name: fanout
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $x0
+ renamable $x1 = ADDXri renamable $x0, 1, 0
+ renamable $x2 = ADDXri renamable $x1, 1, 0
+ renamable $x3 = ADDXri renamable $x1, 2, 0
+ RET_ReallyLR implicit $x2, implicit $x3
+...
|
tomershafir
requested review from
JonPsson,
arsenm,
mshockwave and
wangpc-pp
September 11, 2026 12:17
cofibrant
approved these changes
Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On the way, adding a stable test for
pickOnlyChoice()scheduling paths directly, which has been missing, while filechecking the fixed tracing.