================
@@ -11800,6 +11796,16 @@ void 
AArch64InstrInfo::createPauthEpilogueInstr(MachineBasicBlock &MBB,
   RS.enterBasicBlockEnd(MBB);
   RS.backward(InsertPt);
 
+  bool MayCheckLR = Subtarget.getAuthenticatedLRCheckMethod(MF) !=
+                    AArch64PAuth::AuthCheckMethod::None;
+  if (ImplicitDefs.empty() && MayCheckLR) {
+    // If we may have to check LR at this point, we need a scratch register -
+    // try to pick a free one among X16 and X17.
+    Register ScratchRegForCheckVA =
+        LiveRegs.available(MRI, AArch64::X16) ? AArch64::X16 : AArch64::X17;
+    ImplicitDefs.push_back(ScratchRegForCheckVA);
+  }
----------------
vhscampos wrote:

This is really brittle because both registers might be unavailable at this 
point. An available register should be chosen using `RegScavenger`.

Besides, I am not sure if this is the right place to find and commit to a 
scratch register. In my PACMAN PR, a scratch register is chosen in 
`AArch64PointerAuth.cpp`. I really don't know which one is better than the 
other, but we must carefully think about this.

I am generally in favour of keeping `CreatePauthEpilogueInstr` as simple as 
possible, and perform register spilling and scratch register picking in 
`AArch64PointerAuth.cpp`.

https://github.com/llvm/llvm-project/pull/220193
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to