[llvm] [AArch64] Cache AArch64RegisterInfo::isAnyArgRegReserved (PR #190957)

Cullen Rhodes via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 8 05:59:13 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:

ah interesting, I didn't actually look where this came from but couldn't think of anything other than `+reserve-x{0-7}` which could reserve these arg registers. Will try your suggestion

https://github.com/llvm/llvm-project/pull/190957


More information about the llvm-commits mailing list