[llvm-branch-commits] [llvm] [AMDGPU] Physical register tracking in GCN trackers. (PR #184275)

Matt Arsenault via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Mar 3 02:19:09 PST 2026


================
@@ -335,17 +370,60 @@ class GCNRPTracker {
 
   LaneBitmask getLastUsedLanes(Register Reg, SlotIndex Pos) const;
 
+  // Helper to check if a register unit is live at a given slot index.
+  bool isUnitLiveAt(MCRegUnit Unit, SlotIndex SI) const;
+
+  // Check if all register units of Reg are currently live in PhysLiveRegs.
+  bool allRegUnitsLive(Register Reg) const;
+
+  // Check if Reg has any killed units at the given slot index.
+  bool checkRegKilled(Register Reg, SlotIndex SI) const;
+
+  // Check if Reg has any killed units and erase them from PhysLiveRegs.
+  bool eraseKilledUnits(Register Reg, SlotIndex SI);
+
+  // Erase all live units of Reg from PhysLiveRegs.
+  // Returns true if any unit was live (and thus erased).
+  bool eraseAllLiveUnits(Register Reg);
+
+  // Insert all not-live units of Reg into PhysLiveRegs.
+  // Returns true if any unit was not live (and thus inserted).
+  bool insertAllNotLiveUnits(Register Reg);
+
 public:
+  // Enable physical register tracking only if both GCNTrackers and
+  // TrackPhysRegInTrackers are true.
+  void setPhysRegTracking();
+
   // reset tracker and set live register set to the specified value.
   void reset(const MachineRegisterInfo &MRInfo,
              const LiveRegSet &VirtLiveRegsSet);
+
   // live regs for the current state
   const decltype(VirtLiveRegs) &getLiveRegs() const { return VirtLiveRegs; }
+  const decltype(VirtLiveRegs) &getVirtLiveRegs() const { return VirtLiveRegs; }
   const MachineInstr *getLastTrackedMI() const { return LastTrackedMI; }
 
-  void clearMaxPressure() { MaxVirtPressure.clear(); }
+  void clearMaxPressure() {
+    MaxVirtPressure.clear();
+    MaxPhysPressure.clear();
+  }
+
+  // Returns sum of virtual and physical register pressure
----------------
arsenm wrote:

Physical registers don't really have pressure? They just subtract from the set available for allocating virtual registers 

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


More information about the llvm-branch-commits mailing list