Skip to content

Commit 80f6b42

Browse files
authored
[MachinePipeliner] Fix incorrect use of getPressureSets. (llvm#109179)
The code was passing a physical register directly to getPressureSets which expects a register unit. Fix this by looping over the register units and calling getPressureSets for each of them. Found while trying to add a RegisterUnit class to stop storing register units in `Register`. 0 is a valid register unit but not a valid Register.
1 parent 12d9485 commit 80f6b42

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

llvm/lib/CodeGen/MachinePipeliner.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,9 +1344,11 @@ class HighRegisterPressureDetector {
13441344
LLVM_DEBUG({
13451345
for (auto Reg : FixedRegs) {
13461346
dbgs() << printReg(Reg, TRI, 0, &MRI) << ": [";
1347-
const int *Sets = TRI->getRegUnitPressureSets(Reg);
1348-
for (; *Sets != -1; Sets++) {
1349-
dbgs() << TRI->getRegPressureSetName(*Sets) << ", ";
1347+
for (MCRegUnit Unit : TRI->regunits(Reg)) {
1348+
const int *Sets = TRI->getRegUnitPressureSets(Unit);
1349+
for (; *Sets != -1; Sets++) {
1350+
dbgs() << TRI->getRegPressureSetName(*Sets) << ", ";
1351+
}
13501352
}
13511353
dbgs() << "]\n";
13521354
}
@@ -1355,15 +1357,18 @@ class HighRegisterPressureDetector {
13551357
for (auto Reg : FixedRegs) {
13561358
LLVM_DEBUG(dbgs() << "fixed register: " << printReg(Reg, TRI, 0, &MRI)
13571359
<< "\n");
1358-
auto PSetIter = MRI.getPressureSets(Reg);
1359-
unsigned Weight = PSetIter.getWeight();
1360-
for (; PSetIter.isValid(); ++PSetIter) {
1361-
unsigned &Limit = PressureSetLimit[*PSetIter];
1362-
assert(Limit >= Weight &&
1363-
"register pressure limit must be greater than or equal weight");
1364-
Limit -= Weight;
1365-
LLVM_DEBUG(dbgs() << "PSet=" << *PSetIter << " Limit=" << Limit
1366-
<< " (decreased by " << Weight << ")\n");
1360+
for (MCRegUnit Unit : TRI->regunits(Reg)) {
1361+
auto PSetIter = MRI.getPressureSets(Unit);
1362+
unsigned Weight = PSetIter.getWeight();
1363+
for (; PSetIter.isValid(); ++PSetIter) {
1364+
unsigned &Limit = PressureSetLimit[*PSetIter];
1365+
assert(
1366+
Limit >= Weight &&
1367+
"register pressure limit must be greater than or equal weight");
1368+
Limit -= Weight;
1369+
LLVM_DEBUG(dbgs() << "PSet=" << *PSetIter << " Limit=" << Limit
1370+
<< " (decreased by " << Weight << ")\n");
1371+
}
13671372
}
13681373
}
13691374
}

0 commit comments

Comments
 (0)