Skip to content

Commit 118e2fb

Browse files
committed
[PAC][CodeGen] Use emitPtrauthCheckAuthenticatedValue in LowerMOVaddrPAC
1 parent a168264 commit 118e2fb

File tree

1 file changed

+3
-34
lines changed

1 file changed

+3
-34
lines changed

llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,41 +2193,10 @@ void AArch64AsmPrinter::LowerMOVaddrPAC(const MachineInstr &MI) {
21932193
if (!STI->hasFPAC()) {
21942194
auto AuthKey = (AuthOpcode == AArch64::AUTIA ? AArch64PACKey::IA
21952195
: AArch64PACKey::DA);
2196-
unsigned XPACOpc = getXPACOpcodeForKey(AuthKey);
2197-
MCSymbol *SuccessSym = createTempSymbol("auth_success_");
21982196

2199-
// XPAC has tied src/dst: use x17 as a temporary copy.
2200-
// mov x17, x16
2201-
EmitToStreamer(MCInstBuilder(AArch64::ORRXrs)
2202-
.addReg(AArch64::X17)
2203-
.addReg(AArch64::XZR)
2204-
.addReg(AArch64::X16)
2205-
.addImm(0));
2206-
2207-
// xpaci x17
2208-
EmitToStreamer(
2209-
MCInstBuilder(XPACOpc).addReg(AArch64::X17).addReg(AArch64::X17));
2210-
2211-
// cmp x16, x17
2212-
EmitToStreamer(MCInstBuilder(AArch64::SUBSXrs)
2213-
.addReg(AArch64::XZR)
2214-
.addReg(AArch64::X16)
2215-
.addReg(AArch64::X17)
2216-
.addImm(0));
2217-
2218-
// b.eq Lsuccess
2219-
EmitToStreamer(
2220-
MCInstBuilder(AArch64::Bcc)
2221-
.addImm(AArch64CC::EQ)
2222-
.addExpr(MCSymbolRefExpr::create(SuccessSym, OutContext)));
2223-
2224-
// Trapping sequences do a 'brk'.
2225-
// brk #<0xc470 + aut key>
2226-
EmitToStreamer(MCInstBuilder(AArch64::BRK).addImm(0xc470 | AuthKey));
2227-
2228-
// If the auth check succeeds, we can continue.
2229-
// Lsuccess:
2230-
OutStreamer->emitLabel(SuccessSym);
2197+
emitPtrauthCheckAuthenticatedValue(AArch64::X16, AArch64::X17, AuthKey,
2198+
/*ShouldTrap=*/true,
2199+
/*OnFailure=*/nullptr);
22312200
}
22322201
} else {
22332202
EmitToStreamer(MCInstBuilder(AArch64::LDRXui)

0 commit comments

Comments
 (0)