LLVM 24.0.0git
AArch64PointerAuth.cpp
Go to the documentation of this file.
1//===-- AArch64PointerAuth.cpp -- Harden code using PAuth ------------------==//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11#include "AArch64.h"
13#include "AArch64InstrInfo.h"
15#include "AArch64RegisterInfo.h"
16#include "AArch64Subtarget.h"
23#include "llvm/IR/Module.h"
24
25using namespace llvm;
26using namespace llvm::AArch64PAuth;
27
28#define AARCH64_POINTER_AUTH_NAME "AArch64 Pointer Authentication"
29
30namespace {
31
32class AArch64PointerAuthImpl {
33public:
34 bool run(MachineFunction &MF);
35
36private:
37 const AArch64Subtarget *Subtarget = nullptr;
38 const AArch64InstrInfo *TII = nullptr;
39
40 void signLR(MachineFunction &MF, MachineBasicBlock::iterator MBBI) const;
41
42 void authenticateLR(MachineFunction &MF,
44
45 bool emitSignReturnAddressHardening(MachineFunction &MF);
46};
47
48class AArch64PointerAuthLegacy : public MachineFunctionPass {
49public:
50 static char ID;
51
52 AArch64PointerAuthLegacy() : MachineFunctionPass(ID) {}
53
54 bool runOnMachineFunction(MachineFunction &MF) override;
55
56 StringRef getPassName() const override { return AARCH64_POINTER_AUTH_NAME; }
57};
58
59} // end anonymous namespace
60
61INITIALIZE_PASS(AArch64PointerAuthLegacy, "aarch64-ptrauth",
62 AARCH64_POINTER_AUTH_NAME, false, false)
63
65 return new AArch64PointerAuthLegacy();
66}
67
68char AArch64PointerAuthLegacy::ID = 0;
69
84
85// Wrap a given PAC instruction in CFI that describes it.
86//
87// Depending on the type of CFI required, we may need to emit the directive
88// either before or after the instruction, so that unwinders can correctly
89// interpret the location of the signing instruction.
90//
91// As a general rule, CFI opcodes describe the actions needed to recover the
92// register state leading up to a not-yet-retired instruction, with one
93// exception: .cfi_negate_ra_state_with_pc always comes before the paci[ab]sppc,
94// since the unwinder uses the location of the CFI itself to derive the address
95// of the signing instruction [1].
96// 1: https://github.com/llvm/llvm-project/pull/137795#issuecomment-2838779129
97template <typename BuildPACMIFn>
100 BuildPACMIFn BuildPACMI) {
101 if (!EmitCFI) {
102 BuildPACMI();
103 return;
104 }
105
106 auto &MF = *MBB.getParent();
107 auto &MFnI = *MF.getInfo<AArch64FunctionInfo>();
109 const Triple &TT = MF.getFunction().getParent()->getTargetTriple();
110 SetRAStateMode Mode = MF.getSubtarget<AArch64Subtarget>()
111 .getCLOpts()
112 .cfi_llvm_set_ra_sign_state;
113
114 if (MFnI.branchProtectionPAuthLR()) {
115 switch (Mode) {
117 CFIBuilder.buildNegateRAStateWithPC();
118 BuildPACMI();
119 break;
122 BuildPACMI();
123 MCSymbol *PACSym = MFnI.getSigningInstrLabel();
124 assert(PACSym && "No PAC instruction to refer to");
125 CFIBuilder.buildSetRAState(2, PACSym);
126 break;
127 }
128 }
129 } else {
130 switch (Mode) {
133 BuildPACMI();
134 if (!TT.isOSBinFormatMachO()) {
135 CFIBuilder.buildNegateRAState();
136 }
137 break;
139 BuildPACMI();
140 CFIBuilder.buildSetRAState(1, nullptr);
141 break;
142 }
143 }
144}
145
147 bool EmitCFI) {
148 if (!EmitCFI)
149 return;
150
151 auto &MF = *MBB.getParent();
152 auto &MFnI = *MF.getInfo<AArch64FunctionInfo>();
154 const Triple &TT = MF.getFunction().getParent()->getTargetTriple();
155 SetRAStateMode Mode = MF.getSubtarget<AArch64Subtarget>()
156 .getCLOpts()
157 .cfi_llvm_set_ra_sign_state;
158
159 if (MFnI.branchProtectionPAuthLR()) {
160 switch (Mode) {
162 // DW_CFA_AARCH64_negate_ra_state_with_pc is semantically broken for
163 // functions where shrinkwrapping places signing/authenticating pairs on
164 // distinct CFG paths.
165 //
166 // DWARF CFI is evaluated linearly over the byte stream, not along control
167 // flow edges. The toggle semantics of this directive therefore cannot
168 // faithfully represent the signed/unsigned RA state for all possible CFG
169 // paths. The added complexity versus DW_CFA_AARCH64_negate_ra_state is
170 // that an unwinder must also reconstruct the PC of the PACI[AB]SPPC in
171 // order to verify the signed LR, and that address is derived from the
172 // location of this directive in the linear CFI stream.
173 //
174 // The correct fix is to use DW_CFA_AARCH64_set_ra_state_with_pc, which
175 // sets the RA state and signing address absolutely rather than toggling
176 // them. An unwinder that supports this directive can reconstruct the
177 // correct state on any CFG path, regardless of how many
178 // signing/authenticating pairs exist in the function. However, not all
179 // unwinders support this directive, so we cannot rely on it exclusively.
180 //
181 // For unwinders that only support DW_CFA_AARCH64_negate_ra_state_with_pc,
182 // libunwind exploits a loophole: it records the address at the
183 // DW_CFA_AARCH64_negate_ra_state_with_pc site to authenticate the LR, but
184 // does not care that the CFI state remains "signed with pc" after
185 // authentication has occurred. This means we can safely omit the
186 // FrameDestroy emission of this directive, treating it solely as a marker
187 // for the signing site, as long as each function has at most one such
188 // signing location. That invariant holds today because shrinkwrapping
189 // does not yet hoist or sink PAuth_LR frame code across CFG join/split
190 // points; once it does, we must avoid those transformations on platforms
191 // that have this limitation.
192 //
193 // https://github.com/ARM-software/abi-aa/issues/327
194 // https://github.com/ARM-software/abi-aa/pull/346
195 break;
198 CFIBuilder.buildSetRAState(0, nullptr);
199 break;
200 }
201 } else if (!TT.isOSBinFormatMachO()) {
202 switch (Mode) {
205 CFIBuilder.buildNegateRAState();
206 break;
208 CFIBuilder.buildSetRAState(0, nullptr);
209 break;
210 }
211 }
212}
213
216 DebugLoc DL,
217 const AArch64InstrInfo *TII,
218 Register Dst, Register Src) {
219 assert(&MBB == MBBI->getParent());
220 BuildMI(MBB, MBBI, DL, TII->get(AArch64::ORRXrs), Dst)
221 .addReg(AArch64::XZR)
222 .addReg(Src)
223 .addImm(0)
225}
226
227void AArch64PointerAuthImpl::signLR(MachineFunction &MF,
229 auto &MFnI = *MF.getInfo<AArch64FunctionInfo>();
230 bool UseBKey = MFnI.shouldSignWithBKey();
231 bool EmitCFI = MFnI.needsDwarfUnwindInfo(MF);
232 bool NeedsWinCFI = MF.hasWinCFI();
233
234 MachineBasicBlock &MBB = *MBBI->getParent();
235
236 // Debug location must be unknown, see AArch64FrameLowering::emitPrologue.
237 DebugLoc DL;
238
239 if (UseBKey && !MF.getTarget().getTargetTriple().isOSBinFormatMachO()) {
240 BuildMI(MBB, MBBI, DL, TII->get(AArch64::EMITBKEY))
242 }
243
244 // PAuthLR authentication instructions need to know the value of PC at the
245 // point of signing (PACI*).
246 if (MFnI.branchProtectionPAuthLR()) {
247 MCSymbol *PACSym = MF.getContext().createTempSymbol();
248 MFnI.setSigningInstrLabel(PACSym);
249 }
250
251 // No SEH opcode for this one; it doesn't materialize into an
252 // instruction on Windows.
253 if (MFnI.branchProtectionPAuthLR() && Subtarget->hasPAuthLR()) {
254 decoratePACWithCFI(MBB, MBBI, EmitCFI, [&]() {
255 BuildMI(MBB, MBBI, DL,
256 TII->get(UseBKey ? AArch64::PACIBSPPC : AArch64::PACIASPPC))
258 ->setPreInstrSymbol(MF, MFnI.getSigningInstrLabel());
259 });
260 } else {
261 if (MFnI.branchProtectionPAuthLR()) {
262 BuildMI(MBB, MBBI, DL, TII->get(AArch64::PACM))
264 }
265 decoratePACWithCFI(MBB, MBBI, EmitCFI, [&]() {
266 BuildMI(MBB, MBBI, DL,
267 TII->get(UseBKey ? AArch64::PACIBSP : AArch64::PACIASP))
269 ->setPreInstrSymbol(MF, MFnI.getSigningInstrLabel());
270 });
271 }
272
273 if (!EmitCFI && NeedsWinCFI) {
274 assert(UseBKey &&
275 "Windows SEH PAC unwind info only supports B-key signing");
276 BuildMI(MBB, MBBI, DL, TII->get(AArch64::SEH_PACSignLR))
278 }
279}
280
281void AArch64PointerAuthImpl::authenticateLR(
283 const AArch64FunctionInfo *MFnI = MF.getInfo<AArch64FunctionInfo>();
284 bool UseBKey = MFnI->shouldSignWithBKey();
285 bool EmitAsyncCFI = MFnI->needsAsyncDwarfUnwindInfo(MF);
286 bool NeedsWinCFI = MF.hasWinCFI();
287
288 MachineBasicBlock &MBB = *MBBI->getParent();
289 DebugLoc DL = MBBI->getDebugLoc();
290 // MBBI points to a PAUTH_EPILOGUE instruction to be replaced and
291 // TI points to a terminator instruction that may or may not be combined.
292 // Note that inserting new instructions "before MBBI" and "before TI" is
293 // not the same because if ShadowCallStack is enabled, its instructions
294 // are placed between MBBI and TI.
296
297 MCSymbol *PACSym = MFnI->getSigningInstrLabel();
298 auto &AFL = *static_cast<const AArch64FrameLowering *>(
299 MF.getSubtarget().getFrameLowering());
300 int64_t ArgumentStackToRestore = AFL.getArgumentStackToRestore(MF, MBB);
301
302 // The AUTIASP instruction assembles to a hint instruction before v8.3a so
303 // this instruction can safely be used for any v8a architecture.
304 // From v8.3a onwards there are optimised authenticate LR and return
305 // instructions, namely RETA{A,B}, that can be used instead. In this case
306 // the DW_CFA_AARCH64_negate_ra_state can't be emitted. Additionally,
307 // RET{A,B} requires the SP to match its incoming value on entry to the
308 // function.
309 //
310 // If the PAC-RET hardening based on load from the return address is
311 // enabled, fallback to the use of AUTIASP/AUTIBSP and RET.
312 bool TerminatorIsCombinable = std::next(MBBI) == TI && TI != MBB.end() &&
313 TI->getOpcode() == AArch64::RET &&
314 ArgumentStackToRestore == 0 &&
316
317 if (Subtarget->hasPAuth() && TerminatorIsCombinable && !NeedsWinCFI &&
318 !MF.getFunction().hasFnAttribute(Attribute::ShadowCallStack)) {
319 if (MFnI->branchProtectionPAuthLR() && Subtarget->hasPAuthLR()) {
320 assert(PACSym && "No PAC instruction to refer to");
321 BuildMI(MBB, TI, DL,
322 TII->get(UseBKey ? AArch64::RETABSPPCi : AArch64::RETAASPPCi))
323 .addSym(PACSym)
326 } else {
327 if (MFnI->branchProtectionPAuthLR()) {
329 AArch64::X16);
330 BuildMI(MBB, MBBI, DL, TII->get(AArch64::PACM))
332 }
333 BuildMI(MBB, TI, DL, TII->get(UseBKey ? AArch64::RETAB : AArch64::RETAA))
336 }
337 MBB.erase(TI);
338 return;
339 }
340
341 // If PAUTH_EPILOGUE is at insertion point with a net zero offset on SP, we
342 // can use an AUT form with a hardcoded SP discriminator.
343 if (ArgumentStackToRestore == 0) {
344 if (MFnI->branchProtectionPAuthLR() && Subtarget->hasPAuthLR()) {
345 assert(PACSym && "No PAC instruction to refer to");
346 BuildMI(MBB, MBBI, DL,
347 TII->get(UseBKey ? AArch64::AUTIBSPPCi : AArch64::AUTIASPPCi))
348 .addSym(PACSym)
350 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
351 } else {
352 if (MFnI->branchProtectionPAuthLR()) {
354 AArch64::X16);
355
356 BuildMI(MBB, MBBI, DL, TII->get(AArch64::PACM))
358 }
359 BuildMI(MBB, MBBI, DL,
360 TII->get(UseBKey ? AArch64::AUTIBSP : AArch64::AUTIASP))
362 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
363 }
364
365 if (NeedsWinCFI) {
366 assert(UseBKey &&
367 "Windows SEH PAC unwind info only supports B-key signing");
368 BuildMI(MBB, MBBI, DL, TII->get(AArch64::SEH_PACSignLR))
370 }
371
372 return;
373 }
374
375 // When ArgumentStackToRestore > 0, this function received more argument
376 // space than the tail callee pops. The epilogue contains an SP adjustment
377 // (e.g. "add sp, sp, #N") to discard the leftover argument space.
378 //
379 // When ArgumentStackToRestore < 0, the tail callee pops more argument space
380 // than this function received, so after the frame teardown, SP is below the
381 // entry SP used as the signing modifier.
382 //
383 // We cannot simply bump SP first and then use AUTI[AB]SP with the bumped
384 // value, because the live arguments would fall below SP and potentially
385 // outside the red-zone.
386 //
387 // At this point there is an offset to the incoming SP, and we can't use the
388 // aut variants that hard-code SP. Reconstruct entry SP in x16 and
389 // authenticate using AUTI[AB]1716 (x17=LR, x16=entry_SP).
390 emitFrameOffset(MBB, MBBI, DL, AArch64::X16, AArch64::SP,
391 StackOffset::getFixed(-ArgumentStackToRestore), TII,
393
394 if (MFnI->branchProtectionPAuthLR() && Subtarget->hasPAuthLR()) {
395 emitMOVWithFrameDestroy(MBB, MBBI, DL, TII, AArch64::X17, AArch64::LR);
396
397 assert(PACSym && "No PAC instruction to refer to");
398 emitEpiloguePACSymOffsetIntoReg(*TII, MBB, MBBI, DL, PACSym, AArch64::X15);
399
400 unsigned AutOpc = UseBKey ? AArch64::AUTIB171615 : AArch64::AUTIA171615;
401 BuildMI(MBB, MBBI, DL, TII->get(AutOpc))
403 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
404
405 emitMOVWithFrameDestroy(MBB, MBBI, DL, TII, AArch64::LR, AArch64::X17);
406 } else if (MFnI->branchProtectionPAuthLR()) {
407 emitMOVWithFrameDestroy(MBB, MBBI, DL, TII, AArch64::X17, AArch64::LR);
408
409 assert(PACSym && "No PAC instruction to refer to");
410 emitEpiloguePACSymOffsetIntoReg(*TII, MBB, MBBI, DL, PACSym, AArch64::X15);
411
412 // The PACM hint-space instruction modifies the following AUTI[AB]1716
413 // to optionally take x15 as an extra operand depending on the
414 // presence of +pauth-lr at runtime. On machines without +pauth-lr, it
415 // behaves as a nop, and the address of the PACI[AB]SP in x15 is
416 // ignored.
417 BuildMI(MBB, MBBI, DL, TII->get(AArch64::PACM))
419
420 unsigned AutOpc = UseBKey ? AArch64::AUTIB1716 : AArch64::AUTIA1716;
421 BuildMI(MBB, MBBI, DL, TII->get(AutOpc))
423 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
424
425 emitMOVWithFrameDestroy(MBB, MBBI, DL, TII, AArch64::LR, AArch64::X17);
426 } else if (Subtarget->hasPAuth()) {
427 BuildMI(MBB, MBBI, DL, TII->get(UseBKey ? AArch64::AUTIB : AArch64::AUTIA),
428 AArch64::LR)
429 .addUse(AArch64::LR)
430 .addUse(AArch64::X16)
432 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
433 } else {
434 emitMOVWithFrameDestroy(MBB, MBBI, DL, TII, AArch64::X17, AArch64::LR);
435
436 unsigned AutOpc = UseBKey ? AArch64::AUTIB1716 : AArch64::AUTIA1716;
437 BuildMI(MBB, MBBI, DL, TII->get(AutOpc))
439 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
440
441 emitMOVWithFrameDestroy(MBB, MBBI, DL, TII, AArch64::LR, AArch64::X17);
442 }
443
444 if (NeedsWinCFI) {
445 assert(UseBKey &&
446 "Windows SEH PAC unwind info only supports B-key signing");
447 BuildMI(MBB, MBBI, DL, TII->get(AArch64::SEH_PACSignLR))
449 }
450}
451
453 switch (Method) {
455 return 0;
457 return 4;
459 return 12;
462 return 20;
463 }
464 llvm_unreachable("Unknown AuthCheckMethod enum");
465}
466
467bool AArch64PointerAuthImpl::run(MachineFunction &MF) {
468 Subtarget = &MF.getSubtarget<AArch64Subtarget>();
469 TII = Subtarget->getInstrInfo();
470
472
473 bool Modified = false;
474
475 for (auto &MBB : MF) {
476 for (auto &MI : MBB) {
477 switch (MI.getOpcode()) {
478 default:
479 break;
480 case AArch64::PAUTH_PROLOGUE:
481 case AArch64::PAUTH_EPILOGUE:
482 PAuthPseudoInstrs.push_back(MI.getIterator());
483 break;
484 }
485 }
486 }
487
488 for (auto It : PAuthPseudoInstrs) {
489 switch (It->getOpcode()) {
490 case AArch64::PAUTH_PROLOGUE:
491 signLR(MF, It);
492 break;
493 case AArch64::PAUTH_EPILOGUE:
494 authenticateLR(MF, It);
495 break;
496 default:
497 llvm_unreachable("Unhandled opcode");
498 }
499 It->eraseFromParent();
500 Modified = true;
501 }
502
503 Modified |= emitSignReturnAddressHardening(MF);
504
505 return Modified;
506}
507
508bool AArch64PointerAuthImpl::emitSignReturnAddressHardening(
509 MachineFunction &MF) {
510 const auto *FI = MF.getInfo<AArch64FunctionInfo>();
511 assert(FI && "FI can't be null");
512 if (!FI->shouldSignReturnAddress(MF) || !FI->shouldHardenSignReturnAddress())
513 return false;
514 assert(Subtarget && "Subtarget must be initialized");
515
516 RegScavenger RS;
517 bool Modified = false;
518 for (MachineBasicBlock &MBB : MF) {
520
521 if (RetInstIter == MBB.end() || RetInstIter->getOpcode() != AArch64::RET)
522 continue;
523
524 assert(RetInstIter->getOperand(0).getReg() == AArch64::LR &&
525 "Return instruction must be returning via LR");
526
527 MachineBasicBlock::iterator InsertionPoint = RetInstIter;
528 // In the case of Windows SEH, the hardening sequence does not immediately
529 // precede the return instruction. Instead, it precedes the SEH_EpilogEnd
530 // pseudo-instruction, which itself is expected to be the predecessor of
531 // the return. Plus, each instruction in the sequence needs one SEH_Nop.
532 const bool NeedsWinCFI = MF.hasWinCFI();
533 if (NeedsWinCFI) {
534 --InsertionPoint;
535 assert(InsertionPoint->getOpcode() == AArch64::SEH_EpilogEnd);
536 }
537 DebugLoc DL = InsertionPoint->getDebugLoc();
538 const auto EmitSEHNopIfRequired = [&]() {
539 if (NeedsWinCFI)
540 BuildMI(MBB, InsertionPoint, DL, TII->get(AArch64::SEH_Nop))
542 };
543
544 RS.enterBasicBlockEnd(MBB);
545 Register XReg = RS.scavengeRegisterBackwards(
546 AArch64::GPR64RegClass, InsertionPoint,
547 /*RestoreAfter=*/false, /*SPAdj=*/0, /*AllowSpill=*/false);
548 if (XReg == AArch64::NoRegister) {
549 // Couldn't find a free register to use for the hardening. Skip.
550 MF.getContext().reportWarning(
551 SMLoc(), "harden-pac-ret failed for function " + MF.getName());
552 continue;
553 }
554
555 // Register copies are done using ORRXrs directly instead of using the
556 // pseudo-instruction COPY because this function can be called after
557 // pseudo-instruction expansion takes place, for example via the machine
558 // outliner pass.
559 emitMOVWithFrameDestroy(MBB, InsertionPoint, DL, TII, XReg, AArch64::LR);
560 EmitSEHNopIfRequired();
561
562 // The XPACI instruction is only available with FEAT_PAUTH. So if the
563 // subtarget does not have it, the alternative XPACLRI instruction must be
564 // used instead. The latter is in hint space, therefore can be used even
565 // if FEAT_PAUTH is absent.
566 if (Subtarget->hasPAuth()) {
567 BuildMI(MBB, InsertionPoint, DL, TII->get(AArch64::XPACI), XReg)
568 .addUse(XReg)
570 EmitSEHNopIfRequired();
571 Register WReg =
572 Subtarget->getRegisterInfo()->getSubReg(XReg, AArch64::sub_32);
573 BuildMI(MBB, InsertionPoint, DL, TII->get(AArch64::LDRWui), WReg)
574 .addUse(XReg)
575 .addImm(0)
576 .addMemOperand(MF.getMachineMemOperand(
577 MachinePointerInfo(),
579 Align(4)))
581 EmitSEHNopIfRequired();
582 } else {
583 // Emit a CFI directive to tell unwinders that the return address is now
584 // saved in XReg.
585 CFIInstBuilder(MBB, InsertionPoint, MachineInstr::FrameDestroy)
586 .buildRegister(AArch64::LR, XReg);
587 BuildMI(MBB, InsertionPoint, DL, TII->get(AArch64::XPACLRI))
589 EmitSEHNopIfRequired();
590 BuildMI(MBB, InsertionPoint, DL, TII->get(AArch64::LDRWui), AArch64::W30)
591 .addUse(AArch64::LR)
592 .addImm(0)
593 .addMemOperand(MF.getMachineMemOperand(
594 MachinePointerInfo(),
596 Align(4)))
598 EmitSEHNopIfRequired();
599 BuildMI(MBB, RetInstIter, DL, TII->get(AArch64::RET))
600 .addUse(XReg)
601 .copyImplicitOps(*RetInstIter);
602 MBB.erase(RetInstIter);
603 }
604 Modified = true;
605 }
606
607 return Modified;
608}
609
610bool AArch64PointerAuthLegacy::runOnMachineFunction(MachineFunction &MF) {
611 return AArch64PointerAuthImpl().run(MF);
612}
613
614PreservedAnalyses
617 const bool Changed = AArch64PointerAuthImpl().run(MF);
618 if (!Changed)
619 return PreservedAnalyses::all();
622 return PA;
623}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define AARCH64_POINTER_AUTH_NAME
static void emitEpiloguePACSymOffsetIntoReg(const TargetInstrInfo &TII, MachineBasicBlock &MBB, MachineBasicBlock::iterator I, DebugLoc DL, MCSymbol *PACSym, Register Reg)
static void emitMOVWithFrameDestroy(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, DebugLoc DL, const AArch64InstrInfo *TII, Register Dst, Register Src)
static void emitAUTCFI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, bool EmitCFI)
static void decoratePACWithCFI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, bool EmitCFI, BuildPACMIFn BuildPACMI)
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
Module.h This file contains the declarations for the Module class.
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
Promote Memory to Register
Definition Mem2Reg.cpp:110
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
This file declares the machine register scavenger class.
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
bool needsAsyncDwarfUnwindInfo(const MachineFunction &MF) const
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
const AArch64RegisterInfo * getRegisterInfo() const override
const AArch64InstrInfo * getInstrInfo() const override
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
Helper class for creating CFI instructions and inserting them into MIR.
A debug info location.
Definition DebugLoc.h:126
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition Function.cpp:734
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ABI instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
LLVM_ABI instr_iterator getFirstInstrTerminator()
Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.
MachineInstrBundleIterator< MachineInstr > iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MCContext & getContext() const
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
const MachineInstrBuilder & addUse(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
const MachineInstrBuilder & copyImplicitOps(const MachineInstr &OtherMI) const
Copy all the implicit operands from OtherMI onto this one.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
LLVM_ABI void setPreInstrSymbol(MachineFunction &MF, MCSymbol *Symbol)
Set a symbol that will be emitted just prior to the instruction itself.
@ MOVolatile
The memory access is volatile.
@ MOLoad
The memory access reads data.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition Analysis.h:151
Wrapper class representing virtual and physical registers.
Definition Register.h:20
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
int64_t getFixed() const
Returns the fixed component of the stack.
Definition TypeSize.h:46
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
TargetInstrInfo - Interface to description of machine instruction set.
const Triple & getTargetTriple() const
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition Triple.h:876
Changed
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ MO_NC
MO_NC - Indicates whether the linker is expected to check the symbol reference for overflow.
@ MO_PAGEOFF
MO_PAGEOFF - A symbol operand with this flag represents the offset of that symbol within a 4K page.
@ MO_PAGE
MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...
unsigned getCheckerSizeInBytes(AuthCheckMethod Method)
Returns the number of bytes added by checkAuthenticatedRegister.
AuthCheckMethod
Variants of check performed on an authenticated pointer.
@ XPACHint
Check by comparing the authenticated value with an XPAC-ed one without using PAuth instructions not e...
@ DummyLoad
Perform a load to a temporary register.
@ HighBitsNoTBI
Check by comparing bits 62 and 61 of the authenticated address.
@ None
Do not check the value at all.
@ XPAC
Similar to XPACHint but using Armv8.3-only XPAC instruction, thus not restricted to LR:
SetRAStateMode
Control the emission of .cfi_set_ra_state, which replaces the deprecated .cfi_negate_ra_state_with_pc...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
FunctionPass * createAArch64PointerAuthPass()
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
void emitFrameOffset(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, StackOffset Offset, const TargetInstrInfo *TII, MachineInstr::MIFlag=MachineInstr::NoFlags, bool SetNZCV=false, bool NeedsWinCFI=false, bool *HasWinCFI=nullptr, bool EmitCFAOffset=false, StackOffset InitialOffset={}, unsigned FrameReg=AArch64::SP)
emitFrameOffset - Emit instructions as needed to set DestReg to SrcReg plus Offset.