1//=- AArch64MachineFunctionInfo.h - AArch64 machine function info -*- C++ -*-=//
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//
9// This file declares AArch64-specific per-machine-function information.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
14#define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
15
16#include "AArch64SMEAttributes.h"
17#include "AArch64Subtarget.h"
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/SmallPtrSet.h"
20#include "llvm/ADT/SmallVector.h"
21#include "llvm/CodeGen/CallingConvLower.h"
22#include "llvm/CodeGen/MIRYamlMapping.h"
23#include "llvm/CodeGen/MachineFrameInfo.h"
24#include "llvm/CodeGen/MachineFunction.h"
25#include "llvm/IR/Function.h"
26#include "llvm/MC/MCLinkerOptimizationHint.h"
27#include "llvm/MC/MCSymbol.h"
28#include <cassert>
29#include <optional>
30
31namespace llvm {
32
33namespace yaml {
34struct AArch64FunctionInfo;
35} // end namespace yaml
36
37class AArch64Subtarget;
38class MachineInstr;
39
40/// Condition of signing the return address in a function.
41///
42/// Corresponds to possible values of "sign-return-address" function attribute.
43enum class SignReturnAddress {
44 None,
45 NonLeaf,
46 All,
47};
48
49/// AArch64FunctionInfo - This class is derived from MachineFunctionInfo and
50/// contains private AArch64-specific information for each MachineFunction.
51class AArch64FunctionInfo final : public MachineFunctionInfo {
52 /// Number of bytes of arguments this function has on the stack. If the callee
53 /// is expected to restore the argument stack this should be a multiple of 16,
54 /// all usable during a tail call.
55 ///
56 /// The alternative would forbid tail call optimisation in some cases: if we
57 /// want to transfer control from a function with 8-bytes of stack-argument
58 /// space to a function with 16-bytes then misalignment of this value would
59 /// make a stack adjustment necessary, which could not be undone by the
60 /// callee.
61 unsigned BytesInStackArgArea = 0;
62
63 /// The number of bytes to restore to deallocate space for incoming
64 /// arguments. Canonically 0 in the C calling convention, but non-zero when
65 /// callee is expected to pop the args.
66 unsigned ArgumentStackToRestore = 0;
67
68 /// Space just below incoming stack pointer reserved for arguments being
69 /// passed on the stack during a tail call. This will be the difference
70 /// between the largest tail call argument space needed in this function and
71 /// what's already available by reusing space of incoming arguments.
72 unsigned TailCallReservedStack = 0;
73
74 /// HasStackFrame - True if this function has a stack frame. Set by
75 /// determineCalleeSaves().
76 bool HasStackFrame = false;
77
78 /// Amount of stack frame size, not including callee-saved registers.
79 uint64_t LocalStackSize = 0;
80
81 /// Amount of stack frame size used for saving callee-saved registers.
82 unsigned CalleeSavedStackSize = 0;
83 unsigned ZPRCalleeSavedStackSize = 0;
84 unsigned PPRCalleeSavedStackSize = 0;
85 bool HasCalleeSavedStackSize = false;
86 bool HasSVECalleeSavedStackSize = false;
87
88 /// Number of TLS accesses using the special (combinable)
89 /// _TLS_MODULE_BASE_ symbol.
90 unsigned NumLocalDynamicTLSAccesses = 0;
91
92 /// FrameIndex for start of varargs area for arguments passed on the
93 /// stack.
94 int VarArgsStackIndex = 0;
95
96 /// Offset of start of varargs area for arguments passed on the stack.
97 unsigned VarArgsStackOffset = 0;
98
99 /// FrameIndex for start of varargs area for arguments passed in
100 /// general purpose registers.
101 int VarArgsGPRIndex = 0;
102
103 /// Size of the varargs area for arguments passed in general purpose
104 /// registers.
105 unsigned VarArgsGPRSize = 0;
106
107 /// FrameIndex for start of varargs area for arguments passed in
108 /// floating-point registers.
109 int VarArgsFPRIndex = 0;
110
111 /// Size of the varargs area for arguments passed in floating-point
112 /// registers.
113 unsigned VarArgsFPRSize = 0;
114
115 /// The stack slots used to add space between FPR and GPR accesses when using
116 /// hazard padding. StackHazardCSRSlotIndex is added between GPR and FPR CSRs.
117 /// StackHazardSlotIndex is added between (sorted) stack objects.
118 int StackHazardSlotIndex = std::numeric_limits<int>::max();
119 int StackHazardCSRSlotIndex = std::numeric_limits<int>::max();
120
121 /// True if this function has a subset of CSRs that is handled explicitly via
122 /// copies.
123 bool IsSplitCSR = false;
124
125 /// True when the stack gets realigned dynamically because the size of stack
126 /// frame is unknown at compile time. e.g., in case of VLAs.
127 bool StackRealigned = false;
128
129 /// True when the callee-save stack area has unused gaps that may be used for
130 /// other stack allocations.
131 bool CalleeSaveStackHasFreeSpace = false;
132
133 /// SRetReturnReg - sret lowering includes returning the value of the
134 /// returned struct in a register. This field holds the virtual register into
135 /// which the sret argument is passed.
136 Register SRetReturnReg;
137
138 /// SVE stack size (for predicates and data vectors) are maintained here
139 /// rather than in FrameInfo, as the placement and Stack IDs are target
140 /// specific.
141 uint64_t StackSizeZPR = 0;
142 uint64_t StackSizePPR = 0;
143
144 /// Are SVE objects (vectors and predicates) split into separate regions on
145 /// the stack.
146 bool SplitSVEObjects = false;
147
148 /// HasCalculatedStackSizeSVE indicates whether StackSizeZPR/PPR is valid.
149 bool HasCalculatedStackSizeSVE = false;
150
151 /// Has a value when it is known whether or not the function uses a
152 /// redzone, and no value otherwise.
153 /// Initialized during frame lowering, unless the function has the noredzone
154 /// attribute, in which case it is set to false at construction.
155 std::optional<bool> HasRedZone;
156
157 /// ForwardedMustTailRegParms - A list of virtual and physical registers
158 /// that must be forwarded to every musttail call.
159 SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;
160
161 /// FrameIndex for the tagged base pointer.
162 std::optional<int> TaggedBasePointerIndex;
163
164 /// Offset from SP-at-entry to the tagged base pointer.
165 /// Tagged base pointer is set up to point to the first (lowest address)
166 /// tagged stack slot.
167 unsigned TaggedBasePointerOffset;
168
169 /// OutliningStyle denotes, if a function was outined, how it was outlined,
170 /// e.g. Tail Call, Thunk, or Function if none apply.
171 std::optional<std::string> OutliningStyle;
172
173 // Offset from SP-after-callee-saved-spills (i.e. SP-at-entry minus
174 // CalleeSavedStackSize) to the address of the frame record.
175 int CalleeSaveBaseToFrameRecordOffset = 0;
176
177 /// SignCondition controls when PAC-RET protection should be used.
178 SignReturnAddress SignCondition = SignReturnAddress::None;
179
180 /// SignWithBKey modifies the default PAC-RET mode to signing with the B key.
181 bool SignWithBKey = false;
182
183 /// HasELFSignedGOT is true if the target binary format is ELF and the IR
184 /// module containing the corresponding function has "ptrauth-elf-got" flag
185 /// set to 1.
186 bool HasELFSignedGOT = false;
187
188 /// SigningInstrOffset captures the offset of the PAC-RET signing instruction
189 /// within the prologue, so it can be re-used for authentication in the
190 /// epilogue when using PC as a second salt (FEAT_PAuth_LR)
191 MCSymbol *SignInstrLabel = nullptr;
192
193 /// SignReturnAddressHardening specifies the PAC-RET hardening scheme.
194 enum class SignReturnAddressHardeningKind { None, LoadReturnAddress };
195
196 SignReturnAddressHardeningKind SignReturnAddressHardening =
197 SignReturnAddressHardeningKind::None;
198
199 /// BranchTargetEnforcement enables placing BTI instructions at potential
200 /// indirect branch destinations.
201 bool BranchTargetEnforcement = false;
202
203 /// Indicates that SP signing should be diversified with PC as-per PAuthLR.
204 /// This is set by -mbranch-protection and will emit NOP instructions unless
205 /// the subtarget feature +pauthlr is also used (in which case non-NOP
206 /// instructions are emitted).
207 bool BranchProtectionPAuthLR = false;
208
209 /// Whether this function has an extended frame record [Ctx, FP, LR]. If so,
210 /// bit 60 of the in-memory FP will be 1 to enable other tools to detect the
211 /// extended record.
212 bool HasSwiftAsyncContext = false;
213
214 /// Whether this function makes a non-tail call, on Windows, to a function
215 /// that pops its own stack arguments. The unwinder gives the SP after that
216 /// pop, which isn't the SP our unwind info describes if we reserved the
217 /// argument area in the prologue, so we must be found via the frame pointer.
218 bool HasWinCallToCalleePopFunction = false;
219
220 /// The stack slot where the Swift asynchronous context is stored.
221 int SwiftAsyncContextFrameIdx = std::numeric_limits<int>::max();
222
223 bool IsMTETagged = false;
224
225 /// The function has Scalable Vector or Scalable Predicate register argument
226 /// or return type
227 bool IsSVECC = false;
228
229 /// Whether this function changes streaming mode within the function.
230 bool HasStreamingModeChanges = false;
231
232 /// True if the function need unwind information.
233 mutable std::optional<bool> NeedsDwarfUnwindInfo;
234
235 /// True if the function need asynchronous unwind information.
236 mutable std::optional<bool> NeedsAsyncDwarfUnwindInfo;
237
238 int64_t StackProbeSize = 0;
239
240 // Holds a register containing pstate.sm. This is set
241 // on function entry to record the initial pstate of a function.
242 Register PStateSMReg = Register();
243
244 // Has the PNReg used to build PTRUE instruction.
245 // The PTRUE is used for the LD/ST of ZReg pairs in save and restore.
246 unsigned PredicateRegForFillSpill = 0;
247
248 // Holds the SME function attributes (streaming mode, ZA/ZT0 state).
249 SMEAttrs SMEFnAttrs;
250
251 // Holds the TPIDR2 block if allocated early (for Windows/stack probes
252 // support).
253 Register EarlyAllocSMESaveBuffer = Register();
254
255public:
256 AArch64FunctionInfo(const Function &F, const AArch64Subtarget *STI);
257
258 MachineFunctionInfo *
259 clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF,
260 const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
261 const override;
262
263 void setEarlyAllocSMESaveBuffer(Register Ptr) {
264 EarlyAllocSMESaveBuffer = Ptr;
265 }
266
267 Register getEarlyAllocSMESaveBuffer() const {
268 return EarlyAllocSMESaveBuffer;
269 }
270
271 void setPredicateRegForFillSpill(unsigned Reg) {
272 PredicateRegForFillSpill = Reg;
273 }
274 unsigned getPredicateRegForFillSpill() const {
275 return PredicateRegForFillSpill;
276 }
277
278 Register getPStateSMReg() const { return PStateSMReg; };
279 void setPStateSMReg(Register Reg) { PStateSMReg = Reg; };
280
281 bool isSVECC() const { return IsSVECC; };
282 void setIsSVECC(bool s) { IsSVECC = s; };
283
284 void initializeBaseYamlFields(const yaml::AArch64FunctionInfo &YamlMFI);
285
286 unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; }
287 void setBytesInStackArgArea(unsigned bytes) { BytesInStackArgArea = bytes; }
288
289 unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; }
290 void setArgumentStackToRestore(unsigned bytes) {
291 ArgumentStackToRestore = bytes;
292 }
293
294 unsigned getTailCallReservedStack() const { return TailCallReservedStack; }
295 void setTailCallReservedStack(unsigned bytes) {
296 TailCallReservedStack = bytes;
297 }
298
299 void setStackSizeSVE(uint64_t ZPR, uint64_t PPR) {
300 assert(isAligned(Align(16), ZPR) && isAligned(Align(16), PPR) &&
301 "expected SVE stack sizes to be aligned to 16-bytes");
302 StackSizeZPR = ZPR;
303 StackSizePPR = PPR;
304 HasCalculatedStackSizeSVE = true;
305 }
306
307 uint64_t getStackSizeZPR() const {
308 assert(hasCalculatedStackSizeSVE());
309 return StackSizeZPR;
310 }
311 uint64_t getStackSizePPR() const {
312 assert(hasCalculatedStackSizeSVE());
313 return StackSizePPR;
314 }
315
316 bool hasCalculatedStackSizeSVE() const { return HasCalculatedStackSizeSVE; }
317
318 bool hasSVEStackSize() const {
319 return getStackSizeZPR() > 0 || getStackSizePPR() > 0;
320 }
321
322 bool hasStackFrame() const { return HasStackFrame; }
323 void setHasStackFrame(bool s) { HasStackFrame = s; }
324
325 bool isStackRealigned() const { return StackRealigned; }
326 void setStackRealigned(bool s) { StackRealigned = s; }
327 bool hasCalleeSaveStackFreeSpace() const {
328 return CalleeSaveStackHasFreeSpace;
329 }
330 void setCalleeSaveStackHasFreeSpace(bool s) {
331 CalleeSaveStackHasFreeSpace = s;
332 }
333 bool isSplitCSR() const { return IsSplitCSR; }
334 void setIsSplitCSR(bool s) { IsSplitCSR = s; }
335
336 void setLocalStackSize(uint64_t Size) { LocalStackSize = Size; }
337 uint64_t getLocalStackSize() const { return LocalStackSize; }
338
339 void setOutliningStyle(const std::string &Style) { OutliningStyle = Style; }
340 std::optional<std::string> getOutliningStyle() const {
341 return OutliningStyle;
342 }
343
344 void setCalleeSavedStackSize(unsigned Size) {
345 CalleeSavedStackSize = Size;
346 HasCalleeSavedStackSize = true;
347 }
348
349 // When CalleeSavedStackSize has not been set (for example when
350 // some MachineIR pass is run in isolation), then recalculate
351 // the CalleeSavedStackSize directly from the CalleeSavedInfo.
352 // Note: This information can only be recalculated after PEI
353 // has assigned offsets to the callee save objects.
354 unsigned getCalleeSavedStackSize(const MachineFrameInfo &MFI) const {
355 bool ValidateCalleeSavedStackSize = false;
356
357#ifndef NDEBUG
358 // Make sure the calculated size derived from the CalleeSavedInfo
359 // equals the cached size that was calculated elsewhere (e.g. in
360 // determineCalleeSaves).
361 ValidateCalleeSavedStackSize = HasCalleeSavedStackSize;
362#endif
363
364 if (!HasCalleeSavedStackSize || ValidateCalleeSavedStackSize) {
365 assert(MFI.isCalleeSavedInfoValid() && "CalleeSavedInfo not calculated");
366 if (MFI.getCalleeSavedInfo().empty())
367 return 0;
368
369 int64_t MinOffset = std::numeric_limits<int64_t>::max();
370 int64_t MaxOffset = std::numeric_limits<int64_t>::min();
371 for (const auto &Info : MFI.getCalleeSavedInfo()) {
372 int FrameIdx = Info.getFrameIdx();
373 if (MFI.getStackID(ObjectIdx: FrameIdx) != TargetStackID::Default)
374 continue;
375 int64_t Offset = MFI.getObjectOffset(ObjectIdx: FrameIdx);
376 int64_t ObjSize = MFI.getObjectSize(ObjectIdx: FrameIdx);
377 MinOffset = std::min<int64_t>(a: Offset, b: MinOffset);
378 MaxOffset = std::max<int64_t>(a: Offset + ObjSize, b: MaxOffset);
379 }
380
381 if (SwiftAsyncContextFrameIdx != std::numeric_limits<int>::max()) {
382 int64_t Offset = MFI.getObjectOffset(ObjectIdx: getSwiftAsyncContextFrameIdx());
383 int64_t ObjSize = MFI.getObjectSize(ObjectIdx: getSwiftAsyncContextFrameIdx());
384 MinOffset = std::min<int64_t>(a: Offset, b: MinOffset);
385 MaxOffset = std::max<int64_t>(a: Offset + ObjSize, b: MaxOffset);
386 }
387
388 if (StackHazardCSRSlotIndex != std::numeric_limits<int>::max()) {
389 int64_t Offset = MFI.getObjectOffset(ObjectIdx: StackHazardCSRSlotIndex);
390 int64_t ObjSize = MFI.getObjectSize(ObjectIdx: StackHazardCSRSlotIndex);
391 MinOffset = std::min<int64_t>(a: Offset, b: MinOffset);
392 MaxOffset = std::max<int64_t>(a: Offset + ObjSize, b: MaxOffset);
393 }
394
395 unsigned Size = alignTo(Value: MaxOffset - MinOffset, Align: 16);
396 assert((!HasCalleeSavedStackSize || getCalleeSavedStackSize() == Size) &&
397 "Invalid size calculated for callee saves");
398 return Size;
399 }
400
401 return getCalleeSavedStackSize();
402 }
403
404 unsigned getCalleeSavedStackSize() const {
405 assert(HasCalleeSavedStackSize &&
406 "CalleeSavedStackSize has not been calculated");
407 return CalleeSavedStackSize;
408 }
409
410 // Saves the CalleeSavedStackSize for SVE vectors in 'scalable bytes'
411 void setSVECalleeSavedStackSize(unsigned ZPR, unsigned PPR) {
412 assert(isAligned(Align(16), ZPR) && isAligned(Align(16), PPR) &&
413 "expected SVE callee-save sizes to be aligned to 16-bytes");
414 ZPRCalleeSavedStackSize = ZPR;
415 PPRCalleeSavedStackSize = PPR;
416 HasSVECalleeSavedStackSize = true;
417 }
418 unsigned getZPRCalleeSavedStackSize() const {
419 assert(HasSVECalleeSavedStackSize &&
420 "ZPRCalleeSavedStackSize has not been calculated");
421 return ZPRCalleeSavedStackSize;
422 }
423 unsigned getPPRCalleeSavedStackSize() const {
424 assert(HasSVECalleeSavedStackSize &&
425 "PPRCalleeSavedStackSize has not been calculated");
426 return PPRCalleeSavedStackSize;
427 }
428
429 unsigned getSVECalleeSavedStackSize() const {
430 assert(!hasSplitSVEObjects() &&
431 "ZPRs and PPRs are split. Use get[ZPR|PPR]CalleeSavedStackSize()");
432 return getZPRCalleeSavedStackSize() + getPPRCalleeSavedStackSize();
433 }
434
435 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; }
436 unsigned getNumLocalDynamicTLSAccesses() const {
437 return NumLocalDynamicTLSAccesses;
438 }
439
440 bool isStackHazardIncludedInCalleeSaveArea() const {
441 return hasStackHazardSlotIndex() && !hasSplitSVEObjects();
442 }
443
444 std::optional<bool> hasRedZone() const { return HasRedZone; }
445 void setHasRedZone(bool s) { HasRedZone = s; }
446
447 int getVarArgsStackIndex() const { return VarArgsStackIndex; }
448 void setVarArgsStackIndex(int Index) { VarArgsStackIndex = Index; }
449
450 unsigned getVarArgsStackOffset() const { return VarArgsStackOffset; }
451 void setVarArgsStackOffset(unsigned Offset) { VarArgsStackOffset = Offset; }
452
453 int getVarArgsGPRIndex() const { return VarArgsGPRIndex; }
454 void setVarArgsGPRIndex(int Index) { VarArgsGPRIndex = Index; }
455
456 unsigned getVarArgsGPRSize() const { return VarArgsGPRSize; }
457 void setVarArgsGPRSize(unsigned Size) { VarArgsGPRSize = Size; }
458
459 int getVarArgsFPRIndex() const { return VarArgsFPRIndex; }
460 void setVarArgsFPRIndex(int Index) { VarArgsFPRIndex = Index; }
461
462 unsigned getVarArgsFPRSize() const { return VarArgsFPRSize; }
463 void setVarArgsFPRSize(unsigned Size) { VarArgsFPRSize = Size; }
464
465 bool hasStackHazardSlotIndex() const {
466 return StackHazardSlotIndex != std::numeric_limits<int>::max();
467 }
468 int getStackHazardSlotIndex() const { return StackHazardSlotIndex; }
469 void setStackHazardSlotIndex(int Index) {
470 assert(StackHazardSlotIndex == std::numeric_limits<int>::max());
471 StackHazardSlotIndex = Index;
472 }
473 int getStackHazardCSRSlotIndex() const { return StackHazardCSRSlotIndex; }
474 void setStackHazardCSRSlotIndex(int Index) {
475 assert(StackHazardCSRSlotIndex == std::numeric_limits<int>::max());
476 StackHazardCSRSlotIndex = Index;
477 }
478
479 bool hasSplitSVEObjects() const { return SplitSVEObjects; }
480 void setSplitSVEObjects(bool s) { SplitSVEObjects = s; }
481
482 bool hasSVE_AAPCS(const MachineFunction &MF) const {
483 return hasSplitSVEObjects() || isSVECC() ||
484 MF.getFunction().getCallingConv() ==
485 CallingConv::AArch64_SVE_VectorCall;
486 }
487
488 SMEAttrs getSMEFnAttrs() const { return SMEFnAttrs; }
489
490 unsigned getSRetReturnReg() const { return SRetReturnReg; }
491 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
492
493 unsigned getJumpTableEntrySize(int Idx) const {
494 return JumpTableEntryInfo[Idx].first;
495 }
496 MCSymbol *getJumpTableEntryPCRelSymbol(int Idx) const {
497 return JumpTableEntryInfo[Idx].second;
498 }
499 void setJumpTableEntryInfo(int Idx, unsigned Size, MCSymbol *PCRelSym) {
500 if ((unsigned)Idx >= JumpTableEntryInfo.size())
501 JumpTableEntryInfo.resize(N: Idx+1);
502 JumpTableEntryInfo[Idx] = std::make_pair(x&: Size, y&: PCRelSym);
503 }
504
505 using SetOfInstructions = SmallPtrSet<const MachineInstr *, 16>;
506
507 const SetOfInstructions &getLOHRelated() const { return LOHRelated; }
508
509 // Shortcuts for LOH related types.
510 class MILOHDirective {
511 MCLOHType Kind;
512
513 /// Arguments of this directive. Order matters.
514 SmallVector<const MachineInstr *, 3> Args;
515
516 public:
517 using LOHArgs = ArrayRef<const MachineInstr *>;
518
519 MILOHDirective(MCLOHType Kind, LOHArgs Args)
520 : Kind(Kind), Args(Args.begin(), Args.end()) {
521 assert(isValidMCLOHType(Kind) && "Invalid LOH directive type!");
522 }
523
524 MCLOHType getKind() const { return Kind; }
525 LOHArgs getArgs() const { return Args; }
526 };
527
528 using MILOHArgs = MILOHDirective::LOHArgs;
529 using MILOHContainer = SmallVector<MILOHDirective, 32>;
530
531 const MILOHContainer &getLOHContainer() const { return LOHContainerSet; }
532
533 /// Add a LOH directive of this @p Kind and this @p Args.
534 void addLOHDirective(MCLOHType Kind, MILOHArgs Args) {
535 LOHContainerSet.push_back(Elt: MILOHDirective(Kind, Args));
536 LOHRelated.insert_range(R&: Args);
537 }
538
539 size_t
540 clearLinkerOptimizationHints(const SmallPtrSetImpl<MachineInstr *> &MIs) {
541 size_t InitialSize = LOHContainerSet.size();
542 erase_if(C&: LOHContainerSet, P: [&](const auto &D) {
543 return any_of(D.getArgs(), [&](auto *Arg) { return MIs.contains(Ptr: Arg); });
544 });
545 // In theory there could be an LOH with one label in MIs and another label
546 // outside MIs, however we don't know if the label outside MIs is used in
547 // any other LOHs, so we can't remove them from LOHRelated. In that case, we
548 // might produce a few extra labels, but it won't break anything.
549 LOHRelated.remove_if(P: [&](auto *MI) { return MIs.contains(Ptr: MI); });
550 return InitialSize - LOHContainerSet.size();
551 };
552
553 SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() {
554 return ForwardedMustTailRegParms;
555 }
556
557 std::optional<int> getTaggedBasePointerIndex() const {
558 return TaggedBasePointerIndex;
559 }
560 void setTaggedBasePointerIndex(int Index) { TaggedBasePointerIndex = Index; }
561
562 unsigned getTaggedBasePointerOffset() const {
563 return TaggedBasePointerOffset;
564 }
565 void setTaggedBasePointerOffset(unsigned Offset) {
566 TaggedBasePointerOffset = Offset;
567 }
568
569 int getCalleeSaveBaseToFrameRecordOffset() const {
570 return CalleeSaveBaseToFrameRecordOffset;
571 }
572 void setCalleeSaveBaseToFrameRecordOffset(int Offset) {
573 CalleeSaveBaseToFrameRecordOffset = Offset;
574 }
575
576 static bool shouldSignReturnAddress(SignReturnAddress Condition,
577 bool IsLRSpilled);
578
579 bool shouldSignReturnAddress(const MachineFunction &MF) const;
580
581 SignReturnAddress getSignReturnAddressCondition() const {
582 return SignCondition;
583 }
584
585 bool needsShadowCallStackPrologueEpilogue(MachineFunction &MF) const;
586
587 bool shouldSignWithBKey() const { return SignWithBKey; }
588
589 bool hasELFSignedGOT() const { return HasELFSignedGOT; }
590
591 MCSymbol *getSigningInstrLabel() const { return SignInstrLabel; }
592 void setSigningInstrLabel(MCSymbol *Label) { SignInstrLabel = Label; }
593
594 bool isMTETagged() const { return IsMTETagged; }
595
596 bool shouldHardenSignReturnAddress() const {
597 return SignReturnAddressHardening != SignReturnAddressHardeningKind::None;
598 }
599
600 bool branchTargetEnforcement() const { return BranchTargetEnforcement; }
601
602 bool branchProtectionPAuthLR() const { return BranchProtectionPAuthLR; }
603
604 void setHasSwiftAsyncContext(bool HasContext) {
605 HasSwiftAsyncContext = HasContext;
606 }
607 bool hasSwiftAsyncContext() const { return HasSwiftAsyncContext; }
608
609 void setHasWinCallToCalleePopFunction(bool Has) {
610 HasWinCallToCalleePopFunction = Has;
611 }
612 bool hasWinCallToCalleePopFunction() const {
613 return HasWinCallToCalleePopFunction;
614 }
615
616 void setSwiftAsyncContextFrameIdx(int FI) {
617 SwiftAsyncContextFrameIdx = FI;
618 }
619 int getSwiftAsyncContextFrameIdx() const { return SwiftAsyncContextFrameIdx; }
620
621 bool needsDwarfUnwindInfo(const MachineFunction &MF) const;
622 bool needsAsyncDwarfUnwindInfo(const MachineFunction &MF) const;
623
624 bool hasStreamingModeChanges() const { return HasStreamingModeChanges; }
625 void setHasStreamingModeChanges(bool HasChanges) {
626 HasStreamingModeChanges = HasChanges;
627 }
628
629 bool hasStackProbing() const { return StackProbeSize != 0; }
630
631 int64_t getStackProbeSize() const { return StackProbeSize; }
632
633private:
634 // Hold the lists of LOHs.
635 MILOHContainer LOHContainerSet;
636 SetOfInstructions LOHRelated;
637
638 SmallVector<std::pair<unsigned, MCSymbol *>, 2> JumpTableEntryInfo;
639};
640
641namespace yaml {
642struct AArch64FunctionInfo final : public yaml::MachineFunctionInfo {
643 std::optional<bool> HasRedZone;
644 std::optional<uint64_t> StackSizeZPR;
645 std::optional<uint64_t> StackSizePPR;
646 std::optional<bool> HasStackFrame;
647 std::optional<bool> HasStreamingModeChanges;
648
649 AArch64FunctionInfo() = default;
650 AArch64FunctionInfo(const llvm::AArch64FunctionInfo &MFI);
651
652 void mappingImpl(yaml::IO &YamlIO) override;
653 ~AArch64FunctionInfo() override = default;
654};
655
656template <> struct MappingTraits<AArch64FunctionInfo> {
657 static void mapping(IO &YamlIO, AArch64FunctionInfo &MFI) {
658 YamlIO.mapOptional(Key: "hasRedZone", Val&: MFI.HasRedZone);
659 YamlIO.mapOptional(Key: "stackSizeZPR", Val&: MFI.StackSizeZPR);
660 YamlIO.mapOptional(Key: "stackSizePPR", Val&: MFI.StackSizePPR);
661 YamlIO.mapOptional(Key: "hasStackFrame", Val&: MFI.HasStackFrame);
662 YamlIO.mapOptional(Key: "hasStreamingModeChanges", Val&: MFI.HasStreamingModeChanges);
663 }
664};
665
666} // end namespace yaml
667
668} // end namespace llvm
669
670#endif // LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
671