[llvm] [AMDGPU] GCNRegPressure printing pass for testing. (PR #70031)

Valery Pykhtin via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 00:17:27 PDT 2023


================
@@ -487,3 +488,77 @@ LLVM_DUMP_METHOD
 void GCNRegPressure::dump() const { dbgs() << print(*this); }
 
 #endif
+
+char llvm::GCNRegPressurePrinter::ID = 0;
+char &llvm::GCNRegPressurePrinterID = GCNRegPressurePrinter::ID;
+
+INITIALIZE_PASS(GCNRegPressurePrinter, "amdgpu-print-rp", "", true, true)
+
+bool GCNRegPressurePrinter::runOnMachineFunction(MachineFunction &MF) {
+  if (skipFunction(MF.getFunction()))
+    return false;
+
+  const MachineRegisterInfo &MRI = MF.getRegInfo();
+  const LiveIntervals &LIS = getAnalysis<LiveIntervals>();
+  GCNUpwardRPTracker RPT(LIS);
----------------
vpykhtin wrote:

Sorry I had to provide more context about this.
 
Piotr has found the problem with upward tracker [D33289](https://reviews.llvm.org/D33289) and Jay suggested to make a debug pass to test our RP values before fixing the tracker.

I think we should test both trackers and in theory they should give the same results so we can do an upward and downward runs and check their output with a single Filecheck prefix. If they don't match test update tool will warn about this and we can add a second and third prefixes to see the difference.

I've faced a situation when the trackers disagree, let me add the downward tracker option to this pass and I'll try to illustrate how it works.

Very briefly:
```
  undef %0.sub1:sgpr_64 = ...
  use %0
```
LiveIntervals creates only a subrange for _sub1_ subreg but not a subrange for undefined _sub0_, but _sub0_ is used when %0 is accessed.

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


More information about the llvm-commits mailing list