[llvm-branch-commits] [llvm] [AArch64][PAC] Emit tail calls more efficiently (PR #220193)
Victor Campos via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Sep 3 09:00:33 PDT 2026
================
@@ -11800,6 +11796,16 @@ void AArch64InstrInfo::createPauthEpilogueInstr(MachineBasicBlock &MBB,
RS.enterBasicBlockEnd(MBB);
RS.backward(InsertPt);
+ bool MayCheckLR = Subtarget.getAuthenticatedLRCheckMethod(MF) !=
+ AArch64PAuth::AuthCheckMethod::None;
+ if (ImplicitDefs.empty() && MayCheckLR) {
+ // If we may have to check LR at this point, we need a scratch register -
+ // try to pick a free one among X16 and X17.
+ Register ScratchRegForCheckVA =
+ LiveRegs.available(MRI, AArch64::X16) ? AArch64::X16 : AArch64::X17;
+ ImplicitDefs.push_back(ScratchRegForCheckVA);
+ }
----------------
vhscampos wrote:
This is really brittle because both registers might be unavailable at this point. An available register should be chosen using `RegScavenger`.
Besides, I am not sure if this is the right place to find and commit to a scratch register. In my PACMAN PR, a scratch register is chosen in `AArch64PointerAuth.cpp`. I really don't know which one is better than the other, but we must carefully think about this.
I am generally in favour of keeping `CreatePauthEpilogueInstr` as simple as possible, and perform register spilling and scratch register picking in `AArch64PointerAuth.cpp`.
https://github.com/llvm/llvm-project/pull/220193
More information about the llvm-branch-commits
mailing list