[AArch64][PtrAuth] Fix unwind state for tail calls
authorOliver Stannard <oliver.stannard@arm.com>
Thu, 27 Jul 2023 13:36:14 +0000 (14:36 +0100)
committerTobias Hieta <tobias@hieta.se>
Fri, 11 Aug 2023 07:00:15 +0000 (09:00 +0200)
commit56f8c059f4d0104cfee27c5994f95861d0d7f2bf
treefb081426a29722bb5a11e2dbfaaa41ad3a10dba8
parent506f5b47a2fcd1b871b39702ee9ecbe50a798cb3
[AArch64][PtrAuth] Fix unwind state for tail calls

When generating unwind tables for code which uses return-address
signing, we need to toggle the RA_SIGN_STATE DWARF register around any
tail-calls, because these require the return address to be authenticated
before the call, and could throw an exception. This is done using the
.cfi_negate_ra_state directive before the call, and .cfi_restore_state
at the start of the next basic block.

However, since D153098, the .cfi_restore_state isn't being inserted,
because the CFIFixup pass isn't being run. This re-enables that pass
when return-adress signing is enabled.

Reviewed By: ikudrin, MaskRay

Differential Revision: https://reviews.llvm.org/D156428

(cherry picked from commit f2e7285b03fbfc263c8a2eaa2b5e2e1cfafc6abd)
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-regsave.mir
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-thunk.ll
llvm/test/CodeGen/AArch64/sign-return-address-cfi-negate-ra-state.ll
llvm/test/CodeGen/AArch64/sign-return-address.ll