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

Valery Pykhtin via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 8 09:11:32 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) {
----------------
vpykhtin wrote:

This is a very nice feature. I think we can specify slot index to print the info. Also it could print all slot indexes where register pressure reaches maximum.

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


More information about the llvm-commits mailing list