Skip to content

Commit a26fd0b

Browse files
authored
[LivePhysReg] Fix off by 1 error in an assert. NFC (llvm#128379)
Reg should not be equal to the number of registers.
1 parent 0963f0d commit a26fd0b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/include/llvm/CodeGen/LivePhysRegs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class LivePhysRegs {
8282
/// Adds a physical register and all its sub-registers to the set.
8383
void addReg(MCPhysReg Reg) {
8484
assert(TRI && "LivePhysRegs is not initialized.");
85-
assert(Reg <= TRI->getNumRegs() && "Expected a physical register.");
85+
assert(Reg < TRI->getNumRegs() && "Expected a physical register.");
8686
for (MCPhysReg SubReg : TRI->subregs_inclusive(Reg))
8787
LiveRegs.insert(SubReg);
8888
}
@@ -91,7 +91,7 @@ class LivePhysRegs {
9191
/// super-registers from the set.
9292
void removeReg(MCPhysReg Reg) {
9393
assert(TRI && "LivePhysRegs is not initialized.");
94-
assert(Reg <= TRI->getNumRegs() && "Expected a physical register.");
94+
assert(Reg < TRI->getNumRegs() && "Expected a physical register.");
9595
for (MCRegAliasIterator R(Reg, TRI, true); R.isValid(); ++R)
9696
LiveRegs.erase((*R).id());
9797
}

0 commit comments

Comments
 (0)