================
@@ -91,15 +133,37 @@ static void decoratePACWithCFI(MachineBasicBlock &MBB,
auto &MF = *MBB.getParent();
auto &MFnI = *MF.getInfo<AArch64FunctionInfo>();
-
CFIInstBuilder CFIBuilder(MBB, MBBI, MachineInstr::FrameSetup);
+ const Triple &TT = MF.getTarget().getTargetTriple();
+
if (MFnI.branchProtectionPAuthLR()) {
- CFIBuilder.buildNegateRAStateWithPC();
- BuildPACMI();
+ switch (CFILLVMSetRASignStateMode) {
+ case SetRAStateMode::Never:
+ CFIBuilder.buildNegateRAStateWithPC();
+ BuildPACMI();
+ break;
+ case SetRAStateMode::PAuthLR:
+ case SetRAStateMode::Always: {
+ BuildPACMI();
+ MCSymbol *PACSym = MFnI.getSigningInstrLabel();
+ assert(PACSym && "No PAC instruction to refer to");
+ CFIBuilder.buildSetRAState(2, PACSym);
+ break;
+ }
+ }
} else {
- BuildPACMI();
- if (!MF.getTarget().getTargetTriple().isOSBinFormatMachO()) {
- CFIBuilder.buildNegateRAState();
+ switch (CFILLVMSetRASignStateMode) {
+ case SetRAStateMode::Never:
+ case SetRAStateMode::PAuthLR:
+ BuildPACMI();
+ if (!TT.isOSBinFormatMachO()) {
+ CFIBuilder.buildNegateRAState();
+ }
+ break;
+ case SetRAStateMode::Always:
+ BuildPACMI();
+ CFIBuilder.buildSetRAState(1, nullptr);
+ break;
----------------
jroelofs wrote:
Given the subtle difference for `.cfi_negate_ra_state_with_pc` vs the rest, I'd
rather not de-duplicate that: it makes it much clearer that one of them _is_
different to have them all at the same depth in the if/switch nest.
https://github.com/llvm/llvm-project/pull/209949
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits