[llvm] 80f6b42 - [MachinePipeliner] Fix incorrect use of getPressureSets. (#109179)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 21:34:09 PDT 2024
Author: Craig Topper
Date: 2024-09-18T21:34:05-07:00
New Revision: 80f6b42a26ec7594e6b016c5dde5d57db6c9dfb1
URL: https://github.com/llvm/llvm-project/commit/80f6b42a26ec7594e6b016c5dde5d57db6c9dfb1
DIFF: https://github.com/llvm/llvm-project/commit/80f6b42a26ec7594e6b016c5dde5d57db6c9dfb1.diff
LOG: [MachinePipeliner] Fix incorrect use of getPressureSets. (#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.
Added:
Modified:
llvm/lib/CodeGen/MachinePipeliner.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp
index 34eaf211c17a30..cd8333931bb5f9 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -1344,9 +1344,11 @@ class HighRegisterPressureDetector {
LLVM_DEBUG({
for (auto Reg : FixedRegs) {
dbgs() << printReg(Reg, TRI, 0, &MRI) << ": [";
- const int *Sets = TRI->getRegUnitPressureSets(Reg);
- for (; *Sets != -1; Sets++) {
- dbgs() << TRI->getRegPressureSetName(*Sets) << ", ";
+ for (MCRegUnit Unit : TRI->regunits(Reg)) {
+ const int *Sets = TRI->getRegUnitPressureSets(Unit);
+ for (; *Sets != -1; Sets++) {
+ dbgs() << TRI->getRegPressureSetName(*Sets) << ", ";
+ }
}
dbgs() << "]\n";
}
@@ -1355,15 +1357,18 @@ class HighRegisterPressureDetector {
for (auto Reg : FixedRegs) {
LLVM_DEBUG(dbgs() << "fixed register: " << printReg(Reg, TRI, 0, &MRI)
<< "\n");
- auto PSetIter = MRI.getPressureSets(Reg);
- unsigned Weight = PSetIter.getWeight();
- for (; PSetIter.isValid(); ++PSetIter) {
- unsigned &Limit = PressureSetLimit[*PSetIter];
- assert(Limit >= Weight &&
- "register pressure limit must be greater than or equal weight");
- Limit -= Weight;
- LLVM_DEBUG(dbgs() << "PSet=" << *PSetIter << " Limit=" << Limit
- << " (decreased by " << Weight << ")\n");
+ for (MCRegUnit Unit : TRI->regunits(Reg)) {
+ auto PSetIter = MRI.getPressureSets(Unit);
+ unsigned Weight = PSetIter.getWeight();
+ for (; PSetIter.isValid(); ++PSetIter) {
+ unsigned &Limit = PressureSetLimit[*PSetIter];
+ assert(
+ Limit >= Weight &&
+ "register pressure limit must be greater than or equal weight");
+ Limit -= Weight;
+ LLVM_DEBUG(dbgs() << "PSet=" << *PSetIter << " Limit=" << Limit
+ << " (decreased by " << Weight << ")\n");
+ }
}
}
}
More information about the llvm-commits
mailing list