[llvm-branch-commits] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
Daniil Kovalev via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed May 22 01:49:12 PDT 2024
================
@@ -1012,25 +1014,37 @@ bool AArch64CallLowering::isEligibleForTailCallOptimization(
}
static unsigned getCallOpcode(const MachineFunction &CallerF, bool IsIndirect,
- bool IsTailCall) {
+ bool IsTailCall,
+ std::optional<CallLowering::PointerAuthInfo> &PAI,
+ MachineRegisterInfo &MRI) {
const AArch64FunctionInfo *FuncInfo = CallerF.getInfo<AArch64FunctionInfo>();
- if (!IsTailCall)
- return IsIndirect ? getBLRCallOpcode(CallerF) : (unsigned)AArch64::BL;
+ if (!IsTailCall) {
+ if (!PAI)
+ return IsIndirect ? getBLRCallOpcode(CallerF) : (unsigned)AArch64::BL;
+
+ assert(IsIndirect && "authenticated direct call");
+ assert(PAI->Key == 0 || PAI->Key == 1 && "invalid ptrauth key");
+ return AArch64::BLRA;
+ }
if (!IsIndirect)
return AArch64::TCRETURNdi;
- // When BTI or PAuthLR are enabled, there are restrictions on using x16 and
- // x17 to hold the function pointer.
+ // When BTI is enabled, we need to use TCRETURNriBTI to make sure that we use
+ // x16 or x17.
if (FuncInfo->branchTargetEnforcement()) {
- if (FuncInfo->branchProtectionPAuthLR())
+ if (PAI)
+ return AArch64::AUTH_TCRETURN_BTI;
+ else if (FuncInfo->branchProtectionPAuthLR())
----------------
kovdan01 wrote:
Do not use else after return https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return
https://github.com/llvm/llvm-project/pull/85736
More information about the llvm-branch-commits
mailing list