Skip to content

[CodeGen] Use cached version of getRegPressureSetLimit #119194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion llvm/lib/CodeGen/MachineLICM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ namespace {
const TargetRegisterInfo *TRI = nullptr;
const MachineFrameInfo *MFI = nullptr;
MachineRegisterInfo *MRI = nullptr;
RegisterClassInfo RegClassInfo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way RegisterClassInfo is currently used, it gets recomputed for every pass that uses it. It should probably move to be a normal analysis

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking this, especially as it has some saved state to work out when it needs to recompute. I think that's probably a good follow-up?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relatedly, we also do not serialize the set of reserved registers in MIR

TargetSchedModel SchedModel;
bool PreRegAlloc = false;
bool HasProfileData = false;
Expand Down Expand Up @@ -389,6 +390,7 @@ bool MachineLICMImpl::run(MachineFunction &MF) {
MFI = &MF.getFrameInfo();
MRI = &MF.getRegInfo();
SchedModel.init(&ST);
RegClassInfo.runOnMachineFunction(MF);

HasProfileData = MF.getFunction().hasProfileData();

Expand All @@ -405,7 +407,7 @@ bool MachineLICMImpl::run(MachineFunction &MF) {
std::fill(RegPressure.begin(), RegPressure.end(), 0);
RegLimit.resize(NumRPS);
for (unsigned i = 0, e = NumRPS; i != e; ++i)
RegLimit[i] = TRI->getRegPressureSetLimit(MF, i);
RegLimit[i] = RegClassInfo.getRegPressureSetLimit(i);
}

if (HoistConstLoads)
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachinePipeliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ class HighRegisterPressureDetector {
// Calculate the upper limit of each pressure set
void computePressureSetLimit(const RegisterClassInfo &RCI) {
for (unsigned PSet = 0; PSet < PSetNum; PSet++)
PressureSetLimit[PSet] = TRI->getRegPressureSetLimit(MF, PSet);
PressureSetLimit[PSet] = RCI.getRegPressureSetLimit(PSet);
}

// There are two patterns of last-use.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachineSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ bool MachineSinking::registerPressureSetExceedsLimit(
std::vector<unsigned> BBRegisterPressure = getBBRegisterPressure(MBB);
for (; *PS != -1; PS++)
if (Weight + BBRegisterPressure[*PS] >=
TRI->getRegPressureSetLimit(*MBB.getParent(), *PS))
RegClassInfo.getRegPressureSetLimit(*PS))
return true;
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6936,7 +6936,6 @@ bool ARMPipelinerLoopInfo::tooMuchRegisterPressure(SwingSchedulerDAG &SSD,
RegClassInfo.runOnMachineFunction(*MF);
RPTracker.init(MF, &RegClassInfo, nullptr, EndLoop->getParent(),
EndLoop->getParent()->end(), false, false);
const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();

bumpCrossIterationPressure(RPTracker, CrossIterationNeeds);

Expand Down Expand Up @@ -6979,7 +6978,7 @@ bool ARMPipelinerLoopInfo::tooMuchRegisterPressure(SwingSchedulerDAG &SSD,

auto &P = RPTracker.getPressure().MaxSetPressure;
for (unsigned I = 0, E = P.size(); I < E; ++I)
if (P[I] > TRI->getRegPressureSetLimit(*MF, I)) {
if (P[I] > RegClassInfo.getRegPressureSetLimit(I)) {
return true;
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ bool PPCInstrInfo::shouldReduceRegisterPressure(
};

// For now we only care about float and double type fma.
unsigned VSSRCLimit = TRI->getRegPressureSetLimit(
*MBB->getParent(), PPC::RegisterPressureSets::VSSRC);
unsigned VSSRCLimit =
RegClassInfo->getRegPressureSetLimit(PPC::RegisterPressureSets::VSSRC);

// Only reduce register pressure when pressure is high.
return GetMBBPressure(MBB)[PPC::RegisterPressureSets::VSSRC] >
Expand Down
Loading