LLVM  13.0.0git
MachineFrameInfo.h
Go to the documentation of this file.
1 //===-- CodeGen/MachineFrameInfo.h - Abstract Stack Frame Rep. --*- 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 // The file defines the MachineFrameInfo class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H
14 #define LLVM_CODEGEN_MACHINEFRAMEINFO_H
15 
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/CodeGen/Register.h"
18 #include "llvm/Support/Alignment.h"
19 #include "llvm/Support/DataTypes.h"
20 #include <cassert>
21 #include <vector>
22 
23 namespace llvm {
24 class raw_ostream;
25 class MachineFunction;
26 class MachineBasicBlock;
27 class BitVector;
28 class AllocaInst;
29 
30 /// The CalleeSavedInfo class tracks the information need to locate where a
31 /// callee saved register is in the current frame.
32 /// Callee saved reg can also be saved to a different register rather than
33 /// on the stack by setting DstReg instead of FrameIdx.
35  Register Reg;
36  union {
37  int FrameIdx;
38  unsigned DstReg;
39  };
40  /// Flag indicating whether the register is actually restored in the epilog.
41  /// In most cases, if a register is saved, it is also restored. There are
42  /// some situations, though, when this is not the case. For example, the
43  /// LR register on ARM is usually saved, but on exit from the function its
44  /// saved value may be loaded directly into PC. Since liveness tracking of
45  /// physical registers treats callee-saved registers are live outside of
46  /// the function, LR would be treated as live-on-exit, even though in these
47  /// scenarios it is not. This flag is added to indicate that the saved
48  /// register described by this object is not restored in the epilog.
49  /// The long-term solution is to model the liveness of callee-saved registers
50  /// by implicit uses on the return instructions, however, the required
51  /// changes in the ARM backend would be quite extensive.
52  bool Restored;
53  /// Flag indicating whether the register is spilled to stack or another
54  /// register.
55  bool SpilledToReg;
56 
57 public:
58  explicit CalleeSavedInfo(unsigned R, int FI = 0)
59  : Reg(R), FrameIdx(FI), Restored(true), SpilledToReg(false) {}
60 
61  // Accessors.
62  Register getReg() const { return Reg; }
63  int getFrameIdx() const { return FrameIdx; }
64  unsigned getDstReg() const { return DstReg; }
65  void setFrameIdx(int FI) {
66  FrameIdx = FI;
67  SpilledToReg = false;
68  }
69  void setDstReg(Register SpillReg) {
70  DstReg = SpillReg;
71  SpilledToReg = true;
72  }
73  bool isRestored() const { return Restored; }
74  void setRestored(bool R) { Restored = R; }
75  bool isSpilledToReg() const { return SpilledToReg; }
76 };
77 
78 /// The MachineFrameInfo class represents an abstract stack frame until
79 /// prolog/epilog code is inserted. This class is key to allowing stack frame
80 /// representation optimizations, such as frame pointer elimination. It also
81 /// allows more mundane (but still important) optimizations, such as reordering
82 /// of abstract objects on the stack frame.
83 ///
84 /// To support this, the class assigns unique integer identifiers to stack
85 /// objects requested clients. These identifiers are negative integers for
86 /// fixed stack objects (such as arguments passed on the stack) or nonnegative
87 /// for objects that may be reordered. Instructions which refer to stack
88 /// objects use a special MO_FrameIndex operand to represent these frame
89 /// indexes.
90 ///
91 /// Because this class keeps track of all references to the stack frame, it
92 /// knows when a variable sized object is allocated on the stack. This is the
93 /// sole condition which prevents frame pointer elimination, which is an
94 /// important optimization on register-poor architectures. Because original
95 /// variable sized alloca's in the source program are the only source of
96 /// variable sized stack objects, it is safe to decide whether there will be
97 /// any variable sized objects before all stack objects are known (for
98 /// example, register allocator spill code never needs variable sized
99 /// objects).
100 ///
101 /// When prolog/epilog code emission is performed, the final stack frame is
102 /// built and the machine instructions are modified to refer to the actual
103 /// stack offsets of the object, eliminating all MO_FrameIndex operands from
104 /// the program.
105 ///
106 /// Abstract Stack Frame Information
108 public:
109  /// Stack Smashing Protection (SSP) rules require that vulnerable stack
110  /// allocations are located close the stack protector.
112  SSPLK_None, ///< Did not trigger a stack protector. No effect on data
113  ///< layout.
114  SSPLK_LargeArray, ///< Array or nested array >= SSP-buffer-size. Closest
115  ///< to the stack protector.
116  SSPLK_SmallArray, ///< Array or nested array < SSP-buffer-size. 2nd closest
117  ///< to the stack protector.
118  SSPLK_AddrOf ///< The address of this allocation is exposed and
119  ///< triggered protection. 3rd closest to the protector.
120  };
121 
122 private:
123  // Represent a single object allocated on the stack.
124  struct StackObject {
125  // The offset of this object from the stack pointer on entry to
126  // the function. This field has no meaning for a variable sized element.
127  int64_t SPOffset;
128 
129  // The size of this object on the stack. 0 means a variable sized object,
130  // ~0ULL means a dead object.
131  uint64_t Size;
132 
133  // The required alignment of this stack slot.
134  Align Alignment;
135 
136  // If true, the value of the stack object is set before
137  // entering the function and is not modified inside the function. By
138  // default, fixed objects are immutable unless marked otherwise.
139  bool isImmutable;
140 
141  // If true the stack object is used as spill slot. It
142  // cannot alias any other memory objects.
143  bool isSpillSlot;
144 
145  /// If true, this stack slot is used to spill a value (could be deopt
146  /// and/or GC related) over a statepoint. We know that the address of the
147  /// slot can't alias any LLVM IR value. This is very similar to a Spill
148  /// Slot, but is created by statepoint lowering is SelectionDAG, not the
149  /// register allocator.
150  bool isStatepointSpillSlot = false;
151 
152  /// Identifier for stack memory type analagous to address space. If this is
153  /// non-0, the meaning is target defined. Offsets cannot be directly
154  /// compared between objects with different stack IDs. The object may not
155  /// necessarily reside in the same contiguous memory block as other stack
156  /// objects. Objects with differing stack IDs should not be merged or
157  /// replaced substituted for each other.
158  //
159  /// It is assumed a target uses consecutive, increasing stack IDs starting
160  /// from 1.
161  uint8_t StackID;
162 
163  /// If this stack object is originated from an Alloca instruction
164  /// this value saves the original IR allocation. Can be NULL.
165  const AllocaInst *Alloca;
166 
167  // If true, the object was mapped into the local frame
168  // block and doesn't need additional handling for allocation beyond that.
169  bool PreAllocated = false;
170 
171  // If true, an LLVM IR value might point to this object.
172  // Normally, spill slots and fixed-offset objects don't alias IR-accessible
173  // objects, but there are exceptions (on PowerPC, for example, some byval
174  // arguments have ABI-prescribed offsets).
175  bool isAliased;
176 
177  /// If true, the object has been zero-extended.
178  bool isZExt = false;
179 
180  /// If true, the object has been zero-extended.
181  bool isSExt = false;
182 
183  uint8_t SSPLayout;
184 
185  StackObject(uint64_t Size, Align Alignment, int64_t SPOffset,
186  bool IsImmutable, bool IsSpillSlot, const AllocaInst *Alloca,
187  bool IsAliased, uint8_t StackID = 0)
188  : SPOffset(SPOffset), Size(Size), Alignment(Alignment),
189  isImmutable(IsImmutable), isSpillSlot(IsSpillSlot), StackID(StackID),
190  Alloca(Alloca), isAliased(IsAliased), SSPLayout(SSPLK_None) {}
191  };
192 
193  /// The alignment of the stack.
194  Align StackAlignment;
195 
196  /// Can the stack be realigned. This can be false if the target does not
197  /// support stack realignment, or if the user asks us not to realign the
198  /// stack. In this situation, overaligned allocas are all treated as dynamic
199  /// allocations and the target must handle them as part of DYNAMIC_STACKALLOC
200  /// lowering. All non-alloca stack objects have their alignment clamped to the
201  /// base ABI stack alignment.
202  /// FIXME: There is room for improvement in this case, in terms of
203  /// grouping overaligned allocas into a "secondary stack frame" and
204  /// then only use a single alloca to allocate this frame and only a
205  /// single virtual register to access it. Currently, without such an
206  /// optimization, each such alloca gets its own dynamic realignment.
207  bool StackRealignable;
208 
209  /// Whether the function has the \c alignstack attribute.
210  bool ForcedRealign;
211 
212  /// The list of stack objects allocated.
213  std::vector<StackObject> Objects;
214 
215  /// This contains the number of fixed objects contained on
216  /// the stack. Because fixed objects are stored at a negative index in the
217  /// Objects list, this is also the index to the 0th object in the list.
218  unsigned NumFixedObjects = 0;
219 
220  /// This boolean keeps track of whether any variable
221  /// sized objects have been allocated yet.
222  bool HasVarSizedObjects = false;
223 
224  /// This boolean keeps track of whether there is a call
225  /// to builtin \@llvm.frameaddress.
226  bool FrameAddressTaken = false;
227 
228  /// This boolean keeps track of whether there is a call
229  /// to builtin \@llvm.returnaddress.
230  bool ReturnAddressTaken = false;
231 
232  /// This boolean keeps track of whether there is a call
233  /// to builtin \@llvm.experimental.stackmap.
234  bool HasStackMap = false;
235 
236  /// This boolean keeps track of whether there is a call
237  /// to builtin \@llvm.experimental.patchpoint.
238  bool HasPatchPoint = false;
239 
240  /// The prolog/epilog code inserter calculates the final stack
241  /// offsets for all of the fixed size objects, updating the Objects list
242  /// above. It then updates StackSize to contain the number of bytes that need
243  /// to be allocated on entry to the function.
244  uint64_t StackSize = 0;
245 
246  /// The amount that a frame offset needs to be adjusted to
247  /// have the actual offset from the stack/frame pointer. The exact usage of
248  /// this is target-dependent, but it is typically used to adjust between
249  /// SP-relative and FP-relative offsets. E.G., if objects are accessed via
250  /// SP then OffsetAdjustment is zero; if FP is used, OffsetAdjustment is set
251  /// to the distance between the initial SP and the value in FP. For many
252  /// targets, this value is only used when generating debug info (via
253  /// TargetRegisterInfo::getFrameIndexReference); when generating code, the
254  /// corresponding adjustments are performed directly.
255  int OffsetAdjustment = 0;
256 
257  /// The prolog/epilog code inserter may process objects that require greater
258  /// alignment than the default alignment the target provides.
259  /// To handle this, MaxAlignment is set to the maximum alignment
260  /// needed by the objects on the current frame. If this is greater than the
261  /// native alignment maintained by the compiler, dynamic alignment code will
262  /// be needed.
263  ///
264  Align MaxAlignment;
265 
266  /// Set to true if this function adjusts the stack -- e.g.,
267  /// when calling another function. This is only valid during and after
268  /// prolog/epilog code insertion.
269  bool AdjustsStack = false;
270 
271  /// Set to true if this function has any function calls.
272  bool HasCalls = false;
273 
274  /// The frame index for the stack protector.
275  int StackProtectorIdx = -1;
276 
277  /// The frame index for the function context. Used for SjLj exceptions.
278  int FunctionContextIdx = -1;
279 
280  /// This contains the size of the largest call frame if the target uses frame
281  /// setup/destroy pseudo instructions (as defined in the TargetFrameInfo
282  /// class). This information is important for frame pointer elimination.
283  /// It is only valid during and after prolog/epilog code insertion.
284  unsigned MaxCallFrameSize = ~0u;
285 
286  /// The number of bytes of callee saved registers that the target wants to
287  /// report for the current function in the CodeView S_FRAMEPROC record.
288  unsigned CVBytesOfCalleeSavedRegisters = 0;
289 
290  /// The prolog/epilog code inserter fills in this vector with each
291  /// callee saved register saved in either the frame or a different
292  /// register. Beyond its use by the prolog/ epilog code inserter,
293  /// this data is used for debug info and exception handling.
294  std::vector<CalleeSavedInfo> CSInfo;
295 
296  /// Has CSInfo been set yet?
297  bool CSIValid = false;
298 
299  /// References to frame indices which are mapped
300  /// into the local frame allocation block. <FrameIdx, LocalOffset>
301  SmallVector<std::pair<int, int64_t>, 32> LocalFrameObjects;
302 
303  /// Size of the pre-allocated local frame block.
304  int64_t LocalFrameSize = 0;
305 
306  /// Required alignment of the local object blob, which is the strictest
307  /// alignment of any object in it.
308  Align LocalFrameMaxAlign;
309 
310  /// Whether the local object blob needs to be allocated together. If not,
311  /// PEI should ignore the isPreAllocated flags on the stack objects and
312  /// just allocate them normally.
313  bool UseLocalStackAllocationBlock = false;
314 
315  /// True if the function dynamically adjusts the stack pointer through some
316  /// opaque mechanism like inline assembly or Win32 EH.
317  bool HasOpaqueSPAdjustment = false;
318 
319  /// True if the function contains operations which will lower down to
320  /// instructions which manipulate the stack pointer.
321  bool HasCopyImplyingStackAdjustment = false;
322 
323  /// True if the function contains a call to the llvm.vastart intrinsic.
324  bool HasVAStart = false;
325 
326  /// True if this is a varargs function that contains a musttail call.
327  bool HasMustTailInVarArgFunc = false;
328 
329  /// True if this function contains a tail call. If so immutable objects like
330  /// function arguments are no longer so. A tail call *can* override fixed
331  /// stack objects like arguments so we can't treat them as immutable.
332  bool HasTailCall = false;
333 
334  /// Not null, if shrink-wrapping found a better place for the prologue.
335  MachineBasicBlock *Save = nullptr;
336  /// Not null, if shrink-wrapping found a better place for the epilogue.
337  MachineBasicBlock *Restore = nullptr;
338 
339 public:
340  explicit MachineFrameInfo(unsigned StackAlignment, bool StackRealignable,
341  bool ForcedRealign)
342  : StackAlignment(assumeAligned(StackAlignment)),
343  StackRealignable(StackRealignable), ForcedRealign(ForcedRealign) {}
344 
345  /// Return true if there are any stack objects in this function.
346  bool hasStackObjects() const { return !Objects.empty(); }
347 
348  /// This method may be called any time after instruction
349  /// selection is complete to determine if the stack frame for this function
350  /// contains any variable sized objects.
351  bool hasVarSizedObjects() const { return HasVarSizedObjects; }
352 
353  /// Return the index for the stack protector object.
354  int getStackProtectorIndex() const { return StackProtectorIdx; }
355  void setStackProtectorIndex(int I) { StackProtectorIdx = I; }
356  bool hasStackProtectorIndex() const { return StackProtectorIdx != -1; }
357 
358  /// Return the index for the function context object.
359  /// This object is used for SjLj exceptions.
360  int getFunctionContextIndex() const { return FunctionContextIdx; }
361  void setFunctionContextIndex(int I) { FunctionContextIdx = I; }
362 
363  /// This method may be called any time after instruction
364  /// selection is complete to determine if there is a call to
365  /// \@llvm.frameaddress in this function.
366  bool isFrameAddressTaken() const { return FrameAddressTaken; }
367  void setFrameAddressIsTaken(bool T) { FrameAddressTaken = T; }
368 
369  /// This method may be called any time after
370  /// instruction selection is complete to determine if there is a call to
371  /// \@llvm.returnaddress in this function.
372  bool isReturnAddressTaken() const { return ReturnAddressTaken; }
373  void setReturnAddressIsTaken(bool s) { ReturnAddressTaken = s; }
374 
375  /// This method may be called any time after instruction
376  /// selection is complete to determine if there is a call to builtin
377  /// \@llvm.experimental.stackmap.
378  bool hasStackMap() const { return HasStackMap; }
379  void setHasStackMap(bool s = true) { HasStackMap = s; }
380 
381  /// This method may be called any time after instruction
382  /// selection is complete to determine if there is a call to builtin
383  /// \@llvm.experimental.patchpoint.
384  bool hasPatchPoint() const { return HasPatchPoint; }
385  void setHasPatchPoint(bool s = true) { HasPatchPoint = s; }
386 
387  /// Return the minimum frame object index.
388  int getObjectIndexBegin() const { return -NumFixedObjects; }
389 
390  /// Return one past the maximum frame object index.
391  int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; }
392 
393  /// Return the number of fixed objects.
394  unsigned getNumFixedObjects() const { return NumFixedObjects; }
395 
396  /// Return the number of objects.
397  unsigned getNumObjects() const { return Objects.size(); }
398 
399  /// Map a frame index into the local object block
400  void mapLocalFrameObject(int ObjectIndex, int64_t Offset) {
401  LocalFrameObjects.push_back(std::pair<int, int64_t>(ObjectIndex, Offset));
402  Objects[ObjectIndex + NumFixedObjects].PreAllocated = true;
403  }
404 
405  /// Get the local offset mapping for a for an object.
406  std::pair<int, int64_t> getLocalFrameObjectMap(int i) const {
407  assert (i >= 0 && (unsigned)i < LocalFrameObjects.size() &&
408  "Invalid local object reference!");
409  return LocalFrameObjects[i];
410  }
411 
412  /// Return the number of objects allocated into the local object block.
413  int64_t getLocalFrameObjectCount() const { return LocalFrameObjects.size(); }
414 
415  /// Set the size of the local object blob.
416  void setLocalFrameSize(int64_t sz) { LocalFrameSize = sz; }
417 
418  /// Get the size of the local object blob.
419  int64_t getLocalFrameSize() const { return LocalFrameSize; }
420 
421  /// Required alignment of the local object blob,
422  /// which is the strictest alignment of any object in it.
423  void setLocalFrameMaxAlign(Align Alignment) {
424  LocalFrameMaxAlign = Alignment;
425  }
426 
427  /// Return the required alignment of the local object blob.
428  Align getLocalFrameMaxAlign() const { return LocalFrameMaxAlign; }
429 
430  /// Get whether the local allocation blob should be allocated together or
431  /// let PEI allocate the locals in it directly.
433  return UseLocalStackAllocationBlock;
434  }
435 
436  /// setUseLocalStackAllocationBlock - Set whether the local allocation blob
437  /// should be allocated together or let PEI allocate the locals in it
438  /// directly.
440  UseLocalStackAllocationBlock = v;
441  }
442 
443  /// Return true if the object was pre-allocated into the local block.
444  bool isObjectPreAllocated(int ObjectIdx) const {
445  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
446  "Invalid Object Idx!");
447  return Objects[ObjectIdx+NumFixedObjects].PreAllocated;
448  }
449 
450  /// Return the size of the specified object.
451  int64_t getObjectSize(int ObjectIdx) const {
452  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
453  "Invalid Object Idx!");
454  return Objects[ObjectIdx+NumFixedObjects].Size;
455  }
456 
457  /// Change the size of the specified stack object.
458  void setObjectSize(int ObjectIdx, int64_t Size) {
459  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
460  "Invalid Object Idx!");
461  Objects[ObjectIdx+NumFixedObjects].Size = Size;
462  }
463 
464  LLVM_ATTRIBUTE_DEPRECATED(inline unsigned getObjectAlignment(int ObjectIdx)
465  const,
466  "Use getObjectAlign instead") {
467  return getObjectAlign(ObjectIdx).value();
468  }
469 
470  /// Return the alignment of the specified stack object.
471  Align getObjectAlign(int ObjectIdx) const {
472  assert(unsigned(ObjectIdx + NumFixedObjects) < Objects.size() &&
473  "Invalid Object Idx!");
474  return Objects[ObjectIdx + NumFixedObjects].Alignment;
475  }
476 
477  /// setObjectAlignment - Change the alignment of the specified stack object.
478  void setObjectAlignment(int ObjectIdx, Align Alignment) {
479  assert(unsigned(ObjectIdx + NumFixedObjects) < Objects.size() &&
480  "Invalid Object Idx!");
481  Objects[ObjectIdx + NumFixedObjects].Alignment = Alignment;
482 
483  // Only ensure max alignment for the default stack.
484  if (getStackID(ObjectIdx) == 0)
485  ensureMaxAlignment(Alignment);
486  }
487 
489  unsigned Align),
490  "Use the version that takes Align instead") {
492  }
493 
494  /// Return the underlying Alloca of the specified
495  /// stack object if it exists. Returns 0 if none exists.
496  const AllocaInst* getObjectAllocation(int ObjectIdx) const {
497  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
498  "Invalid Object Idx!");
499  return Objects[ObjectIdx+NumFixedObjects].Alloca;
500  }
501 
502  /// Return the assigned stack offset of the specified object
503  /// from the incoming stack pointer.
504  int64_t getObjectOffset(int ObjectIdx) const {
505  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
506  "Invalid Object Idx!");
507  assert(!isDeadObjectIndex(ObjectIdx) &&
508  "Getting frame offset for a dead object?");
509  return Objects[ObjectIdx+NumFixedObjects].SPOffset;
510  }
511 
512  bool isObjectZExt(int ObjectIdx) const {
513  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
514  "Invalid Object Idx!");
515  return Objects[ObjectIdx+NumFixedObjects].isZExt;
516  }
517 
518  void setObjectZExt(int ObjectIdx, bool IsZExt) {
519  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
520  "Invalid Object Idx!");
521  Objects[ObjectIdx+NumFixedObjects].isZExt = IsZExt;
522  }
523 
524  bool isObjectSExt(int ObjectIdx) const {
525  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
526  "Invalid Object Idx!");
527  return Objects[ObjectIdx+NumFixedObjects].isSExt;
528  }
529 
530  void setObjectSExt(int ObjectIdx, bool IsSExt) {
531  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
532  "Invalid Object Idx!");
533  Objects[ObjectIdx+NumFixedObjects].isSExt = IsSExt;
534  }
535 
536  /// Set the stack frame offset of the specified object. The
537  /// offset is relative to the stack pointer on entry to the function.
538  void setObjectOffset(int ObjectIdx, int64_t SPOffset) {
539  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
540  "Invalid Object Idx!");
541  assert(!isDeadObjectIndex(ObjectIdx) &&
542  "Setting frame offset for a dead object?");
543  Objects[ObjectIdx+NumFixedObjects].SPOffset = SPOffset;
544  }
545 
546  SSPLayoutKind getObjectSSPLayout(int ObjectIdx) const {
547  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
548  "Invalid Object Idx!");
549  return (SSPLayoutKind)Objects[ObjectIdx+NumFixedObjects].SSPLayout;
550  }
551 
552  void setObjectSSPLayout(int ObjectIdx, SSPLayoutKind Kind) {
553  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
554  "Invalid Object Idx!");
555  assert(!isDeadObjectIndex(ObjectIdx) &&
556  "Setting SSP layout for a dead object?");
557  Objects[ObjectIdx+NumFixedObjects].SSPLayout = Kind;
558  }
559 
560  /// Return the number of bytes that must be allocated to hold
561  /// all of the fixed size frame objects. This is only valid after
562  /// Prolog/Epilog code insertion has finalized the stack frame layout.
563  uint64_t getStackSize() const { return StackSize; }
564 
565  /// Set the size of the stack.
566  void setStackSize(uint64_t Size) { StackSize = Size; }
567 
568  /// Estimate and return the size of the stack frame.
569  uint64_t estimateStackSize(const MachineFunction &MF) const;
570 
571  /// Return the correction for frame offsets.
572  int getOffsetAdjustment() const { return OffsetAdjustment; }
573 
574  /// Set the correction for frame offsets.
575  void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; }
576 
577  /// Return the alignment in bytes that this function must be aligned to,
578  /// which is greater than the default stack alignment provided by the target.
579  LLVM_ATTRIBUTE_DEPRECATED(unsigned getMaxAlignment() const,
580  "Use getMaxAlign instead") {
581  return MaxAlignment.value();
582  }
583  /// Return the alignment in bytes that this function must be aligned to,
584  /// which is greater than the default stack alignment provided by the target.
585  Align getMaxAlign() const { return MaxAlignment; }
586 
587  /// Make sure the function is at least Align bytes aligned.
588  void ensureMaxAlignment(Align Alignment);
589 
591  "Use the version that uses Align instead") {
593  }
594 
595  /// Return true if this function adjusts the stack -- e.g.,
596  /// when calling another function. This is only valid during and after
597  /// prolog/epilog code insertion.
598  bool adjustsStack() const { return AdjustsStack; }
599  void setAdjustsStack(bool V) { AdjustsStack = V; }
600 
601  /// Return true if the current function has any function calls.
602  bool hasCalls() const { return HasCalls; }
603  void setHasCalls(bool V) { HasCalls = V; }
604 
605  /// Returns true if the function contains opaque dynamic stack adjustments.
606  bool hasOpaqueSPAdjustment() const { return HasOpaqueSPAdjustment; }
607  void setHasOpaqueSPAdjustment(bool B) { HasOpaqueSPAdjustment = B; }
608 
609  /// Returns true if the function contains operations which will lower down to
610  /// instructions which manipulate the stack pointer.
612  return HasCopyImplyingStackAdjustment;
613  }
615  HasCopyImplyingStackAdjustment = B;
616  }
617 
618  /// Returns true if the function calls the llvm.va_start intrinsic.
619  bool hasVAStart() const { return HasVAStart; }
620  void setHasVAStart(bool B) { HasVAStart = B; }
621 
622  /// Returns true if the function is variadic and contains a musttail call.
623  bool hasMustTailInVarArgFunc() const { return HasMustTailInVarArgFunc; }
624  void setHasMustTailInVarArgFunc(bool B) { HasMustTailInVarArgFunc = B; }
625 
626  /// Returns true if the function contains a tail call.
627  bool hasTailCall() const { return HasTailCall; }
628  void setHasTailCall(bool V = true) { HasTailCall = V; }
629 
630  /// Computes the maximum size of a callframe and the AdjustsStack property.
631  /// This only works for targets defining
632  /// TargetInstrInfo::getCallFrameSetupOpcode(), getCallFrameDestroyOpcode(),
633  /// and getFrameSize().
634  /// This is usually computed by the prologue epilogue inserter but some
635  /// targets may call this to compute it earlier.
637 
638  /// Return the maximum size of a call frame that must be
639  /// allocated for an outgoing function call. This is only available if
640  /// CallFrameSetup/Destroy pseudo instructions are used by the target, and
641  /// then only during or after prolog/epilog code insertion.
642  ///
643  unsigned getMaxCallFrameSize() const {
644  // TODO: Enable this assert when targets are fixed.
645  //assert(isMaxCallFrameSizeComputed() && "MaxCallFrameSize not computed yet");
647  return 0;
648  return MaxCallFrameSize;
649  }
651  return MaxCallFrameSize != ~0u;
652  }
653  void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
654 
655  /// Returns how many bytes of callee-saved registers the target pushed in the
656  /// prologue. Only used for debug info.
658  return CVBytesOfCalleeSavedRegisters;
659  }
661  CVBytesOfCalleeSavedRegisters = S;
662  }
663 
664  /// Create a new object at a fixed location on the stack.
665  /// All fixed objects should be created before other objects are created for
666  /// efficiency. By default, fixed objects are not pointed to by LLVM IR
667  /// values. This returns an index with a negative value.
668  int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable,
669  bool isAliased = false);
670 
671  /// Create a spill slot at a fixed location on the stack.
672  /// Returns an index with a negative value.
673  int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset,
674  bool IsImmutable = false);
675 
676  /// Returns true if the specified index corresponds to a fixed stack object.
677  bool isFixedObjectIndex(int ObjectIdx) const {
678  return ObjectIdx < 0 && (ObjectIdx >= -(int)NumFixedObjects);
679  }
680 
681  /// Returns true if the specified index corresponds
682  /// to an object that might be pointed to by an LLVM IR value.
683  bool isAliasedObjectIndex(int ObjectIdx) const {
684  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
685  "Invalid Object Idx!");
686  return Objects[ObjectIdx+NumFixedObjects].isAliased;
687  }
688 
689  /// Returns true if the specified index corresponds to an immutable object.
690  bool isImmutableObjectIndex(int ObjectIdx) const {
691  // Tail calling functions can clobber their function arguments.
692  if (HasTailCall)
693  return false;
694  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
695  "Invalid Object Idx!");
696  return Objects[ObjectIdx+NumFixedObjects].isImmutable;
697  }
698 
699  /// Marks the immutability of an object.
700  void setIsImmutableObjectIndex(int ObjectIdx, bool IsImmutable) {
701  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
702  "Invalid Object Idx!");
703  Objects[ObjectIdx+NumFixedObjects].isImmutable = IsImmutable;
704  }
705 
706  /// Returns true if the specified index corresponds to a spill slot.
707  bool isSpillSlotObjectIndex(int ObjectIdx) const {
708  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
709  "Invalid Object Idx!");
710  return Objects[ObjectIdx+NumFixedObjects].isSpillSlot;
711  }
712 
713  bool isStatepointSpillSlotObjectIndex(int ObjectIdx) const {
714  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
715  "Invalid Object Idx!");
716  return Objects[ObjectIdx+NumFixedObjects].isStatepointSpillSlot;
717  }
718 
719  /// \see StackID
720  uint8_t getStackID(int ObjectIdx) const {
721  return Objects[ObjectIdx+NumFixedObjects].StackID;
722  }
723 
724  /// \see StackID
725  void setStackID(int ObjectIdx, uint8_t ID) {
726  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
727  "Invalid Object Idx!");
728  Objects[ObjectIdx+NumFixedObjects].StackID = ID;
729  // If ID > 0, MaxAlignment may now be overly conservative.
730  // If ID == 0, MaxAlignment will need to be updated separately.
731  }
732 
733  /// Returns true if the specified index corresponds to a dead object.
734  bool isDeadObjectIndex(int ObjectIdx) const {
735  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
736  "Invalid Object Idx!");
737  return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL;
738  }
739 
740  /// Returns true if the specified index corresponds to a variable sized
741  /// object.
742  bool isVariableSizedObjectIndex(int ObjectIdx) const {
743  assert(unsigned(ObjectIdx + NumFixedObjects) < Objects.size() &&
744  "Invalid Object Idx!");
745  return Objects[ObjectIdx + NumFixedObjects].Size == 0;
746  }
747 
749  assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
750  "Invalid Object Idx!");
751  Objects[ObjectIdx+NumFixedObjects].isStatepointSpillSlot = true;
752  assert(isStatepointSpillSlotObjectIndex(ObjectIdx) && "inconsistent");
753  }
754 
755  /// Create a new statically sized stack object, returning
756  /// a nonnegative identifier to represent it.
757  int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot,
758  const AllocaInst *Alloca = nullptr, uint8_t ID = 0);
760  inline int CreateStackObject(uint64_t Size, unsigned Alignment,
761  bool isSpillSlot,
762  const AllocaInst *Alloca = nullptr,
763  uint8_t ID = 0),
764  "Use CreateStackObject that takes an Align instead") {
765  return CreateStackObject(Size, assumeAligned(Alignment), isSpillSlot,
766  Alloca, ID);
767  }
768 
769  /// Create a new statically sized stack object that represents a spill slot,
770  /// returning a nonnegative identifier to represent it.
771  int CreateSpillStackObject(uint64_t Size, Align Alignment);
773  inline int CreateSpillStackObject(uint64_t Size, unsigned Alignment),
774  "Use CreateSpillStackObject that takes an Align instead") {
775  return CreateSpillStackObject(Size, assumeAligned(Alignment));
776  }
777 
778  /// Remove or mark dead a statically sized stack object.
779  void RemoveStackObject(int ObjectIdx) {
780  // Mark it dead.
781  Objects[ObjectIdx+NumFixedObjects].Size = ~0ULL;
782  }
783 
784  /// Notify the MachineFrameInfo object that a variable sized object has been
785  /// created. This must be created whenever a variable sized object is
786  /// created, whether or not the index returned is actually used.
787  int CreateVariableSizedObject(Align Alignment, const AllocaInst *Alloca);
788  /// FIXME: Remove this function when transition to Align is over.
790  unsigned Alignment, const AllocaInst *Alloca),
791  "Use the version that takes an Align instead") {
792  return CreateVariableSizedObject(assumeAligned(Alignment), Alloca);
793  }
794 
795  /// Returns a reference to call saved info vector for the current function.
796  const std::vector<CalleeSavedInfo> &getCalleeSavedInfo() const {
797  return CSInfo;
798  }
799  /// \copydoc getCalleeSavedInfo()
800  std::vector<CalleeSavedInfo> &getCalleeSavedInfo() { return CSInfo; }
801 
802  /// Used by prolog/epilog inserter to set the function's callee saved
803  /// information.
804  void setCalleeSavedInfo(std::vector<CalleeSavedInfo> CSI) {
805  CSInfo = std::move(CSI);
806  }
807 
808  /// Has the callee saved info been calculated yet?
809  bool isCalleeSavedInfoValid() const { return CSIValid; }
810 
811  void setCalleeSavedInfoValid(bool v) { CSIValid = v; }
812 
813  MachineBasicBlock *getSavePoint() const { return Save; }
814  void setSavePoint(MachineBasicBlock *NewSave) { Save = NewSave; }
815  MachineBasicBlock *getRestorePoint() const { return Restore; }
816  void setRestorePoint(MachineBasicBlock *NewRestore) { Restore = NewRestore; }
817 
818  /// Return a set of physical registers that are pristine.
819  ///
820  /// Pristine registers hold a value that is useless to the current function,
821  /// but that must be preserved - they are callee saved registers that are not
822  /// saved.
823  ///
824  /// Before the PrologueEpilogueInserter has placed the CSR spill code, this
825  /// method always returns an empty set.
826  BitVector getPristineRegs(const MachineFunction &MF) const;
827 
828  /// Used by the MachineFunction printer to print information about
829  /// stack objects. Implemented in MachineFunction.cpp.
830  void print(const MachineFunction &MF, raw_ostream &OS) const;
831 
832  /// dump - Print the function to stderr.
833  void dump(const MachineFunction &MF) const;
834 };
835 
836 } // End llvm namespace
837 
838 #endif
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
i
i
Definition: README.txt:29
llvm::EngineKind::Kind
Kind
Definition: ExecutionEngine.h:524
llvm::MachineFrameInfo::LLVM_ATTRIBUTE_DEPRECATED
LLVM_ATTRIBUTE_DEPRECATED(inline int CreateSpillStackObject(uint64_t Size, unsigned Alignment), "Use CreateSpillStackObject that takes an Align instead")
Definition: MachineFrameInfo.h:772
llvm::MachineFrameInfo::isObjectZExt
bool isObjectZExt(int ObjectIdx) const
Definition: MachineFrameInfo.h:512
llvm::MachineFrameInfo::isMaxCallFrameSizeComputed
bool isMaxCallFrameSizeComputed() const
Definition: MachineFrameInfo.h:650
llvm::MachineFrameInfo::hasVarSizedObjects
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
Definition: MachineFrameInfo.h:351
llvm::CalleeSavedInfo::setRestored
void setRestored(bool R)
Definition: MachineFrameInfo.h:74
llvm::MachineFrameInfo::estimateStackSize
uint64_t estimateStackSize(const MachineFunction &MF) const
Estimate and return the size of the stack frame.
Definition: MachineFrameInfo.cpp:137
llvm
Definition: AllocatorList.h:23
llvm::MachineFrameInfo::hasVAStart
bool hasVAStart() const
Returns true if the function calls the llvm.va_start intrinsic.
Definition: MachineFrameInfo.h:619
llvm::CalleeSavedInfo::getReg
Register getReg() const
Definition: MachineFrameInfo.h:62
llvm::CalleeSavedInfo::isRestored
bool isRestored() const
Definition: MachineFrameInfo.h:73
llvm::MachineFrameInfo::getNumFixedObjects
unsigned getNumFixedObjects() const
Return the number of fixed objects.
Definition: MachineFrameInfo.h:394
llvm::MachineFrameInfo::setReturnAddressIsTaken
void setReturnAddressIsTaken(bool s)
Definition: MachineFrameInfo.h:373
llvm::MachineFrameInfo::hasCopyImplyingStackAdjustment
bool hasCopyImplyingStackAdjustment() const
Returns true if the function contains operations which will lower down to instructions which manipula...
Definition: MachineFrameInfo.h:611
llvm::MachineFrameInfo::LLVM_ATTRIBUTE_DEPRECATED
LLVM_ATTRIBUTE_DEPRECATED(int CreateVariableSizedObject(unsigned Alignment, const AllocaInst *Alloca), "Use the version that takes an Align instead")
FIXME: Remove this function when transition to Align is over.
Definition: MachineFrameInfo.h:789
llvm::MachineFrameInfo::setCVBytesOfCalleeSavedRegisters
void setCVBytesOfCalleeSavedRegisters(unsigned S)
Definition: MachineFrameInfo.h:660
llvm::MachineFrameInfo::getCVBytesOfCalleeSavedRegisters
unsigned getCVBytesOfCalleeSavedRegisters() const
Returns how many bytes of callee-saved registers the target pushed in the prologue.
Definition: MachineFrameInfo.h:657
llvm::MachineFrameInfo::getUseLocalStackAllocationBlock
bool getUseLocalStackAllocationBlock() const
Get whether the local allocation blob should be allocated together or let PEI allocate the locals in ...
Definition: MachineFrameInfo.h:432
llvm::MachineFrameInfo::getOffsetAdjustment
int getOffsetAdjustment() const
Return the correction for frame offsets.
Definition: MachineFrameInfo.h:572
llvm::MachineFrameInfo::LLVM_ATTRIBUTE_DEPRECATED
LLVM_ATTRIBUTE_DEPRECATED(inline int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0), "Use CreateStackObject that takes an Align instead")
Definition: MachineFrameInfo.h:759
llvm::MachineFrameInfo::setStackSize
void setStackSize(uint64_t Size)
Set the size of the stack.
Definition: MachineFrameInfo.h:566
llvm::MachineFrameInfo::isObjectPreAllocated
bool isObjectPreAllocated(int ObjectIdx) const
Return true if the object was pre-allocated into the local block.
Definition: MachineFrameInfo.h:444
llvm::MachineFrameInfo::SSPLK_LargeArray
@ SSPLK_LargeArray
Array or nested array >= SSP-buffer-size.
Definition: MachineFrameInfo.h:114
llvm::MachineFrameInfo::setMaxCallFrameSize
void setMaxCallFrameSize(unsigned S)
Definition: MachineFrameInfo.h:653
T
#define T
Definition: Mips16ISelLowering.cpp:341
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::MachineFrameInfo::setAdjustsStack
void setAdjustsStack(bool V)
Definition: MachineFrameInfo.h:599
llvm::MachineFrameInfo::setObjectSize
void setObjectSize(int ObjectIdx, int64_t Size)
Change the size of the specified stack object.
Definition: MachineFrameInfo.h:458
llvm::MachineFrameInfo::RemoveStackObject
void RemoveStackObject(int ObjectIdx)
Remove or mark dead a statically sized stack object.
Definition: MachineFrameInfo.h:779
llvm::MachineFrameInfo::getObjectIndexEnd
int getObjectIndexEnd() const
Return one past the maximum frame object index.
Definition: MachineFrameInfo.h:391
llvm::MachineFrameInfo::CreateVariableSizedObject
int CreateVariableSizedObject(Align Alignment, const AllocaInst *Alloca)
Notify the MachineFrameInfo object that a variable sized object has been created.
Definition: MachineFrameInfo.cpp:74
llvm::MachineFrameInfo::LLVM_ATTRIBUTE_DEPRECATED
LLVM_ATTRIBUTE_DEPRECATED(unsigned getMaxAlignment() const, "Use getMaxAlign instead")
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
Definition: MachineFrameInfo.h:579
HasCalls
@ HasCalls
Definition: AArch64InstrInfo.cpp:6157
llvm::MachineFrameInfo::getMaxCallFrameSize
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
Definition: MachineFrameInfo.h:643
llvm::MachineFrameInfo::setObjectAlignment
void setObjectAlignment(int ObjectIdx, Align Alignment)
setObjectAlignment - Change the alignment of the specified stack object.
Definition: MachineFrameInfo.h:478
llvm::CalleeSavedInfo::setDstReg
void setDstReg(Register SpillReg)
Definition: MachineFrameInfo.h:69
llvm::MachineFrameInfo::hasStackObjects
bool hasStackObjects() const
Return true if there are any stack objects in this function.
Definition: MachineFrameInfo.h:346
llvm::MachineFrameInfo::setHasStackMap
void setHasStackMap(bool s=true)
Definition: MachineFrameInfo.h:379
llvm::MachineFrameInfo::ensureMaxAlignment
void ensureMaxAlignment(Align Alignment)
Make sure the function is at least Align bytes aligned.
Definition: MachineFrameInfo.cpp:31
llvm::MachineFrameInfo::isReturnAddressTaken
bool isReturnAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
Definition: MachineFrameInfo.h:372
llvm::MachineFrameInfo::setObjectSSPLayout
void setObjectSSPLayout(int ObjectIdx, SSPLayoutKind Kind)
Definition: MachineFrameInfo.h:552
llvm::MachineFrameInfo::setCalleeSavedInfoValid
void setCalleeSavedInfoValid(bool v)
Definition: MachineFrameInfo.h:811
llvm::MachineFrameInfo::setLocalFrameMaxAlign
void setLocalFrameMaxAlign(Align Alignment)
Required alignment of the local object blob, which is the strictest alignment of any object in it.
Definition: MachineFrameInfo.h:423
int
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Definition: README.txt:536
llvm::CalleeSavedInfo::DstReg
unsigned DstReg
Definition: MachineFrameInfo.h:38
llvm::MachineFrameInfo::print
void print(const MachineFunction &MF, raw_ostream &OS) const
Used by the MachineFunction printer to print information about stack objects.
Definition: MachineFrameInfo.cpp:212
llvm::MachineFrameInfo::LLVM_ATTRIBUTE_DEPRECATED
LLVM_ATTRIBUTE_DEPRECATED(inline void ensureMaxAlignment(unsigned Align), "Use the version that uses Align instead")
Definition: MachineFrameInfo.h:590
false
Definition: StackSlotColoring.cpp:142
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::MachineFrameInfo::setHasOpaqueSPAdjustment
void setHasOpaqueSPAdjustment(bool B)
Definition: MachineFrameInfo.h:607
llvm::MachineFrameInfo::getRestorePoint
MachineBasicBlock * getRestorePoint() const
Definition: MachineFrameInfo.h:815
llvm::MachineFrameInfo::getStackID
uint8_t getStackID(int ObjectIdx) const
Definition: MachineFrameInfo.h:720
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
llvm::MachineFrameInfo::isAliasedObjectIndex
bool isAliasedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to an object that might be pointed to by an LLVM IR v...
Definition: MachineFrameInfo.h:683
llvm::MachineFrameInfo::SSPLK_None
@ SSPLK_None
Did not trigger a stack protector.
Definition: MachineFrameInfo.h:112
llvm::MachineFrameInfo::LLVM_ATTRIBUTE_DEPRECATED
LLVM_ATTRIBUTE_DEPRECATED(inline void setObjectAlignment(int ObjectIdx, unsigned Align), "Use the version that takes Align instead")
Definition: MachineFrameInfo.h:488
llvm::MachineFrameInfo::getLocalFrameMaxAlign
Align getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
Definition: MachineFrameInfo.h:428
llvm::MachineFrameInfo::getStackSize
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
Definition: MachineFrameInfo.h:563
llvm::MachineFrameInfo::hasMustTailInVarArgFunc
bool hasMustTailInVarArgFunc() const
Returns true if the function is variadic and contains a musttail call.
Definition: MachineFrameInfo.h:623
llvm::MachineFrameInfo::getObjectOffset
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
Definition: MachineFrameInfo.h:504
llvm::BitVector
Definition: BitVector.h:74
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::MachineFrameInfo::isFixedObjectIndex
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
Definition: MachineFrameInfo.h:677
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::MachineFrameInfo::getObjectIndexBegin
int getObjectIndexBegin() const
Return the minimum frame object index.
Definition: MachineFrameInfo.h:388
llvm::MachineFrameInfo::isCalleeSavedInfoValid
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
Definition: MachineFrameInfo.h:809
llvm::CalleeSavedInfo::setFrameIdx
void setFrameIdx(int FI)
Definition: MachineFrameInfo.h:65
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::MachineFrameInfo::isDeadObjectIndex
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
Definition: MachineFrameInfo.h:734
llvm::MachineFrameInfo::CreateSpillStackObject
int CreateSpillStackObject(uint64_t Size, Align Alignment)
Create a new statically sized stack object that represents a spill slot, returning a nonnegative iden...
Definition: MachineFrameInfo.cpp:66
llvm::MachineFrameInfo::getLocalFrameObjectMap
std::pair< int, int64_t > getLocalFrameObjectMap(int i) const
Get the local offset mapping for a for an object.
Definition: MachineFrameInfo.h:406
llvm::MachineFrameInfo::MachineFrameInfo
MachineFrameInfo(unsigned StackAlignment, bool StackRealignable, bool ForcedRealign)
Definition: MachineFrameInfo.h:340
llvm::MachineFrameInfo::setCalleeSavedInfo
void setCalleeSavedInfo(std::vector< CalleeSavedInfo > CSI)
Used by prolog/epilog inserter to set the function's callee saved information.
Definition: MachineFrameInfo.h:804
llvm::CalleeSavedInfo::isSpilledToReg
bool isSpilledToReg() const
Definition: MachineFrameInfo.h:75
llvm::MachineFrameInfo::setHasMustTailInVarArgFunc
void setHasMustTailInVarArgFunc(bool B)
Definition: MachineFrameInfo.h:624
llvm::MachineFrameInfo::CreateFixedSpillStackObject
int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset, bool IsImmutable=false)
Create a spill slot at a fixed location on the stack.
Definition: MachineFrameInfo.cpp:102
llvm::MachineFrameInfo::getLocalFrameSize
int64_t getLocalFrameSize() const
Get the size of the local object blob.
Definition: MachineFrameInfo.h:419
llvm::MachineFrameInfo::getObjectSize
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
Definition: MachineFrameInfo.h:451
llvm::CalleeSavedInfo::FrameIdx
int FrameIdx
Definition: MachineFrameInfo.h:37
llvm::MachineFrameInfo::hasStackProtectorIndex
bool hasStackProtectorIndex() const
Definition: MachineFrameInfo.h:356
s
multiplies can be turned into SHL s
Definition: README.txt:370
llvm::MachineFrameInfo::setHasCopyImplyingStackAdjustment
void setHasCopyImplyingStackAdjustment(bool B)
Definition: MachineFrameInfo.h:614
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::assumeAligned
Align assumeAligned(uint64_t Value)
Treats the value 0 as a 1, so Align is always at least 1.
Definition: Alignment.h:113
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::MachineFrameInfo::getObjectAlign
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
Definition: MachineFrameInfo.h:471
llvm::MachineFrameInfo::computeMaxCallFrameSize
void computeMaxCallFrameSize(const MachineFunction &MF)
Computes the maximum size of a callframe and the AdjustsStack property.
Definition: MachineFrameInfo.cpp:187
llvm::MachineFrameInfo::setObjectOffset
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
Definition: MachineFrameInfo.h:538
llvm::MachineFrameInfo::setRestorePoint
void setRestorePoint(MachineBasicBlock *NewRestore)
Definition: MachineFrameInfo.h:816
llvm::MachineFrameInfo::setFunctionContextIndex
void setFunctionContextIndex(int I)
Definition: MachineFrameInfo.h:361
llvm::MachineFrameInfo::mapLocalFrameObject
void mapLocalFrameObject(int ObjectIndex, int64_t Offset)
Map a frame index into the local object block.
Definition: MachineFrameInfo.h:400
llvm::MachineFrameInfo::setHasTailCall
void setHasTailCall(bool V=true)
Definition: MachineFrameInfo.h:628
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::MachineFrameInfo::CreateFixedObject
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
Definition: MachineFrameInfo.cpp:83
llvm::MachineFrameInfo::setSavePoint
void setSavePoint(MachineBasicBlock *NewSave)
Definition: MachineFrameInfo.h:814
llvm::MachineFunction
Definition: MachineFunction.h:227
llvm::MachineFrameInfo::getCalleeSavedInfo
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
Definition: MachineFrameInfo.h:796
llvm::MachineFrameInfo::setStackID
void setStackID(int ObjectIdx, uint8_t ID)
Definition: MachineFrameInfo.h:725
llvm::MachineFrameInfo::hasPatchPoint
bool hasPatchPoint() const
This method may be called any time after instruction selection is complete to determine if there is a...
Definition: MachineFrameInfo.h:384
llvm::MachineFrameInfo::isStatepointSpillSlotObjectIndex
bool isStatepointSpillSlotObjectIndex(int ObjectIdx) const
Definition: MachineFrameInfo.h:713
llvm::MachineFrameInfo::setHasCalls
void setHasCalls(bool V)
Definition: MachineFrameInfo.h:603
llvm::MachineFrameInfo::CreateStackObject
int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
Definition: MachineFrameInfo.cpp:51
llvm::MachineFrameInfo::getPristineRegs
BitVector getPristineRegs(const MachineFunction &MF) const
Return a set of physical registers that are pristine.
Definition: MachineFrameInfo.cpp:115
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::MachineFrameInfo::isObjectSExt
bool isObjectSExt(int ObjectIdx) const
Definition: MachineFrameInfo.h:524
llvm::MachineFrameInfo::getLocalFrameObjectCount
int64_t getLocalFrameObjectCount() const
Return the number of objects allocated into the local object block.
Definition: MachineFrameInfo.h:413
llvm::MachineFrameInfo::getMaxAlign
Align getMaxAlign() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
Definition: MachineFrameInfo.h:585
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::MachineFrameInfo::isFrameAddressTaken
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
Definition: MachineFrameInfo.h:366
llvm::MachineFrameInfo::hasCalls
bool hasCalls() const
Return true if the current function has any function calls.
Definition: MachineFrameInfo.h:602
llvm::MachineFrameInfo::dump
void dump(const MachineFunction &MF) const
dump - Print the function to stderr.
Definition: MachineFrameInfo.cpp:253
llvm::MachineFrameInfo::getSavePoint
MachineBasicBlock * getSavePoint() const
Definition: MachineFrameInfo.h:813
Alignment.h
llvm::MachineFrameInfo::getObjectSSPLayout
SSPLayoutKind getObjectSSPLayout(int ObjectIdx) const
Definition: MachineFrameInfo.h:546
llvm::CalleeSavedInfo
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
Definition: MachineFrameInfo.h:34
llvm::MachineFrameInfo::isVariableSizedObjectIndex
bool isVariableSizedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a variable sized object.
Definition: MachineFrameInfo.h:742
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
llvm::MachineFrameInfo::setIsImmutableObjectIndex
void setIsImmutableObjectIndex(int ObjectIdx, bool IsImmutable)
Marks the immutability of an object.
Definition: MachineFrameInfo.h:700
llvm::CalleeSavedInfo::getDstReg
unsigned getDstReg() const
Definition: MachineFrameInfo.h:64
llvm::MachineFrameInfo::setObjectSExt
void setObjectSExt(int ObjectIdx, bool IsSExt)
Definition: MachineFrameInfo.h:530
llvm::MachineFrameInfo::isSpillSlotObjectIndex
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.
Definition: MachineFrameInfo.h:707
llvm::MachineFrameInfo::setStackProtectorIndex
void setStackProtectorIndex(int I)
Definition: MachineFrameInfo.h:355
llvm::MachineFrameInfo::getNumObjects
unsigned getNumObjects() const
Return the number of objects.
Definition: MachineFrameInfo.h:397
llvm::MachineFrameInfo::isImmutableObjectIndex
bool isImmutableObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to an immutable object.
Definition: MachineFrameInfo.h:690
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:107
SmallVector.h
llvm::MachineFrameInfo::SSPLK_AddrOf
@ SSPLK_AddrOf
The address of this allocation is exposed and triggered protection.
Definition: MachineFrameInfo.h:118
llvm::MachineFrameInfo::SSPLayoutKind
SSPLayoutKind
Stack Smashing Protection (SSP) rules require that vulnerable stack allocations are located close the...
Definition: MachineFrameInfo.h:111
llvm::MachineFrameInfo::SSPLK_SmallArray
@ SSPLK_SmallArray
Array or nested array < SSP-buffer-size.
Definition: MachineFrameInfo.h:116
llvm::MachineFrameInfo::setHasPatchPoint
void setHasPatchPoint(bool s=true)
Definition: MachineFrameInfo.h:385
llvm::MachineFrameInfo::markAsStatepointSpillSlotObjectIndex
void markAsStatepointSpillSlotObjectIndex(int ObjectIdx)
Definition: MachineFrameInfo.h:748
llvm::MachineFrameInfo::setOffsetAdjustment
void setOffsetAdjustment(int Adj)
Set the correction for frame offsets.
Definition: MachineFrameInfo.h:575
DataTypes.h
llvm::MachineFrameInfo::hasOpaqueSPAdjustment
bool hasOpaqueSPAdjustment() const
Returns true if the function contains opaque dynamic stack adjustments.
Definition: MachineFrameInfo.h:606
llvm::MachineFrameInfo::getCalleeSavedInfo
std::vector< CalleeSavedInfo > & getCalleeSavedInfo()
Definition: MachineFrameInfo.h:800
llvm::MachineFrameInfo::getStackProtectorIndex
int getStackProtectorIndex() const
Return the index for the stack protector object.
Definition: MachineFrameInfo.h:354
Register.h
llvm::MachineFrameInfo::hasStackMap
bool hasStackMap() const
This method may be called any time after instruction selection is complete to determine if there is a...
Definition: MachineFrameInfo.h:378
llvm::MachineFrameInfo::adjustsStack
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
Definition: MachineFrameInfo.h:598
llvm::MachineFrameInfo::setFrameAddressIsTaken
void setFrameAddressIsTaken(bool T)
Definition: MachineFrameInfo.h:367
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:61
llvm::MachineFrameInfo::hasTailCall
bool hasTailCall() const
Returns true if the function contains a tail call.
Definition: MachineFrameInfo.h:627
llvm::MachineFrameInfo::setObjectZExt
void setObjectZExt(int ObjectIdx, bool IsZExt)
Definition: MachineFrameInfo.h:518
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1789
llvm::CalleeSavedInfo::getFrameIdx
int getFrameIdx() const
Definition: MachineFrameInfo.h:63
llvm::MachineFrameInfo::setLocalFrameSize
void setLocalFrameSize(int64_t sz)
Set the size of the local object blob.
Definition: MachineFrameInfo.h:416
llvm::MachineFrameInfo::setHasVAStart
void setHasVAStart(bool B)
Definition: MachineFrameInfo.h:620
llvm::CalleeSavedInfo::CalleeSavedInfo
CalleeSavedInfo(unsigned R, int FI=0)
Definition: MachineFrameInfo.h:58
llvm::MachineFrameInfo::setUseLocalStackAllocationBlock
void setUseLocalStackAllocationBlock(bool v)
setUseLocalStackAllocationBlock - Set whether the local allocation blob should be allocated together ...
Definition: MachineFrameInfo.h:439
llvm::MachineFrameInfo::getFunctionContextIndex
int getFunctionContextIndex() const
Return the index for the function context object.
Definition: MachineFrameInfo.h:360
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::MachineFrameInfo::getObjectAllocation
const AllocaInst * getObjectAllocation(int ObjectIdx) const
Return the underlying Alloca of the specified stack object if it exists.
Definition: MachineFrameInfo.h:496