Skip to content

Commit 5f2ab74

Browse files
committed
Minor refinements.
- assert ptrauth calls aren't used with PAuth_LR - more const nits
1 parent 1714447 commit 5f2ab74

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ static MachineInstr *createCallWithOps(MachineBasicBlock &MBB,
791791
// operands of the branch as it expects to be B <target> which is only one
792792
// operand. Instead they are implicit operands used by the branch.
793793
while (!MBBI->getOperand(RegMaskStartIdx).isRegMask()) {
794-
MachineOperand &MOP = MBBI->getOperand(RegMaskStartIdx);
794+
const MachineOperand &MOP = MBBI->getOperand(RegMaskStartIdx);
795795
assert(MOP.isReg() && "can only add register operands");
796796
Call->addOperand(MachineOperand::CreateReg(
797797
MOP.getReg(), /*Def=*/false, /*Implicit=*/true, /*isKill=*/false,
@@ -833,11 +833,11 @@ bool AArch64ExpandPseudo::expandCALL_RVMARKER(
833833
MachineInstr *OriginalCall = nullptr;
834834

835835
if (MI.getOpcode() == AArch64::BLRA_RVMARKER) {
836-
// Pointer auth call.
837-
MachineOperand &CallTarget = MI.getOperand(1);
838-
MachineOperand &Key = MI.getOperand(2);
839-
MachineOperand &IntDisc = MI.getOperand(3);
840-
MachineOperand &AddrDisc = MI.getOperand(4);
836+
// ptrauth call.
837+
const MachineOperand &CallTarget = MI.getOperand(1);
838+
const MachineOperand &Key = MI.getOperand(2);
839+
const MachineOperand &IntDisc = MI.getOperand(3);
840+
const MachineOperand &AddrDisc = MI.getOperand(4);
841841

842842
assert((Key.getImm() == AArch64PACKey::IA ||
843843
Key.getImm() == AArch64PACKey::IB) &&

llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,18 +1032,22 @@ static unsigned getCallOpcode(const MachineFunction &CallerF, bool IsIndirect,
10321032
if (!IsIndirect)
10331033
return AArch64::TCRETURNdi;
10341034

1035-
// When BTI is enabled, we need to use TCRETURNriBTI to make sure that we use
1036-
// x16 or x17.
1035+
// When BTI or PAuthLR are enabled, there are restrictions on using x16 and
1036+
// x17 to hold the function pointer.
10371037
if (FuncInfo->branchTargetEnforcement()) {
1038+
if (FuncInfo->branchProtectionPAuthLR()) {
1039+
assert(!PAI && "ptrauth tail-calls not yet supported with PAuthLR");
1040+
return AArch64::TCRETURNrix17;
1041+
}
10381042
if (PAI)
10391043
return AArch64::AUTH_TCRETURN_BTI;
1040-
if (FuncInfo->branchProtectionPAuthLR())
1041-
return AArch64::TCRETURNrix17;
10421044
return AArch64::TCRETURNrix16x17;
10431045
}
10441046

1045-
if (FuncInfo->branchProtectionPAuthLR())
1047+
if (FuncInfo->branchProtectionPAuthLR()) {
1048+
assert(!PAI && "ptrauth tail-calls not yet supported with PAuthLR");
10461049
return AArch64::TCRETURNrinotx16;
1050+
}
10471051

10481052
if (PAI)
10491053
return AArch64::AUTH_TCRETURN;

0 commit comments

Comments
 (0)