[AMDGPU] Add EXPENSIVE_CHECK into GCNRPTracker::reset
authorValery Pykhtin <valery.pykhtin@gmail.com>
Thu, 27 Oct 2022 07:06:27 +0000 (09:06 +0200)
committerValery Pykhtin <valery.pykhtin@gmail.com>
Fri, 28 Oct 2022 06:42:21 +0000 (08:42 +0200)
This would check if passed in live-ins registers match those calculated using LIS.

This check currently breaks 420 lit tests when enabled.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D136860

llvm/lib/Target/AMDGPU/GCNRegPressure.cpp

index 2f38f7f..e0059e6 100644 (file)
@@ -260,6 +260,22 @@ void GCNRPTracker::reset(const MachineInstr &MI,
   }
 
   MaxPressure = CurPressure = getRegPressure(*MRI, LiveRegs);
+
+  LLVM_DEBUG(dbgs() << "\nReset " << (After ? "after" : "before") << ": " << MI
+                    << print(LiveRegs, *MRI));
+#if defined(EXPENSIVE_CHECKS) && !defined(NDEBUG)
+  if (LiveRegsCopy) {
+    auto LISLRS =
+        After ? getLiveRegsAfter(MI, LIS) : getLiveRegsBefore(MI, LIS);
+    if (!isEqual(LISLRS, *LiveRegsCopy)) {
+      dbgs() << "RP mismatch: "
+             << reportMismatch(LISLRS, *LiveRegsCopy,
+                               MRI->getTargetRegisterInfo());
+      llvm_unreachable("GCNRPTracker::reset LiveRegsCopy doens't match those "
+                       "calculated by LIS");
+    }
+  }
+#endif
 }
 
 void GCNUpwardRPTracker::reset(const MachineInstr &MI,