[llvm] [AArch64][PAC] Eliminate excessive MOVs when computing blend (PR #115185)
Daniil Kovalev via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 25 08:37:21 PST 2024
================
@@ -2036,8 +2068,20 @@ void AArch64AsmPrinter::emitPtrauthBranch(const MachineInstr *MI) {
unsigned AddrDisc = MI->getOperand(3).getReg();
- // Compute discriminator into x17
- unsigned DiscReg = emitPtrauthDiscriminator(Disc, AddrDisc);
+ // Make sure AddrDisc is solely used to compute the discriminator.
+ // While hardly meaningful, it is still possible to describe an authentication
+ // of a pointer against its own value (instead of storage address) with
+ // intrinsics, so use report_fatal_error instead of assert.
+ if (BrTarget == AddrDisc)
+ report_fatal_error("Branch target is signed with its own value");
+
+ // If we are printing BLRA pseudo instruction, then x16 and x17 are
+ // implicit-def'ed by the MI and AddrDisc is not used as any other input, so
+ // try to save one MOV by setting MayUseAddrAsScratch.
+ // Unlike BLRA, BRA pseudo is used to perform computed goto, and thus not
+ // declared as clobbering x16/x17.
+ Register DiscReg = emitPtrauthDiscriminator(Disc, AddrDisc, AArch64::X17,
+ /*MayUseAddrAsScratch=*/IsCall);
----------------
kovdan01 wrote:
Is there a test case for `IsCall` being false (I suppose it corresponds to BRA)?
https://github.com/llvm/llvm-project/pull/115185
More information about the llvm-commits
mailing list