[llvm] [MISched] Add statistics for heuristics (PR #137981)
Cullen Rhodes via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 30 23:30:56 PDT 2025
================
@@ -3420,13 +3511,137 @@ bool tryLatency(GenericSchedulerBase::SchedCandidate &TryCand,
}
} // end namespace llvm
-static void tracePick(GenericSchedulerBase::CandReason Reason, bool IsTop) {
+static void tracePick(GenericSchedulerBase::CandReason Reason, bool IsTop,
+ bool IsPostRA = false) {
LLVM_DEBUG(dbgs() << "Pick " << (IsTop ? "Top " : "Bot ")
- << GenericSchedulerBase::getReasonStr(Reason) << '\n');
+ << GenericSchedulerBase::getReasonStr(Reason) << " ["
+ << (IsPostRA ? "post-RA" : "pre-RA") << "]\n");
+
+ if (IsPostRA) {
+ if (IsTop)
+ NumTopPostRA++;
+ else
+ NumBotPostRA++;
+
+ switch (Reason) {
+ case GenericScheduler::NoCand:
+ NumNoCandPostRA++;
+ return;
+ case GenericScheduler::Only1:
+ NumOnly1PostRA++;
+ return;
+ case GenericScheduler::PhysReg:
+ NumPhysRegPostRA++;
+ return;
+ case GenericScheduler::RegExcess:
+ NumRegExcessPostRA++;
+ return;
+ case GenericScheduler::RegCritical:
+ NumRegCriticalPostRA++;
+ return;
+ case GenericScheduler::Stall:
+ NumStallPostRA++;
+ return;
+ case GenericScheduler::Cluster:
+ NumClusterPostRA++;
+ return;
+ case GenericScheduler::Weak:
+ NumWeakPostRA++;
+ return;
+ case GenericScheduler::RegMax:
+ NumRegMaxPostRA++;
+ return;
+ case GenericScheduler::ResourceReduce:
+ NumResourceReducePostRA++;
+ return;
+ case GenericScheduler::ResourceDemand:
+ NumResourceDemandPostRA++;
+ return;
+ case GenericScheduler::TopDepthReduce:
+ NumTopDepthReducePostRA++;
+ return;
+ case GenericScheduler::TopPathReduce:
+ NumTopPathReducePostRA++;
+ return;
+ case GenericScheduler::BotHeightReduce:
+ NumBotHeightReducePostRA++;
+ return;
+ case GenericScheduler::BotPathReduce:
+ NumBotPathReducePostRA++;
+ return;
+ case GenericScheduler::NodeOrder:
+ NumNodeOrderPostRA++;
+ return;
+ case GenericScheduler::FirstValid:
+ NumFirstValidPostRA++;
+ return;
+ };
+ } else {
+ if (IsTop)
+ NumTopPreRA++;
+ else
+ NumBotPreRA++;
+
+ switch (Reason) {
+ case GenericScheduler::NoCand:
+ NumNoCandPreRA++;
+ return;
+ case GenericScheduler::Only1:
+ NumOnly1PreRA++;
+ return;
+ case GenericScheduler::PhysReg:
+ NumPhysRegPreRA++;
+ return;
+ case GenericScheduler::RegExcess:
+ NumRegExcessPreRA++;
+ return;
+ case GenericScheduler::RegCritical:
+ NumRegCriticalPreRA++;
+ return;
+ case GenericScheduler::Stall:
+ NumStallPreRA++;
+ return;
+ case GenericScheduler::Cluster:
+ NumClusterPreRA++;
+ return;
+ case GenericScheduler::Weak:
+ NumWeakPreRA++;
+ return;
+ case GenericScheduler::RegMax:
+ NumRegMaxPreRA++;
+ return;
+ case GenericScheduler::ResourceReduce:
+ NumResourceReducePreRA++;
+ return;
+ case GenericScheduler::ResourceDemand:
+ NumResourceDemandPreRA++;
+ return;
+ case GenericScheduler::TopDepthReduce:
+ NumTopDepthReducePreRA++;
+ return;
+ case GenericScheduler::TopPathReduce:
+ NumTopPathReducePreRA++;
+ return;
+ case GenericScheduler::BotHeightReduce:
+ NumBotHeightReducePreRA++;
+ return;
+ case GenericScheduler::BotPathReduce:
+ NumBotPathReducePreRA++;
+ return;
+ case GenericScheduler::NodeOrder:
+ NumNodeOrderPreRA++;
+ return;
+ case GenericScheduler::FirstValid:
+ NumFirstValidPreRA++;
+ return;
+ };
+ }
+ llvm_unreachable("Unknown reason!");
----------------
c-rhodes wrote:
it's a pretty standard use of unreachable as far as I'm aware: https://llvm.org/docs/ProgrammersManual.html#programmatic-errors
https://github.com/llvm/llvm-project/pull/137981
More information about the llvm-commits
mailing list