[llvm] [AArch64] Cache AArch64RegisterInfo::isAnyArgRegReserved (PR #190957)
Cullen Rhodes via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 06:18:15 PDT 2026
================
@@ -577,9 +577,18 @@ bool AArch64RegisterInfo::isStrictlyReservedReg(const MachineFunction &MF,
}
bool AArch64RegisterInfo::isAnyArgRegReserved(const MachineFunction &MF) const {
- return llvm::any_of(*AArch64::GPR64argRegClass.MC, [this, &MF](MCPhysReg r) {
- return isStrictlyReservedReg(MF, r);
- });
+ auto *AFI = MF.getInfo<AArch64FunctionInfo>();
+ if (std::optional<bool> Cached = AFI->getAnyArgRegReserved())
+ return *Cached;
+
+ bool Any =
+ llvm::any_of(*AArch64::GPR64argRegClass.MC, [this, &MF](MCPhysReg r) {
+ return isStrictlyReservedReg(MF, r);
+ });
+ // Re-computing this in getStrictlyReservedRegs during call lowering for
+ // every call is compile-time expensive, so we avoid by caching the result.
+ AFI->setAnyArgRegReserved(Any);
+ return Any;
----------------
c-rhodes wrote:
you're right it's even quicker with your suggestion:
```
; before
(venv) ➜ llvm-test-suite python compare.py build-compiletime-O0-g-baseline-4d84263b341c/ build-compiletime-O0-g-change-4d84263b341c
instructions:u diff
old new
7zip 140022021530 139850327981 -0.12%
Bullet 65172328835 64954915055 -0.33%
ClamAV 15886698906 15793020981 -0.59%
SPASS 15695354968 15465953482 -1.46%
consumer-typeset 14355883636 14304383550 -0.36%
kimwitu++ 24541806601 24387733012 -0.63%
lencod 14626735118 14580929747 -0.31%
mafft 7866559349 7832468344 -0.43%
sqlite3 5634773669 5580341706 -0.97%
tramp3d-v4 22007582844 21796957376 -0.96%
geomean 20222655758 20097861695 -0.62%
; after
(venv) ➜ llvm-test-suite python compare.py build-compiletime-O0-g-baseline-4d84263b341c build-compiletime-O0-g-change-4d84263b341c
instructions:u diff
old new
7zip 140022021530 139799061361 -0.16%
Bullet 65172328835 64910868166 -0.4%
ClamAV 15886698906 15790883733 -0.6%
SPASS 15695354968 15433651331 -1.67%
consumer-typeset 14355883636 14300038446 -0.39%
kimwitu++ 24541806601 24327598025 -0.87%
lencod 14626735118 14573100351 -0.37%
mafft 7866559349 7830498704 -0.46%
sqlite3 5634773669 5570387186 -1.14%
tramp3d-v4 22007582844 21750044121 -1.17%
geomean 20222655758 20076223104 -0.72%
```
https://github.com/llvm/llvm-project/pull/190957
More information about the llvm-commits
mailing list