aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
authorFrancesco Petrogalli <francesco.petrogalli@apple.com>2023-01-13 10:04:39 +0100
committerFrancesco Petrogalli <francesco.petrogalli@apple.com>2023-01-13 10:38:43 +0100
commitb39a9a94f420a25a239ae03097c255900cbd660e (patch)
treeba6d25eb7b66e515dee23e559610eb611968a11c /llvm/lib/CodeGen/MachineScheduler.cpp
parent8c45d1ad06d5f72b7175ea677a57f789b1384995 (diff)
downloadllvm-b39a9a94f420a25a239ae03097c255900cbd660e.zip
llvm-b39a9a94f420a25a239ae03097c255900cbd660e.tar.gz
llvm-b39a9a94f420a25a239ae03097c255900cbd660e.tar.bz2
[SchedBoundary] Add dump method for resource usage.
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. Reviewed By: jroelofs 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