[llvm] [AMDGPU] Add register usage diagnostics at the point of maximum register pressure. (PR #161850)

Tony Linthicum via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 8 08:32:17 PDT 2025


================
@@ -986,3 +991,128 @@ bool GCNRegPressurePrinter::runOnMachineFunction(MachineFunction &MF) {
 
 #undef PFX
 }
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+LLVM_DUMP_METHOD void llvm::dumpMaxRegPressure(MachineFunction &MF,
+                                               GCNRegPressure::RegKind Kind,
+                                               LiveIntervals &LIS,
+                                               const MachineLoopInfo *MLI) {
+
+  const MachineRegisterInfo &MRI = MF.getRegInfo();
+  const TargetRegisterInfo *TRI = MRI.getTargetRegisterInfo();
+  auto &OS = dbgs();
+  const char *RegName = GCNRegPressure::getName(Kind);
+
+  unsigned MaxNumRegs = 0;
+  MachineInstr *MaxPressureMI = nullptr;
+  GCNUpwardRPTracker RPT(LIS);
+  for (auto &MBB : MF) {
----------------
tlinthic wrote:

This is just a suggestion for potentially increased utility.  Most of the time the highest register pressure in the program unit is what you are interested in, but not always.  It could be useful to have this dump be more targeted.  That is, provide an option to make it specific to a single basic block or even a scheduling region.  This isn't something that needs to be done now, of course.

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


More information about the llvm-commits mailing list