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 "AArch64Subtarget.h"
21
22using namespace llvm;
23using namespace llvm::AArch64PAuth;
24
25#define AARCH64_POINTER_AUTH_NAME "AArch64 Pointer Authentication"
26
27namespace {
28
29/// Control the emission of .cfi_set_ra_state, which replaces the
30/// deprecated .cfi_negate_ra_state_with_pc [1].
31///
32/// The latter is fundamentally unable to express some program orders [2], as
33/// the dwarf 'program' reads functions in a linear scan of their addresses to
34/// reconstruct the state of the frame, whereas control flow may enter and exit
35/// such regions arbitrarily (such as in hot-cold-split, and shrinkwrapped
36/// fucntions), and thus the negate-based cfi is unable to encode the address of
37/// the signing instruciton in all program orders.
38///
39/// Since .cfi_negate_ra_state is still sufficient for describing
40/// ptrauth-returns=pauth, we default to using the new CFI only for PAuth_LR, as
41/// DW_CFA_AARCH64_negate_ra_state has a smaller encoding than
42/// DW_CFA_AARCH64_set_ra_state.
43///
44/// 1: https://github.com/ARM-software/abi-aa/pull/346
45/// 2: https://github.com/ARM-software/abi-aa/issues/327
46enum class SetRAStateMode {
47 Never, // Always use .cfi_negate_ra_state(_with_pc)
48 PAuthLR, // Use .cfi_set_ra_state only for PAuth_LR
49 Always, // Use .cfi_set_ra_state for both PAuth and PAuth_LR
50};
51cl::opt<SetRAStateMode> CFILLVMSetRASignStateMode(
52 "aarch64-cfi-llvm-set-ra-sign-state", cl::init(SetRAStateMode::PAuthLR),
53 cl::desc("Control emission of .cfi_set_ra_state for PAC return address "
54 "signing CFI"),
55 cl::values(clEnumValN(SetRAStateMode::Never, "never",
56 "Always use legacy .cfi_negate_ra_state[_with_pc]"),
57 clEnumValN(SetRAStateMode::PAuthLR, "pauth-lr",
58 "Use new CFI only for PAuth_LR (default)"),
59 clEnumValN(SetRAStateMode::Always, "always",
60 "Use new CFI for both PAuth and PAuth_LR")),
62
63class AArch64PointerAuthImpl {
64public:
65 bool run(MachineFunction &MF);
66
67private:
68 const AArch64Subtarget *Subtarget = nullptr;
69 const AArch64InstrInfo *TII = nullptr;
70
71 void signLR(MachineFunction &MF, MachineBasicBlock::iterator MBBI) const;
72
73 void authenticateLR(MachineFunction &MF,
75};
76
77class AArch64PointerAuthLegacy : public MachineFunctionPass {
78public:
79 static char ID;
80
81 AArch64PointerAuthLegacy() : MachineFunctionPass(ID) {}
82
83 bool runOnMachineFunction(MachineFunction &MF) override;
84
85 StringRef getPassName() const override { return AARCH64_POINTER_AUTH_NAME; }
86};
87
88} // end anonymous namespace
89
90INITIALIZE_PASS(AArch64PointerAuthLegacy, "aarch64-ptrauth",
91 AARCH64_POINTER_AUTH_NAME, false, false)
92
94 return new AArch64PointerAuthLegacy();
95}
96
97char AArch64PointerAuthLegacy::ID = 0;
98
113
114// Wrap a given PAC instruction in CFI that describes it.
115//
116// Depending on the type of CFI required, we may need to emit the directive
117// either before or after the instruction, so that unwinders can correctly
118// interpret the location of the signing instruction.
119//
120// As a general rule, CFI opcodes describe the actions needed to recover the
121// register state leading up to a not-yet-retired instruction, with one
122// exception: .cfi_negate_ra_state_with_pc always comes before the paci[ab]sppc,
123// since the unwinder uses the location of the CFI itself to derive the address
124// of the signing instruction [1].
125// 1: https://github.com/llvm/llvm-project/pull/137795#issuecomment-2838779129
126template <typename BuildPACMIFn>
128 MachineBasicBlock::iterator MBBI, bool EmitCFI,
129 BuildPACMIFn BuildPACMI) {
130 if (!EmitCFI) {
131 BuildPACMI();
132 return;
133 }
134
135 auto &MF = *MBB.getParent();
136 auto &MFnI = *MF.getInfo<AArch64FunctionInfo>();
138 const Triple &TT = MF.getTarget().getTargetTriple();
139
140 if (MFnI.branchProtectionPAuthLR()) {
141 switch (CFILLVMSetRASignStateMode) {
142 case SetRAStateMode::Never:
143 CFIBuilder.buildNegateRAStateWithPC();
144 BuildPACMI();
145 break;
146 case SetRAStateMode::PAuthLR:
147 case SetRAStateMode::Always: {
148 BuildPACMI();
149 MCSymbol *PACSym = MFnI.getSigningInstrLabel();
150 assert(PACSym && "No PAC instruction to refer to");
151 CFIBuilder.buildSetRAState(2, PACSym);
152 break;
153 }
154 }
155 } else {
156 switch (CFILLVMSetRASignStateMode) {
157 case SetRAStateMode::Never:
158 case SetRAStateMode::PAuthLR:
159 BuildPACMI();
160 if (!TT.isOSBinFormatMachO()) {
161 CFIBuilder.buildNegateRAState();
162 }
163 break;
164 case SetRAStateMode::Always:
165 BuildPACMI();
166 CFIBuilder.buildSetRAState(1, nullptr);
167 break;
168 }
169 }
170}
171
173 bool EmitCFI) {
174 if (!EmitCFI)
175 return;
176
177 auto &MF = *MBB.getParent();
178 auto &MFnI = *MF.getInfo<AArch64FunctionInfo>();
180 const Triple &TT = MF.getTarget().getTargetTriple();
181
182 if (MFnI.branchProtectionPAuthLR()) {
183 switch (CFILLVMSetRASignStateMode) {
184 case SetRAStateMode::Never:
185 // DW_CFA_AARCH64_negate_ra_state_with_pc is semantically broken for
186 // functions where shrinkwrapping places signing/authenticating pairs on
187 // distinct CFG paths.
188 //
189 // DWARF CFI is evaluated linearly over the byte stream, not along control
190 // flow edges. The toggle semantics of this directive therefore cannot
191 // faithfully represent the signed/unsigned RA state for all possible CFG
192 // paths. The added complexity versus DW_CFA_AARCH64_negate_ra_state is
193 // that an unwinder must also reconstruct the PC of the PACI[AB]SPPC in
194 // order to verify the signed LR, and that address is derived from the
195 // location of this directive in the linear CFI stream.
196 //
197 // The correct fix is to use DW_CFA_AARCH64_set_ra_state_with_pc, which
198 // sets the RA state and signing address absolutely rather than toggling
199 // them. An unwinder that supports this directive can reconstruct the
200 // correct state on any CFG path, regardless of how many
201 // signing/authenticating pairs exist in the function. However, not all
202 // unwinders support this directive, so we cannot rely on it exclusively.
203 //
204 // For unwinders that only support DW_CFA_AARCH64_negate_ra_state_with_pc,
205 // libunwind exploits a loophole: it records the address at the
206 // DW_CFA_AARCH64_negate_ra_state_with_pc site to authenticate the LR, but
207 // does not care that the CFI state remains "signed with pc" after
208 // authentication has occurred. This means we can safely omit the
209 // FrameDestroy emission of this directive, treating it solely as a marker
210 // for the signing site, as long as each function has at most one such
211 // signing location. That invariant holds today because shrinkwrapping
212 // does not yet hoist or sink PAuth_LR frame code across CFG join/split
213 // points; once it does, we must avoid those transformations on platforms
214 // that have this limitation.
215 //
216 // https://github.com/ARM-software/abi-aa/issues/327
217 // https://github.com/ARM-software/abi-aa/pull/346
218 break;
219 case SetRAStateMode::PAuthLR:
220 case SetRAStateMode::Always:
221 CFIBuilder.buildSetRAState(0, nullptr);
222 break;
223 }
224 } else if (!TT.isOSBinFormatMachO()) {
225 switch (CFILLVMSetRASignStateMode) {
226 case SetRAStateMode::Never:
227 case SetRAStateMode::PAuthLR:
228 CFIBuilder.buildNegateRAState();
229 break;
230 case SetRAStateMode::Always:
231 CFIBuilder.buildSetRAState(0, nullptr);
232 break;
233 }
234 }
235}
236
237void AArch64PointerAuthImpl::signLR(MachineFunction &MF,
239 auto &MFnI = *MF.getInfo<AArch64FunctionInfo>();
240 bool UseBKey = MFnI.shouldSignWithBKey();
241 bool EmitCFI = MFnI.needsDwarfUnwindInfo(MF);
242 bool NeedsWinCFI = MF.hasWinCFI();
243
244 MachineBasicBlock &MBB = *MBBI->getParent();
245
246 // Debug location must be unknown, see AArch64FrameLowering::emitPrologue.
247 DebugLoc DL;
248
249 if (UseBKey && !MF.getTarget().getTargetTriple().isOSBinFormatMachO()) {
250 BuildMI(MBB, MBBI, DL, TII->get(AArch64::EMITBKEY))
252 }
253
254 // PAuthLR authentication instructions need to know the value of PC at the
255 // point of signing (PACI*).
256 if (MFnI.branchProtectionPAuthLR()) {
257 MCSymbol *PACSym = MF.getContext().createTempSymbol();
258 MFnI.setSigningInstrLabel(PACSym);
259 }
260
261 // No SEH opcode for this one; it doesn't materialize into an
262 // instruction on Windows.
263 if (MFnI.branchProtectionPAuthLR() && Subtarget->hasPAuthLR()) {
264 decoratePACWithCFI(MBB, MBBI, EmitCFI, [&]() {
265 BuildMI(MBB, MBBI, DL,
266 TII->get(UseBKey ? AArch64::PACIBSPPC : AArch64::PACIASPPC))
268 ->setPreInstrSymbol(MF, MFnI.getSigningInstrLabel());
269 });
270 } else {
271 if (MFnI.branchProtectionPAuthLR()) {
272 BuildMI(MBB, MBBI, DL, TII->get(AArch64::PACM))
274 }
275 decoratePACWithCFI(MBB, MBBI, EmitCFI, [&]() {
276 BuildMI(MBB, MBBI, DL,
277 TII->get(UseBKey ? AArch64::PACIBSP : AArch64::PACIASP))
279 ->setPreInstrSymbol(MF, MFnI.getSigningInstrLabel());
280 });
281 }
282
283 if (!EmitCFI && NeedsWinCFI) {
284 assert(UseBKey &&
285 "Windows SEH PAC unwind info only supports B-key signing");
286 BuildMI(MBB, MBBI, DL, TII->get(AArch64::SEH_PACSignLR))
288 }
289}
290
291void AArch64PointerAuthImpl::authenticateLR(
292 MachineFunction &MF, MachineBasicBlock::iterator MBBI) const {
293 const AArch64FunctionInfo *MFnI = MF.getInfo<AArch64FunctionInfo>();
294 bool UseBKey = MFnI->shouldSignWithBKey();
295 bool EmitAsyncCFI = MFnI->needsAsyncDwarfUnwindInfo(MF);
296 bool NeedsWinCFI = MF.hasWinCFI();
297
298 MachineBasicBlock &MBB = *MBBI->getParent();
299 DebugLoc DL = MBBI->getDebugLoc();
300 // MBBI points to a PAUTH_EPILOGUE instruction to be replaced and
301 // TI points to a terminator instruction that may or may not be combined.
302 // Note that inserting new instructions "before MBBI" and "before TI" is
303 // not the same because if ShadowCallStack is enabled, its instructions
304 // are placed between MBBI and TI.
306
307 MCSymbol *PACSym = MFnI->getSigningInstrLabel();
308 auto &AFL = *static_cast<const AArch64FrameLowering *>(
309 MF.getSubtarget().getFrameLowering());
310 int64_t ArgumentStackToRestore = AFL.getArgumentStackToRestore(MF, MBB);
311
312 // When ArgumentStackToRestore > 0, this function received more argument
313 // space than the tail callee pops. The epilogue contains an SP adjustment
314 // (e.g. "add sp, sp, #N") to discard the leftover argument space. We must
315 // authenticate *before* that adjustment so that AUTI[AB]SP sees the entry
316 // SP discriminator. Move any such SP-adjusting instructions to after the
317 // authentication instruction.
318 //
319 // When ArgumentStackToRestore < 0, the tail callee pops more argument space
320 // than this function received, so after the frame teardown, SP is below the
321 // entry SP used as the signing modifier.
322 //
323 // We cannot simply bump SP first and then use AUTI[AB]SP with the bumped
324 // value, because the live arguments would fall below SP and potentially
325 // outside the red-zone. Collect those SP adjustments in case we need to move
326 // them after the AUT.
327 int64_t Offset = -ArgumentStackToRestore;
328 SmallVector<MachineInstr *, 2> SPMods;
329 if (ArgumentStackToRestore > 0) {
330 for (auto I = MBBI; I->getFlag(MachineInstr::FrameDestroy); --I) {
331 if ((I->getOpcode() == AArch64::ADDXri ||
332 I->getOpcode() == AArch64::SUBXri) &&
333 I->getOperand(0).getReg() == AArch64::SP &&
334 I->getOperand(1).getReg() == AArch64::SP) {
335 SPMods.push_back(&*I);
336 int64_t Imm = I->getOperand(2).getImm()
337 << AArch64_AM::getShiftValue(I->getOperand(3).getImm());
338 Offset += I->getOpcode() == AArch64::ADDXri ? Imm : -Imm;
339 }
340 }
341 }
342
343 // If there will not be an SP bump afterward, we can use an AUT or RET form
344 // with a hardcoded SP discriminator.
345 if (!Offset) {
346 // The AUTIASP instruction assembles to a hint instruction before v8.3a so
347 // this instruction can safely be used for any v8a architecture.
348 // From v8.3a onwards there are optimised authenticate LR and return
349 // instructions, namely RETA{A,B}, that can be used instead. In this case
350 // the DW_CFA_AARCH64_negate_ra_state can't be emitted. Additionally,
351 // RET{A,B} requires the SP to match its incoming value on entry to the
352 // function.
353 bool TerminatorIsCombinable = TI != MBB.end() &&
354 TI->getOpcode() == AArch64::RET &&
355 ArgumentStackToRestore == 0;
356
357 if (Subtarget->hasPAuth() && TerminatorIsCombinable && !NeedsWinCFI &&
358 !MF.getFunction().hasFnAttribute(Attribute::ShadowCallStack)) {
359 if (MFnI->branchProtectionPAuthLR() && Subtarget->hasPAuthLR()) {
360 assert(PACSym && "No PAC instruction to refer to");
361 BuildMI(MBB, TI, DL,
362 TII->get(UseBKey ? AArch64::RETABSPPCi : AArch64::RETAASPPCi))
363 .addSym(PACSym)
366 } else {
367 if (MFnI->branchProtectionPAuthLR()) {
369 AArch64::X16);
370 BuildMI(MBB, MBBI, DL, TII->get(AArch64::PACM))
372 }
373 BuildMI(MBB, TI, DL,
374 TII->get(UseBKey ? AArch64::RETAB : AArch64::RETAA))
377 }
378 MBB.erase(TI);
379 return;
380 }
381
382 for (auto *MI : SPMods)
383 MI->removeFromParent();
384
385 if (MFnI->branchProtectionPAuthLR() && Subtarget->hasPAuthLR()) {
386 assert(PACSym && "No PAC instruction to refer to");
387 BuildMI(MBB, MBBI, DL,
388 TII->get(UseBKey ? AArch64::AUTIBSPPCi : AArch64::AUTIASPPCi))
389 .addSym(PACSym)
391 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
392 } else {
393 if (MFnI->branchProtectionPAuthLR()) {
395 AArch64::X16);
396
397 BuildMI(MBB, MBBI, DL, TII->get(AArch64::PACM))
399 }
400 BuildMI(MBB, MBBI, DL,
401 TII->get(UseBKey ? AArch64::AUTIBSP : AArch64::AUTIASP))
403 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
404 }
405
406 if (NeedsWinCFI) {
407 assert(UseBKey &&
408 "Windows SEH PAC unwind info only supports B-key signing");
409 BuildMI(MBB, MBBI, DL, TII->get(AArch64::SEH_PACSignLR))
411 }
412
413 for (auto *MI : SPMods)
414 MBB.insert(MBBI, MI);
415
416 return;
417 }
418
419 for (auto *MI : SPMods)
420 MI->removeFromParent();
421
422 // Otherwise there is an offset to the incoming SP, and we can't use the aut
423 // variants that hard-code SP. Reconstruct entry SP in x16 and authenticate
424 // using AUTI[AB]1716 (x17=LR, x16=entry_SP).
425 emitFrameOffset(MBB, MBBI, DL, AArch64::X16, AArch64::SP,
428
429 auto emitMOV = [&](Register Dst, Register Src) {
430 BuildMI(MBB, MBBI, DL, TII->get(AArch64::ORRXrs), Dst)
431 .addReg(AArch64::XZR)
432 .addReg(Src)
433 .addImm(0)
435 };
436
437 if (MFnI->branchProtectionPAuthLR() && Subtarget->hasPAuthLR()) {
438 emitMOV(AArch64::X17, AArch64::LR);
439
440 assert(PACSym && "No PAC instruction to refer to");
441 emitEpiloguePACSymOffsetIntoReg(*TII, MBB, MBBI, DL, PACSym, AArch64::X15);
442
443 unsigned AutOpc = UseBKey ? AArch64::AUTIB171615 : AArch64::AUTIA171615;
444 BuildMI(MBB, MBBI, DL, TII->get(AutOpc))
446 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
447
448 emitMOV(AArch64::LR, AArch64::X17);
449 } else if (MFnI->branchProtectionPAuthLR()) {
450 emitMOV(AArch64::X17, AArch64::LR);
451
452 assert(PACSym && "No PAC instruction to refer to");
453 emitEpiloguePACSymOffsetIntoReg(*TII, MBB, MBBI, DL, PACSym, AArch64::X15);
454
455 // The PACM hint-space instruction modifies the following AUTI[AB]1716
456 // to optionally take x15 as an extra operand depending on the
457 // presence of +pauth-lr at runtime. On machines without +pauth-lr, it
458 // behaves as a nop, and the address of the PACI[AB]SP in x15 is
459 // ignored.
460 BuildMI(MBB, MBBI, DL, TII->get(AArch64::PACM))
462
463 unsigned AutOpc = UseBKey ? AArch64::AUTIB1716 : AArch64::AUTIA1716;
464 BuildMI(MBB, MBBI, DL, TII->get(AutOpc))
466 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
467
468 emitMOV(AArch64::LR, AArch64::X17);
469 } else if (Subtarget->hasPAuth()) {
470 BuildMI(MBB, MBBI, DL, TII->get(UseBKey ? AArch64::AUTIB : AArch64::AUTIA),
471 AArch64::LR)
472 .addUse(AArch64::LR)
473 .addUse(AArch64::X16)
475 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
476 } else {
477 emitMOV(AArch64::X17, AArch64::LR);
478
479 unsigned AutOpc = UseBKey ? AArch64::AUTIB1716 : AArch64::AUTIA1716;
480 BuildMI(MBB, MBBI, DL, TII->get(AutOpc))
482 emitAUTCFI(MBB, MBBI, EmitAsyncCFI);
483
484 emitMOV(AArch64::LR, AArch64::X17);
485 }
486
487 if (NeedsWinCFI) {
488 assert(UseBKey &&
489 "Windows SEH PAC unwind info only supports B-key signing");
490 BuildMI(MBB, MBBI, DL, TII->get(AArch64::SEH_PACSignLR))
492 }
493
494 for (auto *MI : SPMods)
495 MBB.insert(MBBI, MI);
496}
497
499 switch (Method) {
501 return 0;
503 return 4;
505 return 12;
508 return 20;
509 }
510 llvm_unreachable("Unknown AuthCheckMethod enum");
511}
512
513bool AArch64PointerAuthImpl::run(MachineFunction &MF) {
514 Subtarget = &MF.getSubtarget<AArch64Subtarget>();
515 TII = Subtarget->getInstrInfo();
516
518
519 bool Modified = false;
520
521 for (auto &MBB : MF) {
522 for (auto &MI : MBB) {
523 switch (MI.getOpcode()) {
524 default:
525 break;
526 case AArch64::PAUTH_PROLOGUE:
527 case AArch64::PAUTH_EPILOGUE:
528 PAuthPseudoInstrs.push_back(MI.getIterator());
529 break;
530 }
531 }
532 }
533
534 for (auto It : PAuthPseudoInstrs) {
535 switch (It->getOpcode()) {
536 case AArch64::PAUTH_PROLOGUE:
537 signLR(MF, It);
538 break;
539 case AArch64::PAUTH_EPILOGUE:
540 authenticateLR(MF, It);
541 break;
542 default:
543 llvm_unreachable("Unhandled opcode");
544 }
545 It->eraseFromParent();
546 Modified = true;
547 }
548
549 return Modified;
550}
551
552bool AArch64PointerAuthLegacy::runOnMachineFunction(MachineFunction &MF) {
553 return AArch64PointerAuthImpl().run(MF);
554}
555
556PreservedAnalyses
559 const bool Changed = AArch64PointerAuthImpl().run(MF);
560 if (!Changed)
561 return PreservedAnalyses::all();
564 return PA;
565}
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 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
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
#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
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 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:727
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 instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
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.
LLVM_ABI void setPreInstrSymbol(MachineFunction &MF, MCSymbol *Symbol)
Set a symbol that will be emitted just prior to the instruction itself.
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:873
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:
static unsigned getShiftValue(unsigned Imm)
getShiftValue - Extract the shift value.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:578
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.
@ Always
Always emit .debug_str_offsets talbes as DWARF64 for testing.
Definition DWP.h:32