[llvm] [AArch64] Avoid getMinimalPhysRegClass in callee-save frame lowering (PR #193438)

Cullen Rhodes via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 23:21:18 PDT 2026


================
@@ -2623,8 +2640,7 @@ void AArch64FrameLowering::determineCalleeSaves(MachineFunction &MF,
   unsigned PPRCSStackSize = 0;
   const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
   for (unsigned Reg : SavedRegs.set_bits()) {
-    auto *RC = TRI->getMinimalPhysRegClass(MCRegister(Reg));
-    assert(RC && "expected register class!");
+    auto *RC = getAArch64CalleeSavedRegClass(MCRegister(Reg));
----------------
c-rhodes wrote:

I don't think the most minimal RC is necessary for the code in frame lowering since it just uses the RC for spill size and alignment. I did find an existing API `getPhysRegBaseClass`:
https://llvm.org/doxygen/classllvm_1_1TargetRegisterInfo.html#a228e5f06e0b1125c0b58d52bbe9afa46

that seems close to what we want here but it's only implemented for AMDGPU, but it does seem it was added due to existing APIs being slow (https://github.com/llvm/llvm-project/commit/5bc703f755579c0a0e38d8e77146e8e3dd8a955d https://github.com/llvm/llvm-project/commit/d393d0d24239aedfd3c8166e7dc188f360104cac).

it's generated by tablegen and register classes that have BaseClassOrder set are supported:
https://github.com/llvm/llvm-project/blob/f5bb397d204dbe14eea2b7e20337accc1a375c6f/llvm/include/llvm/Target/Target.td#L396-L400

I've implemented it and the compile-time improvement matches the original change:
http://llvm-compile-time-tracker.com/compare.php?from=4e6d3722fca73c97367720180a8d547057fda380&to=2038fc376d322e7c10dd908d823c95db211098dc&stat=instructions%3Au

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


More information about the llvm-commits mailing list