diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp --- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp @@ -1960,6 +1960,9 @@ if (!MFnI.shouldSignReturnAddress(MF)) return MBB; + if (MF.getSubtarget().hasFPAC()) + return MBB; + auto TI = MBB.getFirstTerminator(); if (TI == MBB.end()) return MBB; diff --git a/llvm/test/CodeGen/AArch64/sign-return-address-tailcall.ll b/llvm/test/CodeGen/AArch64/sign-return-address-tailcall.ll --- a/llvm/test/CodeGen/AArch64/sign-return-address-tailcall.ll +++ b/llvm/test/CodeGen/AArch64/sign-return-address-tailcall.ll @@ -1,13 +1,19 @@ ; RUN: llc -mtriple=aarch64 -asm-verbose=0 < %s | FileCheck -DAUT="hint #29" --check-prefixes=COMMON,LDR %s ; RUN: llc -mtriple=aarch64 -asm-verbose=0 -mattr=v8.3a < %s | FileCheck -DAUT="autiasp" --check-prefixes=COMMON,LDR %s +; RUN: llc -mtriple=aarch64 -asm-verbose=0 -mattr=v8.3a,fpac < %s | FileCheck -DAUT="autiasp" --check-prefixes=COMMON,FPAC %s ; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-check-authenticated-lr-by-load=0 < %s | FileCheck -DAUT="hint #29" -DXPAC="hint #7" --check-prefixes=COMMON,XPAC %s ; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-check-authenticated-lr-by-load=0 -mattr=v8.3a < %s | FileCheck -DAUT="autiasp" -DXPAC="xpaclri" --check-prefixes=COMMON,XPAC %s +; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-check-authenticated-lr-by-load=0 -mattr=v8.3a,fpac < %s | FileCheck -DAUT="autiasp" --check-prefixes=COMMON,FPAC %s define i32 @tailcall_direct() "sign-return-address"="non-leaf" { ; COMMON-LABEL: tailcall_direct: ; COMMON: str x30, [sp, #-16]! ; COMMON: ldr x30, [sp], #16 ; +; FPAC-NEXT: [[AUT]] +; FPAC-NEXT: .cfi_negate_ra_state +; FPAC-NEXT: b callee +; ; LDR-NEXT: [[AUT]] ; LDR-NEXT: .cfi_negate_ra_state ; LDR-NEXT: ldr x16, [x30] @@ -32,6 +38,10 @@ ; COMMON: str x30, [sp, #-16]! ; COMMON: ldr x30, [sp], #16 ; +; FPAC-NEXT: [[AUT]] +; FPAC-NEXT: .cfi_negate_ra_state +; FPAC-NEXT: br x0 +; ; LDR-NEXT: [[AUT]] ; LDR-NEXT: .cfi_negate_ra_state ; LDR-NEXT: ldr x16, [x30] @@ -72,6 +82,10 @@ ; COMMON-NOT: str{{.*}}x30 ; COMMON-NOT: ldr{{.*}}x30 ; +; FPAC: [[AUT]] +; FPAC-NEXT: .cfi_negate_ra_state +; FPAC-NEXT: b callee +; ; LDR: [[AUT]] ; LDR-NEXT: .cfi_negate_ra_state ; LDR-NEXT: ldr x16, [x30] @@ -95,6 +109,10 @@ ; COMMON-NOT: str{{.*}}x30 ; COMMON-NOT: ldr{{.*}}x30 ; +; FPAC: [[AUT]] +; FPAC-NEXT: .cfi_negate_ra_state +; FPAC-NEXT: br x0 +; ; LDR: [[AUT]] ; LDR-NEXT: .cfi_negate_ra_state ; LDR-NEXT: ldr x16, [x30]