aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
authorFrancesco Petrogalli <francesco.petrogalli@apple.com>2023-01-13 11:16:37 +0100
committerFrancesco Petrogalli <francesco.petrogalli@apple.com>2023-01-13 11:42:05 +0100
commitaba8983c9d86793b3388e7966389e51708fba9bd (patch)
tree178291aec661c6a01d83aa5bf2319518ba1e9b09 /llvm/lib/CodeGen/MachineScheduler.cpp
parent2f9f11180fde50cbd6d6263d3d305d9ae9b1d535 (diff)
downloadllvm-aba8983c9d86793b3388e7966389e51708fba9bd.zip
llvm-aba8983c9d86793b3388e7966389e51708fba9bd.tar.gz
llvm-aba8983c9d86793b3388e7966389e51708fba9bd.tar.bz2
Recommit [SchedBoundary] Add dump method for resource usage.
Summary: As supporting information, I have added an example that describes how the indexes of the vector of resources SchedBoundary::ReservedCycles are tracked by the field SchedBoundary::ReservedCyclesIndex. This has a minor rework of https://github.com/llvm/llvm-project/commit/b39a9a94f420a25a239ae03097c255900cbd660e which was reverted in https://github.com/llvm/llvm-project/commit/df6ae1779fafd9984e144a27315d6dd65b32c325 becasue the llc invocation of the test was missing the argument `-mtriple`. See for example the failure at https://lab.llvm.org/buildbot#builders/231/builds/7245 that reported the following when targeting a non-aarch64 native build: 'cortex-a55' is not a recognized processor for this target (ignoring processor) Reviewers: jroelofs Subscribers: Differential Revision: https://reviews.llvm.org/D141367
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineScheduler.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index e5cd462..e8c9562 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -95,6 +95,9 @@ cl::opt<bool> ViewMISchedDAGs(
cl::desc("Pop up a window to show MISched dags after they are processed"));
cl::opt<bool> PrintDAGs("misched-print-dags", cl::Hidden,
cl::desc("Print schedule DAGs"));
+cl::opt<bool> MISchedDumpReservedCycles(
+ "misched-dump-reserved-cycles", cl::Hidden, cl::init(false),
+ cl::desc("Dump resource usage at schedule boundary."));
#else
const bool ViewMISchedDAGs = false;
const bool PrintDAGs = false;
@@ -2589,6 +2592,28 @@ SUnit *SchedBoundary::pickOnlyChoice() {
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+
+/// Dump the content of the \ref ReservedCycles vector for the
+/// resources that are used in the basic block.
+///
+LLVM_DUMP_METHOD void SchedBoundary::dumpReservedCycles() const {
+ if (!SchedModel->hasInstrSchedModel())
+ return;
+
+ unsigned ResourceCount = SchedModel->getNumProcResourceKinds();
+ unsigned StartIdx = 0;
+
+ for (unsigned ResIdx = 0; ResIdx < ResourceCount; ++ResIdx) {
+ const unsigned NumUnits = SchedModel->getProcResource(ResIdx)->NumUnits;
+ std::string ResName = SchedModel->getResourceName(ResIdx);
+ for (unsigned UnitIdx = 0; UnitIdx < NumUnits; ++UnitIdx) {
+ dbgs() << ResName << "(" << UnitIdx
+ << ") = " << ReservedCycles[StartIdx + UnitIdx] << "\n";
+ }
+ StartIdx += NumUnits;
+ }
+}
+
// This is useful information to dump after bumpNode.
// Note that the Queue contents are more useful before pickNodeFromQueue.
LLVM_DUMP_METHOD void SchedBoundary::dumpScheduledState() const {
@@ -2611,6 +2636,8 @@ LLVM_DUMP_METHOD void SchedBoundary::dumpScheduledState() const {
<< "\n ExpectedLatency: " << ExpectedLatency << "c\n"
<< (IsResourceLimited ? " - Resource" : " - Latency")
<< " limited.\n";
+ if (MISchedDumpReservedCycles)
+ dumpReservedCycles();
}
#endif