================
@@ -1095,41 +1096,42 @@ LLVM_DUMP_METHOD void
llvm::dumpMaxRegPressure(MachineFunction &MF,
auto &OS = dbgs();
const char *RegName = GCNRegPressure::getName(Kind);
+ // Count only the registers of Kind, from the live sets. The maximum of a
+ // pressure tracker pairs the VGPR and AVGPR components, so its VGPR
component
+ // alone can miss the VGPR peak. Max pressure can occur at either the
+ // early-clobber or register slot. This is slow but this is diagnostic code.
unsigned MaxNumRegs = 0;
const MachineInstr *MaxPressureMI = nullptr;
- GCNUpwardRPTracker RPT(LIS);
+ SlotIndex MaxPressureSlot;
+ GCNRPTracker::LiveRegSet LiveSet;
for (const MachineBasicBlock &MBB : MF) {
- RPT.reset(MRI, LIS.getSlotIndexes()->getMBBEndIdx(&MBB).getPrevSlot());
for (const MachineInstr &MI : reverse(MBB)) {
- RPT.recede(MI);
- unsigned NumRegs = RPT.getMaxPressure().getNumRegs(Kind);
- if (NumRegs > MaxNumRegs) {
- MaxNumRegs = NumRegs;
- MaxPressureMI = &MI;
+ if (MI.isDebugInstr())
+ continue;
+ SlotIndex MISlot = LIS.getInstructionIndex(MI);
+ for (SlotIndex SI : {MISlot.getRegSlot(false), MISlot.getRegSlot(true)})
{
+ GCNRPTracker::LiveRegSet SILiveSet = getLiveRegs(SI, LIS, MRI, Kind);
+ unsigned NumRegs = getRegPressure(MRI, SILiveSet).getNumRegs(Kind);
+ if (NumRegs > MaxNumRegs) {
+ MaxNumRegs = NumRegs;
+ MaxPressureMI = &MI;
+ MaxPressureSlot = SI;
+ LiveSet = std::move(SILiveSet);
----------------
vpykhtin wrote:
One of the purpose of this dump function was the demonstration of how RP
trackers work. You... khm... ruined it :) let alone how horribly inefficient
this is. I cannot come up with a nice solution at the moment - basically we
might want to customize calculation over register numbers at each point where
the pressure changes.
https://github.com/llvm/llvm-project/pull/236175
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits