Skip to content

Commit 1235a93

Browse files
authored
[MachinePipeliner] Use RegisterClassInfo::getRegPressureSetLimit (#119827)
`RegisterClassInfo::getRegPressureSetLimit` is a wrapper of `TargetRegisterInfo::getRegPressureSetLimit` with some logics to adjust the limit by removing reserved registers. It seems that we shouldn't use `TargetRegisterInfo::getRegPressureSetLimit` directly, just like the comment "This limit must be adjusted dynamically for reserved registers" said. Thus we should use `RegisterClassInfo::getRegPressureSetLimit` and remove replicated code. Separate from #118787
1 parent d6e8ab1 commit 1235a93

File tree

1 file changed

+1
-42
lines changed

1 file changed

+1
-42
lines changed

llvm/lib/CodeGen/MachinePipeliner.cpp

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,48 +1326,7 @@ class HighRegisterPressureDetector {
13261326
// Calculate the upper limit of each pressure set
13271327
void computePressureSetLimit(const RegisterClassInfo &RCI) {
13281328
for (unsigned PSet = 0; PSet < PSetNum; PSet++)
1329-
PressureSetLimit[PSet] = TRI->getRegPressureSetLimit(MF, PSet);
1330-
1331-
// We assume fixed registers, such as stack pointer, are already in use.
1332-
// Therefore subtracting the weight of the fixed registers from the limit of
1333-
// each pressure set in advance.
1334-
SmallDenseSet<Register, 8> FixedRegs;
1335-
for (const TargetRegisterClass *TRC : TRI->regclasses()) {
1336-
for (const MCPhysReg Reg : *TRC)
1337-
if (isFixedRegister(Reg))
1338-
FixedRegs.insert(Reg);
1339-
}
1340-
1341-
LLVM_DEBUG({
1342-
for (auto Reg : FixedRegs) {
1343-
dbgs() << printReg(Reg, TRI, 0, &MRI) << ": [";
1344-
for (MCRegUnit Unit : TRI->regunits(Reg)) {
1345-
const int *Sets = TRI->getRegUnitPressureSets(Unit);
1346-
for (; *Sets != -1; Sets++) {
1347-
dbgs() << TRI->getRegPressureSetName(*Sets) << ", ";
1348-
}
1349-
}
1350-
dbgs() << "]\n";
1351-
}
1352-
});
1353-
1354-
for (auto Reg : FixedRegs) {
1355-
LLVM_DEBUG(dbgs() << "fixed register: " << printReg(Reg, TRI, 0, &MRI)
1356-
<< "\n");
1357-
for (MCRegUnit Unit : TRI->regunits(Reg)) {
1358-
auto PSetIter = MRI.getPressureSets(Unit);
1359-
unsigned Weight = PSetIter.getWeight();
1360-
for (; PSetIter.isValid(); ++PSetIter) {
1361-
unsigned &Limit = PressureSetLimit[*PSetIter];
1362-
assert(
1363-
Limit >= Weight &&
1364-
"register pressure limit must be greater than or equal weight");
1365-
Limit -= Weight;
1366-
LLVM_DEBUG(dbgs() << "PSet=" << *PSetIter << " Limit=" << Limit
1367-
<< " (decreased by " << Weight << ")\n");
1368-
}
1369-
}
1370-
}
1329+
PressureSetLimit[PSet] = RCI.getRegPressureSetLimit(PSet);
13711330
}
13721331

13731332
// There are two patterns of last-use.

0 commit comments

Comments
 (0)