aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachinePipeliner.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@sifive.com>2024-09-18 21:34:05 -0700
committerGitHub <noreply@github.com>2024-09-18 21:34:05 -0700
commit80f6b42a26ec7594e6b016c5dde5d57db6c9dfb1 (patch)
treec44da06aa58862237559c1e6ccabd24d151b34ad /llvm/lib/CodeGen/MachinePipeliner.cpp
parent12d94850cd183cadf37f1f278e5795e84a95e894 (diff)
downloadllvm-80f6b42a26ec7594e6b016c5dde5d57db6c9dfb1.zip
llvm-80f6b42a26ec7594e6b016c5dde5d57db6c9dfb1.tar.gz
llvm-80f6b42a26ec7594e6b016c5dde5d57db6c9dfb1.tar.bz2
[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.
Diffstat (limited to 'llvm/lib/CodeGen/MachinePipeliner.cpp')
-rw-r--r--llvm/lib/CodeGen/MachinePipeliner.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp
index 34eaf21..cd83339 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -1344,9 +1344,11 @@ private:
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 @@ private:
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");
+ }
}
}
}