[all-commits] [llvm/llvm-project] 181d80: [AArch64][PAuth] Fix return-address auth for swift...

Jon Roelofs via All-commits all-commits at lists.llvm.org
Fri Jun 12 14:07:22 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 181d8084770935e4e3cd1877d317e95b73fe8368
      https://github.com/llvm/llvm-project/commit/181d8084770935e4e3cd1877d317e95b73fe8368
  Author: Jon Roelofs <jonathan_roelofs at apple.com>
  Date:   2026-06-12 (Fri, 12 Jun 2026)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
    M llvm/test/CodeGen/AArch64/arm64e-tail-call-autib.ll
    M llvm/test/CodeGen/AArch64/pauth-lr-tail-call-fpdiff.ll
    A llvm/test/CodeGen/AArch64/swifttail-ptrauth.ll

  Log Message:
  -----------
  [AArch64][PAuth] Fix return-address auth for swifttailcc with FPDiff > 0 (#203340)

When a swifttailcc tail call has FPDiff > 0 (the caller received more
stack argument space than the callee pops), the epilogue contains an SP
adjustment to discard the leftover argument space. The existing code
treated both FPDiff < 0 and FPDiff > 0 uniformly in a single 'FPDiff !=
0' block, using AUTI[AB]1716 with a reconstructed entry-SP in x16 for
both cases.

For FPDiff < 0 (callee pops more) that reconstruction is necessary and
correct. For FPDiff > 0 it is wrong: by the time we enter the block the
post-index LDP has already adjusted SP back to the frame base, but the
'add sp, sp, #N' argument pop has not yet run. Entry SP equals the
current SP at that point, so AUTI[AB]SP would work directly, but instead
the combined block bumped SP via StackOffset::getFixed(-FPDiff) which
overshoots, and then emits AUTIA1716 with a wrong discriminator. Worse
yet, the SP restore had already been emitted *before* the auth, leaving
the live argument stack below SP and outside the red-zone during the
authentication window.

Fix by splitting the block on the sign of ArgumentStackToRestore:

* `< 0`: reconstruct entry SP in x16, save LR in x17, authenticate with
AUTI[AB]1716 (or AUTI[AB]171615 / PACM+AUTI[AB]1716 for PAuthLR).

* `> 0`: temporarily remove the 'add sp, sp, #N' SP-modifying
instructions from before the auth instruction (SPMods shuffle),
authenticate with AUTI[AB]SP (SP == entry SP at this point), then
re-insert the SP adjustment afterward.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list