================
@@ -320,12 +325,72 @@ class GCNRPTracker {
protected:
const LiveIntervals &LIS;
+
LiveRegSet VirtLiveRegs;
+
+ // Physical register liveness: Units provides O(1) unit-level alias checks,
+ // Regs tracks which register names contributed to pressure for cheap
+ // reconstruction. Both must be kept in sync.
+ struct PhysicalRegLiveness {
+ LiveRegUnits Units;
+ SmallDenseSet<MCRegister, 16> Regs;
+
+ void init(const TargetRegisterInfo &TRI) {
+ Units.init(TRI);
+ Regs.clear();
+ }
+ void clear() {
+ Units.clear();
+ Regs.clear();
+ }
+ const BitVector &getBitVector() const { return Units.getBitVector(); }
+
+ void add(Register Reg) {
+ Units.addReg(Reg);
+ Regs.insert(Reg.asMCReg());
+ }
+ void remove(Register Reg) {
+ Units.removeReg(Reg);
+ Regs.erase(Reg.asMCReg());
+ }
+ void remove(const BitVector &KilledUnits, MCRegister Reg) {
+ Units.removeUnits(KilledUnits);
+ Regs.erase(Reg);
+ }
+ };
+ PhysicalRegLiveness PhysLiveRegs;
+
GCNRegPressure CurPressure, MaxPressure;
+
+ // Flag to control whether physical register tracking is active.
+ // Set to true when GCNTrackers are enabled, false otherwise.
+ bool TrackPhysRegs = false;
+
const MachineInstr *LastTrackedMI = nullptr;
mutable const MachineRegisterInfo *MRI = nullptr;
+ const SIRegisterInfo *SRI = nullptr;
+
+ GCNRPTracker(const LiveIntervals &LIS, const MachineRegisterInfo &MRI)
+ : LIS(LIS), MRI(&MRI),
+ SRI(static_cast<const SIRegisterInfo *>(MRI.getTargetRegisterInfo())) {
+ setPhysRegTracking();
+ if (TrackPhysRegs)
+ PhysLiveRegs.init(*SRI);
+ }
- GCNRPTracker(const LiveIntervals &LIS_) : LIS(LIS_) {}
+ // Copy constructor - PhysLiveRegs.Units must be initialized then copied.
+ GCNRPTracker(const GCNRPTracker &Other)
+ : LIS(Other.LIS), VirtLiveRegs(Other.VirtLiveRegs),
+ CurPressure(Other.CurPressure), MaxPressure(Other.MaxPressure),
+ TrackPhysRegs(Other.TrackPhysRegs), LastTrackedMI(Other.LastTrackedMI),
+ MRI(Other.MRI), SRI(Other.SRI) {
+ if (TrackPhysRegs) {
+ assert(SRI && "SRI not initialized");
+ PhysLiveRegs.init(*SRI);
+ PhysLiveRegs.Units.addUnits(Other.PhysLiveRegs.getBitVector());
+ PhysLiveRegs.Regs = Other.PhysLiveRegs.Regs;
+ }
+ }
----------------
macurtis-amd wrote:
I think the default copy constructor would actually achieve the same result.
https://github.com/llvm/llvm-project/pull/184275
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits