LLVM  9.0.0svn
PrologEpilogInserter.cpp
Go to the documentation of this file.
1 //===- PrologEpilogInserter.cpp - Insert Prolog/Epilog code in function ---===//
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 pass is responsible for finalizing the functions frame layout, saving
10 // callee saved registers, and for emitting prolog & epilog code for the
11 // function.
12 //
13 // This pass must be run after register allocation. After this pass is
14 // executed, it is illegal to construct MO_FrameIndex operands.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/BitVector.h"
21 #include "llvm/ADT/STLExtras.h"
22 #include "llvm/ADT/SetVector.h"
23 #include "llvm/ADT/SmallPtrSet.h"
24 #include "llvm/ADT/SmallSet.h"
25 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/Statistic.h"
46 #include "llvm/IR/Attributes.h"
47 #include "llvm/IR/CallingConv.h"
49 #include "llvm/IR/DiagnosticInfo.h"
50 #include "llvm/IR/Function.h"
51 #include "llvm/IR/InlineAsm.h"
52 #include "llvm/IR/LLVMContext.h"
53 #include "llvm/MC/MCRegisterInfo.h"
54 #include "llvm/Pass.h"
55 #include "llvm/Support/CodeGen.h"
57 #include "llvm/Support/Debug.h"
63 #include <algorithm>
64 #include <cassert>
65 #include <cstdint>
66 #include <functional>
67 #include <limits>
68 #include <utility>
69 #include <vector>
70 
71 using namespace llvm;
72 
73 #define DEBUG_TYPE "prologepilog"
74 
76 
77 STATISTIC(NumLeafFuncWithSpills, "Number of leaf functions with CSRs");
78 STATISTIC(NumFuncSeen, "Number of functions seen in PEI");
79 
80 
81 namespace {
82 
83 class PEI : public MachineFunctionPass {
84 public:
85  static char ID;
86 
87  PEI() : MachineFunctionPass(ID) {
89  }
90 
91  void getAnalysisUsage(AnalysisUsage &AU) const override;
92 
93  /// runOnMachineFunction - Insert prolog/epilog code and replace abstract
94  /// frame indexes with appropriate references.
95  bool runOnMachineFunction(MachineFunction &MF) override;
96 
97 private:
98  RegScavenger *RS;
99 
100  // MinCSFrameIndex, MaxCSFrameIndex - Keeps the range of callee saved
101  // stack frame indexes.
102  unsigned MinCSFrameIndex = std::numeric_limits<unsigned>::max();
103  unsigned MaxCSFrameIndex = 0;
104 
105  // Save and Restore blocks of the current function. Typically there is a
106  // single save block, unless Windows EH funclets are involved.
107  MBBVector SaveBlocks;
108  MBBVector RestoreBlocks;
109 
110  // Flag to control whether to use the register scavenger to resolve
111  // frame index materialization registers. Set according to
112  // TRI->requiresFrameIndexScavenging() for the current function.
113  bool FrameIndexVirtualScavenging;
114 
115  // Flag to control whether the scavenger should be passed even though
116  // FrameIndexVirtualScavenging is used.
117  bool FrameIndexEliminationScavenging;
118 
119  // Emit remarks.
120  MachineOptimizationRemarkEmitter *ORE = nullptr;
121 
122  void calculateCallFrameInfo(MachineFunction &MF);
123  void calculateSaveRestoreBlocks(MachineFunction &MF);
124  void spillCalleeSavedRegs(MachineFunction &MF);
125 
126  void calculateFrameObjectOffsets(MachineFunction &MF);
127  void replaceFrameIndices(MachineFunction &MF);
128  void replaceFrameIndices(MachineBasicBlock *BB, MachineFunction &MF,
129  int &SPAdj);
130  void insertPrologEpilogCode(MachineFunction &MF);
131 };
132 
133 } // end anonymous namespace
134 
135 char PEI::ID = 0;
136 
138 
139 static cl::opt<unsigned>
140 WarnStackSize("warn-stack-size", cl::Hidden, cl::init((unsigned)-1),
141  cl::desc("Warn for stack size bigger than the given"
142  " number"));
143 
144 INITIALIZE_PASS_BEGIN(PEI, DEBUG_TYPE, "Prologue/Epilogue Insertion", false,
145  false)
150  "Prologue/Epilogue Insertion & Frame Finalization", false,
151  false)
152 
154  return new PEI();
155 }
156 
157 STATISTIC(NumBytesStackSpace,
158  "Number of bytes used for stack in all functions");
159 
160 void PEI::getAnalysisUsage(AnalysisUsage &AU) const {
161  AU.setPreservesCFG();
166 }
167 
168 /// StackObjSet - A set of stack object indexes
170 
171 using SavedDbgValuesMap =
173 
174 /// Stash DBG_VALUEs that describe parameters and which are placed at the start
175 /// of the block. Later on, after the prologue code has been emitted, the
176 /// stashed DBG_VALUEs will be reinserted at the start of the block.
178  SavedDbgValuesMap &EntryDbgValues) {
179  SmallVector<const MachineInstr *, 4> FrameIndexValues;
180 
181  for (auto &MI : MBB) {
182  if (!MI.isDebugInstr())
183  break;
184  if (!MI.isDebugValue() || !MI.getDebugVariable()->isParameter())
185  continue;
186  if (MI.getOperand(0).isFI()) {
187  // We can only emit valid locations for frame indices after the frame
188  // setup, so do not stash away them.
189  FrameIndexValues.push_back(&MI);
190  continue;
191  }
192  const DILocalVariable *Var = MI.getDebugVariable();
193  const DIExpression *Expr = MI.getDebugExpression();
194  auto Overlaps = [Var, Expr](const MachineInstr *DV) {
195  return Var == DV->getDebugVariable() &&
196  Expr->fragmentsOverlap(DV->getDebugExpression());
197  };
198  // See if the debug value overlaps with any preceding debug value that will
199  // not be stashed. If that is the case, then we can't stash this value, as
200  // we would then reorder the values at reinsertion.
201  if (llvm::none_of(FrameIndexValues, Overlaps))
202  EntryDbgValues[&MBB].push_back(&MI);
203  }
204 
205  // Remove stashed debug values from the block.
206  if (EntryDbgValues.count(&MBB))
207  for (auto *MI : EntryDbgValues[&MBB])
208  MI->removeFromParent();
209 }
210 
211 /// runOnMachineFunction - Insert prolog/epilog code and replace abstract
212 /// frame indexes with appropriate references.
213 bool PEI::runOnMachineFunction(MachineFunction &MF) {
214  NumFuncSeen++;
215  const Function &F = MF.getFunction();
218 
219  RS = TRI->requiresRegisterScavenging(MF) ? new RegScavenger() : nullptr;
220  FrameIndexVirtualScavenging = TRI->requiresFrameIndexScavenging(MF);
221  FrameIndexEliminationScavenging = (RS && !FrameIndexVirtualScavenging) ||
223  ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();
224 
225  // Calculate the MaxCallFrameSize and AdjustsStack variables for the
226  // function's frame information. Also eliminates call frame pseudo
227  // instructions.
228  calculateCallFrameInfo(MF);
229 
230  // Determine placement of CSR spill/restore code and prolog/epilog code:
231  // place all spills in the entry block, all restores in return blocks.
232  calculateSaveRestoreBlocks(MF);
233 
234  // Stash away DBG_VALUEs that should not be moved by insertion of prolog code.
235  SavedDbgValuesMap EntryDbgValues;
236  for (MachineBasicBlock *SaveBlock : SaveBlocks)
237  stashEntryDbgValues(*SaveBlock, EntryDbgValues);
238 
239  // Handle CSR spilling and restoring, for targets that need it.
240  if (MF.getTarget().usesPhysRegsForPEI())
241  spillCalleeSavedRegs(MF);
242 
243  // Allow the target machine to make final modifications to the function
244  // before the frame layout is finalized.
246 
247  // Calculate actual frame offsets for all abstract stack objects...
248  calculateFrameObjectOffsets(MF);
249 
250  // Add prolog and epilog code to the function. This function is required
251  // to align the stack frame as necessary for any stack variables or
252  // called functions. Because of this, calculateCalleeSavedRegisters()
253  // must be called before this function in order to set the AdjustsStack
254  // and MaxCallFrameSize variables.
255  if (!F.hasFnAttribute(Attribute::Naked))
256  insertPrologEpilogCode(MF);
257 
258  // Reinsert stashed debug values at the start of the entry blocks.
259  for (auto &I : EntryDbgValues)
260  I.first->insert(I.first->begin(), I.second.begin(), I.second.end());
261 
262  // Replace all MO_FrameIndex operands with physical register references
263  // and actual offsets.
264  //
265  replaceFrameIndices(MF);
266 
267  // If register scavenging is needed, as we've enabled doing it as a
268  // post-pass, scavenge the virtual registers that frame index elimination
269  // inserted.
270  if (TRI->requiresRegisterScavenging(MF) && FrameIndexVirtualScavenging)
271  scavengeFrameVirtualRegs(MF, *RS);
272 
273  // Warn on stack size when we exceeds the given limit.
274  MachineFrameInfo &MFI = MF.getFrameInfo();
275  uint64_t StackSize = MFI.getStackSize();
276  if (WarnStackSize.getNumOccurrences() > 0 && WarnStackSize < StackSize) {
277  DiagnosticInfoStackSize DiagStackSize(F, StackSize);
278  F.getContext().diagnose(DiagStackSize);
279  }
280  ORE->emit([&]() {
281  return MachineOptimizationRemarkAnalysis(DEBUG_TYPE, "StackSize",
282  MF.getFunction().getSubprogram(),
283  &MF.front())
284  << ore::NV("NumStackBytes", StackSize) << " stack bytes in function";
285  });
286 
287  delete RS;
288  SaveBlocks.clear();
289  RestoreBlocks.clear();
290  MFI.setSavePoint(nullptr);
291  MFI.setRestorePoint(nullptr);
292  return true;
293 }
294 
295 /// Calculate the MaxCallFrameSize and AdjustsStack
296 /// variables for the function's frame information and eliminate call frame
297 /// pseudo instructions.
298 void PEI::calculateCallFrameInfo(MachineFunction &MF) {
299  const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
301  MachineFrameInfo &MFI = MF.getFrameInfo();
302 
303  unsigned MaxCallFrameSize = 0;
304  bool AdjustsStack = MFI.adjustsStack();
305 
306  // Get the function call frame set-up and tear-down instruction opcode
307  unsigned FrameSetupOpcode = TII.getCallFrameSetupOpcode();
308  unsigned FrameDestroyOpcode = TII.getCallFrameDestroyOpcode();
309 
310  // Early exit for targets which have no call frame setup/destroy pseudo
311  // instructions.
312  if (FrameSetupOpcode == ~0u && FrameDestroyOpcode == ~0u)
313  return;
314 
315  std::vector<MachineBasicBlock::iterator> FrameSDOps;
316  for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E; ++BB)
317  for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ++I)
318  if (TII.isFrameInstr(*I)) {
319  unsigned Size = TII.getFrameSize(*I);
320  if (Size > MaxCallFrameSize) MaxCallFrameSize = Size;
321  AdjustsStack = true;
322  FrameSDOps.push_back(I);
323  } else if (I->isInlineAsm()) {
324  // Some inline asm's need a stack frame, as indicated by operand 1.
325  unsigned ExtraInfo = I->getOperand(InlineAsm::MIOp_ExtraInfo).getImm();
326  if (ExtraInfo & InlineAsm::Extra_IsAlignStack)
327  AdjustsStack = true;
328  }
329 
331  (MFI.getMaxCallFrameSize() == MaxCallFrameSize &&
332  MFI.adjustsStack() == AdjustsStack));
333  MFI.setAdjustsStack(AdjustsStack);
334  MFI.setMaxCallFrameSize(MaxCallFrameSize);
335 
336  for (std::vector<MachineBasicBlock::iterator>::iterator
337  i = FrameSDOps.begin(), e = FrameSDOps.end(); i != e; ++i) {
339 
340  // If call frames are not being included as part of the stack frame, and
341  // the target doesn't indicate otherwise, remove the call frame pseudos
342  // here. The sub/add sp instruction pairs are still inserted, but we don't
343  // need to track the SP adjustment for frame index elimination.
344  if (TFI->canSimplifyCallFramePseudos(MF))
345  TFI->eliminateCallFramePseudoInstr(MF, *I->getParent(), I);
346  }
347 }
348 
349 /// Compute the sets of entry and return blocks for saving and restoring
350 /// callee-saved registers, and placing prolog and epilog code.
351 void PEI::calculateSaveRestoreBlocks(MachineFunction &MF) {
352  const MachineFrameInfo &MFI = MF.getFrameInfo();
353 
354  // Even when we do not change any CSR, we still want to insert the
355  // prologue and epilogue of the function.
356  // So set the save points for those.
357 
358  // Use the points found by shrink-wrapping, if any.
359  if (MFI.getSavePoint()) {
360  SaveBlocks.push_back(MFI.getSavePoint());
361  assert(MFI.getRestorePoint() && "Both restore and save must be set");
362  MachineBasicBlock *RestoreBlock = MFI.getRestorePoint();
363  // If RestoreBlock does not have any successor and is not a return block
364  // then the end point is unreachable and we do not need to insert any
365  // epilogue.
366  if (!RestoreBlock->succ_empty() || RestoreBlock->isReturnBlock())
367  RestoreBlocks.push_back(RestoreBlock);
368  return;
369  }
370 
371  // Save refs to entry and return blocks.
372  SaveBlocks.push_back(&MF.front());
373  for (MachineBasicBlock &MBB : MF) {
374  if (MBB.isEHFuncletEntry())
375  SaveBlocks.push_back(&MBB);
376  if (MBB.isReturnBlock())
377  RestoreBlocks.push_back(&MBB);
378  }
379 }
380 
382  const BitVector &SavedRegs,
383  unsigned &MinCSFrameIndex,
384  unsigned &MaxCSFrameIndex) {
385  if (SavedRegs.empty())
386  return;
387 
388  const TargetRegisterInfo *RegInfo = F.getSubtarget().getRegisterInfo();
389  const MCPhysReg *CSRegs = F.getRegInfo().getCalleeSavedRegs();
390 
391  std::vector<CalleeSavedInfo> CSI;
392  for (unsigned i = 0; CSRegs[i]; ++i) {
393  unsigned Reg = CSRegs[i];
394  if (SavedRegs.test(Reg))
395  CSI.push_back(CalleeSavedInfo(Reg));
396  }
397 
399  MachineFrameInfo &MFI = F.getFrameInfo();
400  if (!TFI->assignCalleeSavedSpillSlots(F, RegInfo, CSI)) {
401  // If target doesn't implement this, use generic code.
402 
403  if (CSI.empty())
404  return; // Early exit if no callee saved registers are modified!
405 
406  unsigned NumFixedSpillSlots;
407  const TargetFrameLowering::SpillSlot *FixedSpillSlots =
408  TFI->getCalleeSavedSpillSlots(NumFixedSpillSlots);
409 
410  // Now that we know which registers need to be saved and restored, allocate
411  // stack slots for them.
412  for (auto &CS : CSI) {
413  // If the target has spilled this register to another register, we don't
414  // need to allocate a stack slot.
415  if (CS.isSpilledToReg())
416  continue;
417 
418  unsigned Reg = CS.getReg();
419  const TargetRegisterClass *RC = RegInfo->getMinimalPhysRegClass(Reg);
420 
421  int FrameIdx;
422  if (RegInfo->hasReservedSpillSlot(F, Reg, FrameIdx)) {
423  CS.setFrameIdx(FrameIdx);
424  continue;
425  }
426 
427  // Check to see if this physreg must be spilled to a particular stack slot
428  // on this target.
429  const TargetFrameLowering::SpillSlot *FixedSlot = FixedSpillSlots;
430  while (FixedSlot != FixedSpillSlots + NumFixedSpillSlots &&
431  FixedSlot->Reg != Reg)
432  ++FixedSlot;
433 
434  unsigned Size = RegInfo->getSpillSize(*RC);
435  if (FixedSlot == FixedSpillSlots + NumFixedSpillSlots) {
436  // Nope, just spill it anywhere convenient.
437  unsigned Align = RegInfo->getSpillAlignment(*RC);
438  unsigned StackAlign = TFI->getStackAlignment();
439 
440  // We may not be able to satisfy the desired alignment specification of
441  // the TargetRegisterClass if the stack alignment is smaller. Use the
442  // min.
443  Align = std::min(Align, StackAlign);
444  FrameIdx = MFI.CreateStackObject(Size, Align, true);
445  if ((unsigned)FrameIdx < MinCSFrameIndex) MinCSFrameIndex = FrameIdx;
446  if ((unsigned)FrameIdx > MaxCSFrameIndex) MaxCSFrameIndex = FrameIdx;
447  } else {
448  // Spill it to the stack where we must.
449  FrameIdx = MFI.CreateFixedSpillStackObject(Size, FixedSlot->Offset);
450  }
451 
452  CS.setFrameIdx(FrameIdx);
453  }
454  }
455 
456  MFI.setCalleeSavedInfo(CSI);
457 }
458 
459 /// Helper function to update the liveness information for the callee-saved
460 /// registers.
461 static void updateLiveness(MachineFunction &MF) {
462  MachineFrameInfo &MFI = MF.getFrameInfo();
463  // Visited will contain all the basic blocks that are in the region
464  // where the callee saved registers are alive:
465  // - Anything that is not Save or Restore -> LiveThrough.
466  // - Save -> LiveIn.
467  // - Restore -> LiveOut.
468  // The live-out is not attached to the block, so no need to keep
469  // Restore in this set.
472  MachineBasicBlock *Entry = &MF.front();
473  MachineBasicBlock *Save = MFI.getSavePoint();
474 
475  if (!Save)
476  Save = Entry;
477 
478  if (Entry != Save) {
479  WorkList.push_back(Entry);
480  Visited.insert(Entry);
481  }
482  Visited.insert(Save);
483 
484  MachineBasicBlock *Restore = MFI.getRestorePoint();
485  if (Restore)
486  // By construction Restore cannot be visited, otherwise it
487  // means there exists a path to Restore that does not go
488  // through Save.
489  WorkList.push_back(Restore);
490 
491  while (!WorkList.empty()) {
492  const MachineBasicBlock *CurBB = WorkList.pop_back_val();
493  // By construction, the region that is after the save point is
494  // dominated by the Save and post-dominated by the Restore.
495  if (CurBB == Save && Save != Restore)
496  continue;
497  // Enqueue all the successors not already visited.
498  // Those are by construction either before Save or after Restore.
499  for (MachineBasicBlock *SuccBB : CurBB->successors())
500  if (Visited.insert(SuccBB).second)
501  WorkList.push_back(SuccBB);
502  }
503 
504  const std::vector<CalleeSavedInfo> &CSI = MFI.getCalleeSavedInfo();
505 
507  for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
508  for (MachineBasicBlock *MBB : Visited) {
509  MCPhysReg Reg = CSI[i].getReg();
510  // Add the callee-saved register as live-in.
511  // It's killed at the spill.
512  if (!MRI.isReserved(Reg) && !MBB->isLiveIn(Reg))
513  MBB->addLiveIn(Reg);
514  }
515  // If callee-saved register is spilled to another register rather than
516  // spilling to stack, the destination register has to be marked as live for
517  // each MBB between the prologue and epilogue so that it is not clobbered
518  // before it is reloaded in the epilogue. The Visited set contains all
519  // blocks outside of the region delimited by prologue/epilogue.
520  if (CSI[i].isSpilledToReg()) {
521  for (MachineBasicBlock &MBB : MF) {
522  if (Visited.count(&MBB))
523  continue;
524  MCPhysReg DstReg = CSI[i].getDstReg();
525  if (!MBB.isLiveIn(DstReg))
526  MBB.addLiveIn(DstReg);
527  }
528  }
529  }
530 
531 }
532 
533 /// Insert restore code for the callee-saved registers used in the function.
534 static void insertCSRSaves(MachineBasicBlock &SaveBlock,
536  MachineFunction &MF = *SaveBlock.getParent();
537  const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
540 
541  MachineBasicBlock::iterator I = SaveBlock.begin();
542  if (!TFI->spillCalleeSavedRegisters(SaveBlock, I, CSI, TRI)) {
543  for (const CalleeSavedInfo &CS : CSI) {
544  // Insert the spill to the stack frame.
545  unsigned Reg = CS.getReg();
546  const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(Reg);
547  TII.storeRegToStackSlot(SaveBlock, I, Reg, true, CS.getFrameIdx(), RC,
548  TRI);
549  }
550  }
551 }
552 
553 /// Insert restore code for the callee-saved registers used in the function.
554 static void insertCSRRestores(MachineBasicBlock &RestoreBlock,
555  std::vector<CalleeSavedInfo> &CSI) {
556  MachineFunction &MF = *RestoreBlock.getParent();
557  const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
560 
561  // Restore all registers immediately before the return and any
562  // terminators that precede it.
564 
565  if (!TFI->restoreCalleeSavedRegisters(RestoreBlock, I, CSI, TRI)) {
566  for (const CalleeSavedInfo &CI : reverse(CSI)) {
567  unsigned Reg = CI.getReg();
568  const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(Reg);
569  TII.loadRegFromStackSlot(RestoreBlock, I, Reg, CI.getFrameIdx(), RC, TRI);
570  assert(I != RestoreBlock.begin() &&
571  "loadRegFromStackSlot didn't insert any code!");
572  // Insert in reverse order. loadRegFromStackSlot can insert
573  // multiple instructions.
574  }
575  }
576 }
577 
578 void PEI::spillCalleeSavedRegs(MachineFunction &MF) {
579  // We can't list this requirement in getRequiredProperties because some
580  // targets (WebAssembly) use virtual registers past this point, and the pass
581  // pipeline is set up without giving the passes a chance to look at the
582  // TargetMachine.
583  // FIXME: Find a way to express this in getRequiredProperties.
586 
587  const Function &F = MF.getFunction();
589  MachineFrameInfo &MFI = MF.getFrameInfo();
590  MinCSFrameIndex = std::numeric_limits<unsigned>::max();
591  MaxCSFrameIndex = 0;
592 
593  // Determine which of the registers in the callee save list should be saved.
594  BitVector SavedRegs;
595  TFI->determineCalleeSaves(MF, SavedRegs, RS);
596 
597  // Assign stack slots for any callee-saved registers that must be spilled.
598  assignCalleeSavedSpillSlots(MF, SavedRegs, MinCSFrameIndex, MaxCSFrameIndex);
599 
600  // Add the code to save and restore the callee saved registers.
601  if (!F.hasFnAttribute(Attribute::Naked)) {
602  MFI.setCalleeSavedInfoValid(true);
603 
604  std::vector<CalleeSavedInfo> &CSI = MFI.getCalleeSavedInfo();
605  if (!CSI.empty()) {
606  if (!MFI.hasCalls())
607  NumLeafFuncWithSpills++;
608 
609  for (MachineBasicBlock *SaveBlock : SaveBlocks) {
610  insertCSRSaves(*SaveBlock, CSI);
611  // Update the live-in information of all the blocks up to the save
612  // point.
613  updateLiveness(MF);
614  }
615  for (MachineBasicBlock *RestoreBlock : RestoreBlocks)
616  insertCSRRestores(*RestoreBlock, CSI);
617  }
618  }
619 }
620 
621 /// AdjustStackOffset - Helper function used to adjust the stack frame offset.
622 static inline void
624  bool StackGrowsDown, int64_t &Offset,
625  unsigned &MaxAlign, unsigned Skew) {
626  // If the stack grows down, add the object size to find the lowest address.
627  if (StackGrowsDown)
628  Offset += MFI.getObjectSize(FrameIdx);
629 
630  unsigned Align = MFI.getObjectAlignment(FrameIdx);
631 
632  // If the alignment of this object is greater than that of the stack, then
633  // increase the stack alignment to match.
634  MaxAlign = std::max(MaxAlign, Align);
635 
636  // Adjust to alignment boundary.
637  Offset = alignTo(Offset, Align, Skew);
638 
639  if (StackGrowsDown) {
640  LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << -Offset
641  << "]\n");
642  MFI.setObjectOffset(FrameIdx, -Offset); // Set the computed offset
643  } else {
644  LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << Offset
645  << "]\n");
646  MFI.setObjectOffset(FrameIdx, Offset);
647  Offset += MFI.getObjectSize(FrameIdx);
648  }
649 }
650 
651 /// Compute which bytes of fixed and callee-save stack area are unused and keep
652 /// track of them in StackBytesFree.
653 static inline void
654 computeFreeStackSlots(MachineFrameInfo &MFI, bool StackGrowsDown,
655  unsigned MinCSFrameIndex, unsigned MaxCSFrameIndex,
656  int64_t FixedCSEnd, BitVector &StackBytesFree) {
657  // Avoid undefined int64_t -> int conversion below in extreme case.
658  if (FixedCSEnd > std::numeric_limits<int>::max())
659  return;
660 
661  StackBytesFree.resize(FixedCSEnd, true);
662 
663  SmallVector<int, 16> AllocatedFrameSlots;
664  // Add fixed objects.
665  for (int i = MFI.getObjectIndexBegin(); i != 0; ++i)
666  AllocatedFrameSlots.push_back(i);
667  // Add callee-save objects.
668  for (int i = MinCSFrameIndex; i <= (int)MaxCSFrameIndex; ++i)
669  AllocatedFrameSlots.push_back(i);
670 
671  for (int i : AllocatedFrameSlots) {
672  // These are converted from int64_t, but they should always fit in int
673  // because of the FixedCSEnd check above.
674  int ObjOffset = MFI.getObjectOffset(i);
675  int ObjSize = MFI.getObjectSize(i);
676  int ObjStart, ObjEnd;
677  if (StackGrowsDown) {
678  // ObjOffset is negative when StackGrowsDown is true.
679  ObjStart = -ObjOffset - ObjSize;
680  ObjEnd = -ObjOffset;
681  } else {
682  ObjStart = ObjOffset;
683  ObjEnd = ObjOffset + ObjSize;
684  }
685  // Ignore fixed holes that are in the previous stack frame.
686  if (ObjEnd > 0)
687  StackBytesFree.reset(ObjStart, ObjEnd);
688  }
689 }
690 
691 /// Assign frame object to an unused portion of the stack in the fixed stack
692 /// object range. Return true if the allocation was successful.
693 static inline bool scavengeStackSlot(MachineFrameInfo &MFI, int FrameIdx,
694  bool StackGrowsDown, unsigned MaxAlign,
695  BitVector &StackBytesFree) {
696  if (MFI.isVariableSizedObjectIndex(FrameIdx))
697  return false;
698 
699  if (StackBytesFree.none()) {
700  // clear it to speed up later scavengeStackSlot calls to
701  // StackBytesFree.none()
702  StackBytesFree.clear();
703  return false;
704  }
705 
706  unsigned ObjAlign = MFI.getObjectAlignment(FrameIdx);
707  if (ObjAlign > MaxAlign)
708  return false;
709 
710  int64_t ObjSize = MFI.getObjectSize(FrameIdx);
711  int FreeStart;
712  for (FreeStart = StackBytesFree.find_first(); FreeStart != -1;
713  FreeStart = StackBytesFree.find_next(FreeStart)) {
714 
715  // Check that free space has suitable alignment.
716  unsigned ObjStart = StackGrowsDown ? FreeStart + ObjSize : FreeStart;
717  if (alignTo(ObjStart, ObjAlign) != ObjStart)
718  continue;
719 
720  if (FreeStart + ObjSize > StackBytesFree.size())
721  return false;
722 
723  bool AllBytesFree = true;
724  for (unsigned Byte = 0; Byte < ObjSize; ++Byte)
725  if (!StackBytesFree.test(FreeStart + Byte)) {
726  AllBytesFree = false;
727  break;
728  }
729  if (AllBytesFree)
730  break;
731  }
732 
733  if (FreeStart == -1)
734  return false;
735 
736  if (StackGrowsDown) {
737  int ObjStart = -(FreeStart + ObjSize);
738  LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") scavenged at SP["
739  << ObjStart << "]\n");
740  MFI.setObjectOffset(FrameIdx, ObjStart);
741  } else {
742  LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") scavenged at SP["
743  << FreeStart << "]\n");
744  MFI.setObjectOffset(FrameIdx, FreeStart);
745  }
746 
747  StackBytesFree.reset(FreeStart, FreeStart + ObjSize);
748  return true;
749 }
750 
751 /// AssignProtectedObjSet - Helper function to assign large stack objects (i.e.,
752 /// those required to be close to the Stack Protector) to stack offsets.
753 static void
754 AssignProtectedObjSet(const StackObjSet &UnassignedObjs,
755  SmallSet<int, 16> &ProtectedObjs,
756  MachineFrameInfo &MFI, bool StackGrowsDown,
757  int64_t &Offset, unsigned &MaxAlign, unsigned Skew) {
758 
759  for (StackObjSet::const_iterator I = UnassignedObjs.begin(),
760  E = UnassignedObjs.end(); I != E; ++I) {
761  int i = *I;
762  AdjustStackOffset(MFI, i, StackGrowsDown, Offset, MaxAlign, Skew);
763  ProtectedObjs.insert(i);
764  }
765 }
766 
767 /// calculateFrameObjectOffsets - Calculate actual frame offsets for all of the
768 /// abstract stack objects.
769 void PEI::calculateFrameObjectOffsets(MachineFunction &MF) {
771 
772  bool StackGrowsDown =
774 
775  // Loop over all of the stack objects, assigning sequential addresses...
776  MachineFrameInfo &MFI = MF.getFrameInfo();
777 
778  // Start at the beginning of the local area.
779  // The Offset is the distance from the stack top in the direction
780  // of stack growth -- so it's always nonnegative.
781  int LocalAreaOffset = TFI.getOffsetOfLocalArea();
782  if (StackGrowsDown)
783  LocalAreaOffset = -LocalAreaOffset;
784  assert(LocalAreaOffset >= 0
785  && "Local area offset should be in direction of stack growth");
786  int64_t Offset = LocalAreaOffset;
787 
788  // Skew to be applied to alignment.
789  unsigned Skew = TFI.getStackAlignmentSkew(MF);
790 
791  // If there are fixed sized objects that are preallocated in the local area,
792  // non-fixed objects can't be allocated right at the start of local area.
793  // Adjust 'Offset' to point to the end of last fixed sized preallocated
794  // object.
795  for (int i = MFI.getObjectIndexBegin(); i != 0; ++i) {
796  int64_t FixedOff;
797  if (StackGrowsDown) {
798  // The maximum distance from the stack pointer is at lower address of
799  // the object -- which is given by offset. For down growing stack
800  // the offset is negative, so we negate the offset to get the distance.
801  FixedOff = -MFI.getObjectOffset(i);
802  } else {
803  // The maximum distance from the start pointer is at the upper
804  // address of the object.
805  FixedOff = MFI.getObjectOffset(i) + MFI.getObjectSize(i);
806  }
807  if (FixedOff > Offset) Offset = FixedOff;
808  }
809 
810  // First assign frame offsets to stack objects that are used to spill
811  // callee saved registers.
812  if (StackGrowsDown) {
813  for (unsigned i = MinCSFrameIndex; i <= MaxCSFrameIndex; ++i) {
814  // If the stack grows down, we need to add the size to find the lowest
815  // address of the object.
816  Offset += MFI.getObjectSize(i);
817 
818  unsigned Align = MFI.getObjectAlignment(i);
819  // Adjust to alignment boundary
820  Offset = alignTo(Offset, Align, Skew);
821 
822  LLVM_DEBUG(dbgs() << "alloc FI(" << i << ") at SP[" << -Offset << "]\n");
823  MFI.setObjectOffset(i, -Offset); // Set the computed offset
824  }
825  } else if (MaxCSFrameIndex >= MinCSFrameIndex) {
826  // Be careful about underflow in comparisons agains MinCSFrameIndex.
827  for (unsigned i = MaxCSFrameIndex; i != MinCSFrameIndex - 1; --i) {
828  if (MFI.isDeadObjectIndex(i))
829  continue;
830 
831  unsigned Align = MFI.getObjectAlignment(i);
832  // Adjust to alignment boundary
833  Offset = alignTo(Offset, Align, Skew);
834 
835  LLVM_DEBUG(dbgs() << "alloc FI(" << i << ") at SP[" << Offset << "]\n");
836  MFI.setObjectOffset(i, Offset);
837  Offset += MFI.getObjectSize(i);
838  }
839  }
840 
841  // FixedCSEnd is the stack offset to the end of the fixed and callee-save
842  // stack area.
843  int64_t FixedCSEnd = Offset;
844  unsigned MaxAlign = MFI.getMaxAlignment();
845 
846  // Make sure the special register scavenging spill slot is closest to the
847  // incoming stack pointer if a frame pointer is required and is closer
848  // to the incoming rather than the final stack pointer.
849  const TargetRegisterInfo *RegInfo = MF.getSubtarget().getRegisterInfo();
850  bool EarlyScavengingSlots = (TFI.hasFP(MF) &&
851  TFI.isFPCloseToIncomingSP() &&
852  RegInfo->useFPForScavengingIndex(MF) &&
853  !RegInfo->needsStackRealignment(MF));
854  if (RS && EarlyScavengingSlots) {
855  SmallVector<int, 2> SFIs;
856  RS->getScavengingFrameIndices(SFIs);
857  for (SmallVectorImpl<int>::iterator I = SFIs.begin(),
858  IE = SFIs.end(); I != IE; ++I)
859  AdjustStackOffset(MFI, *I, StackGrowsDown, Offset, MaxAlign, Skew);
860  }
861 
862  // FIXME: Once this is working, then enable flag will change to a target
863  // check for whether the frame is large enough to want to use virtual
864  // frame index registers. Functions which don't want/need this optimization
865  // will continue to use the existing code path.
867  unsigned Align = MFI.getLocalFrameMaxAlign();
868 
869  // Adjust to alignment boundary.
870  Offset = alignTo(Offset, Align, Skew);
871 
872  LLVM_DEBUG(dbgs() << "Local frame base offset: " << Offset << "\n");
873 
874  // Resolve offsets for objects in the local block.
875  for (unsigned i = 0, e = MFI.getLocalFrameObjectCount(); i != e; ++i) {
876  std::pair<int, int64_t> Entry = MFI.getLocalFrameObjectMap(i);
877  int64_t FIOffset = (StackGrowsDown ? -Offset : Offset) + Entry.second;
878  LLVM_DEBUG(dbgs() << "alloc FI(" << Entry.first << ") at SP[" << FIOffset
879  << "]\n");
880  MFI.setObjectOffset(Entry.first, FIOffset);
881  }
882  // Allocate the local block
883  Offset += MFI.getLocalFrameSize();
884 
885  MaxAlign = std::max(Align, MaxAlign);
886  }
887 
888  // Retrieve the Exception Handler registration node.
889  int EHRegNodeFrameIndex = std::numeric_limits<int>::max();
890  if (const WinEHFuncInfo *FuncInfo = MF.getWinEHFuncInfo())
891  EHRegNodeFrameIndex = FuncInfo->EHRegNodeFrameIndex;
892 
893  // Make sure that the stack protector comes before the local variables on the
894  // stack.
895  SmallSet<int, 16> ProtectedObjs;
896  if (MFI.getStackProtectorIndex() >= 0) {
897  StackObjSet LargeArrayObjs;
898  StackObjSet SmallArrayObjs;
899  StackObjSet AddrOfObjs;
900 
901  AdjustStackOffset(MFI, MFI.getStackProtectorIndex(), StackGrowsDown,
902  Offset, MaxAlign, Skew);
903 
904  // Assign large stack objects first.
905  for (unsigned i = 0, e = MFI.getObjectIndexEnd(); i != e; ++i) {
906  if (MFI.isObjectPreAllocated(i) &&
908  continue;
909  if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
910  continue;
911  if (RS && RS->isScavengingFrameIndex((int)i))
912  continue;
913  if (MFI.isDeadObjectIndex(i))
914  continue;
915  if (MFI.getStackProtectorIndex() == (int)i ||
916  EHRegNodeFrameIndex == (int)i)
917  continue;
918 
919  switch (MFI.getObjectSSPLayout(i)) {
921  continue;
923  SmallArrayObjs.insert(i);
924  continue;
926  AddrOfObjs.insert(i);
927  continue;
929  LargeArrayObjs.insert(i);
930  continue;
931  }
932  llvm_unreachable("Unexpected SSPLayoutKind.");
933  }
934 
935  AssignProtectedObjSet(LargeArrayObjs, ProtectedObjs, MFI, StackGrowsDown,
936  Offset, MaxAlign, Skew);
937  AssignProtectedObjSet(SmallArrayObjs, ProtectedObjs, MFI, StackGrowsDown,
938  Offset, MaxAlign, Skew);
939  AssignProtectedObjSet(AddrOfObjs, ProtectedObjs, MFI, StackGrowsDown,
940  Offset, MaxAlign, Skew);
941  }
942 
943  SmallVector<int, 8> ObjectsToAllocate;
944 
945  // Then prepare to assign frame offsets to stack objects that are not used to
946  // spill callee saved registers.
947  for (unsigned i = 0, e = MFI.getObjectIndexEnd(); i != e; ++i) {
949  continue;
950  if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
951  continue;
952  if (RS && RS->isScavengingFrameIndex((int)i))
953  continue;
954  if (MFI.isDeadObjectIndex(i))
955  continue;
956  if (MFI.getStackProtectorIndex() == (int)i ||
957  EHRegNodeFrameIndex == (int)i)
958  continue;
959  if (ProtectedObjs.count(i))
960  continue;
961 
962  // Add the objects that we need to allocate to our working set.
963  ObjectsToAllocate.push_back(i);
964  }
965 
966  // Allocate the EH registration node first if one is present.
967  if (EHRegNodeFrameIndex != std::numeric_limits<int>::max())
968  AdjustStackOffset(MFI, EHRegNodeFrameIndex, StackGrowsDown, Offset,
969  MaxAlign, Skew);
970 
971  // Give the targets a chance to order the objects the way they like it.
972  if (MF.getTarget().getOptLevel() != CodeGenOpt::None &&
974  TFI.orderFrameObjects(MF, ObjectsToAllocate);
975 
976  // Keep track of which bytes in the fixed and callee-save range are used so we
977  // can use the holes when allocating later stack objects. Only do this if
978  // stack protector isn't being used and the target requests it and we're
979  // optimizing.
980  BitVector StackBytesFree;
981  if (!ObjectsToAllocate.empty() &&
984  computeFreeStackSlots(MFI, StackGrowsDown, MinCSFrameIndex, MaxCSFrameIndex,
985  FixedCSEnd, StackBytesFree);
986 
987  // Now walk the objects and actually assign base offsets to them.
988  for (auto &Object : ObjectsToAllocate)
989  if (!scavengeStackSlot(MFI, Object, StackGrowsDown, MaxAlign,
990  StackBytesFree))
991  AdjustStackOffset(MFI, Object, StackGrowsDown, Offset, MaxAlign, Skew);
992 
993  // Make sure the special register scavenging spill slot is closest to the
994  // stack pointer.
995  if (RS && !EarlyScavengingSlots) {
996  SmallVector<int, 2> SFIs;
997  RS->getScavengingFrameIndices(SFIs);
998  for (SmallVectorImpl<int>::iterator I = SFIs.begin(),
999  IE = SFIs.end(); I != IE; ++I)
1000  AdjustStackOffset(MFI, *I, StackGrowsDown, Offset, MaxAlign, Skew);
1001  }
1002 
1003  if (!TFI.targetHandlesStackFrameRounding()) {
1004  // If we have reserved argument space for call sites in the function
1005  // immediately on entry to the current function, count it as part of the
1006  // overall stack size.
1007  if (MFI.adjustsStack() && TFI.hasReservedCallFrame(MF))
1008  Offset += MFI.getMaxCallFrameSize();
1009 
1010  // Round up the size to a multiple of the alignment. If the function has
1011  // any calls or alloca's, align to the target's StackAlignment value to
1012  // ensure that the callee's frame or the alloca data is suitably aligned;
1013  // otherwise, for leaf functions, align to the TransientStackAlignment
1014  // value.
1015  unsigned StackAlign;
1016  if (MFI.adjustsStack() || MFI.hasVarSizedObjects() ||
1017  (RegInfo->needsStackRealignment(MF) && MFI.getObjectIndexEnd() != 0))
1018  StackAlign = TFI.getStackAlignment();
1019  else
1020  StackAlign = TFI.getTransientStackAlignment();
1021 
1022  // If the frame pointer is eliminated, all frame offsets will be relative to
1023  // SP not FP. Align to MaxAlign so this works.
1024  StackAlign = std::max(StackAlign, MaxAlign);
1025  Offset = alignTo(Offset, StackAlign, Skew);
1026  }
1027 
1028  // Update frame info to pretend that this is part of the stack...
1029  int64_t StackSize = Offset - LocalAreaOffset;
1030  MFI.setStackSize(StackSize);
1031  NumBytesStackSpace += StackSize;
1032 }
1033 
1034 /// insertPrologEpilogCode - Scan the function for modified callee saved
1035 /// registers, insert spill code for these callee saved registers, then add
1036 /// prolog and epilog code to the function.
1037 void PEI::insertPrologEpilogCode(MachineFunction &MF) {
1038  const TargetFrameLowering &TFI = *MF.getSubtarget().getFrameLowering();
1039 
1040  // Add prologue to the function...
1041  for (MachineBasicBlock *SaveBlock : SaveBlocks)
1042  TFI.emitPrologue(MF, *SaveBlock);
1043 
1044  // Add epilogue to restore the callee-save registers in each exiting block.
1045  for (MachineBasicBlock *RestoreBlock : RestoreBlocks)
1046  TFI.emitEpilogue(MF, *RestoreBlock);
1047 
1048  for (MachineBasicBlock *SaveBlock : SaveBlocks)
1049  TFI.inlineStackProbe(MF, *SaveBlock);
1050 
1051  // Emit additional code that is required to support segmented stacks, if
1052  // we've been asked for it. This, when linked with a runtime with support
1053  // for segmented stacks (libgcc is one), will result in allocating stack
1054  // space in small chunks instead of one large contiguous block.
1055  if (MF.shouldSplitStack()) {
1056  for (MachineBasicBlock *SaveBlock : SaveBlocks)
1057  TFI.adjustForSegmentedStacks(MF, *SaveBlock);
1058  // Record that there are split-stack functions, so we will emit a
1059  // special section to tell the linker.
1060  MF.getMMI().setHasSplitStack(true);
1061  } else
1062  MF.getMMI().setHasNosplitStack(true);
1063 
1064  // Emit additional code that is required to explicitly handle the stack in
1065  // HiPE native code (if needed) when loaded in the Erlang/OTP runtime. The
1066  // approach is rather similar to that of Segmented Stacks, but it uses a
1067  // different conditional check and another BIF for allocating more stack
1068  // space.
1070  for (MachineBasicBlock *SaveBlock : SaveBlocks)
1071  TFI.adjustForHiPEPrologue(MF, *SaveBlock);
1072 }
1073 
1074 /// replaceFrameIndices - Replace all MO_FrameIndex operands with physical
1075 /// register references and actual offsets.
1076 void PEI::replaceFrameIndices(MachineFunction &MF) {
1077  const TargetFrameLowering &TFI = *MF.getSubtarget().getFrameLowering();
1078  if (!TFI.needsFrameIndexResolution(MF)) return;
1079 
1080  // Store SPAdj at exit of a basic block.
1081  SmallVector<int, 8> SPState;
1082  SPState.resize(MF.getNumBlockIDs());
1084 
1085  // Iterate over the reachable blocks in DFS order.
1086  for (auto DFI = df_ext_begin(&MF, Reachable), DFE = df_ext_end(&MF, Reachable);
1087  DFI != DFE; ++DFI) {
1088  int SPAdj = 0;
1089  // Check the exit state of the DFS stack predecessor.
1090  if (DFI.getPathLength() >= 2) {
1091  MachineBasicBlock *StackPred = DFI.getPath(DFI.getPathLength() - 2);
1092  assert(Reachable.count(StackPred) &&
1093  "DFS stack predecessor is already visited.\n");
1094  SPAdj = SPState[StackPred->getNumber()];
1095  }
1096  MachineBasicBlock *BB = *DFI;
1097  replaceFrameIndices(BB, MF, SPAdj);
1098  SPState[BB->getNumber()] = SPAdj;
1099  }
1100 
1101  // Handle the unreachable blocks.
1102  for (auto &BB : MF) {
1103  if (Reachable.count(&BB))
1104  // Already handled in DFS traversal.
1105  continue;
1106  int SPAdj = 0;
1107  replaceFrameIndices(&BB, MF, SPAdj);
1108  }
1109 }
1110 
1111 void PEI::replaceFrameIndices(MachineBasicBlock *BB, MachineFunction &MF,
1112  int &SPAdj) {
1114  "getRegisterInfo() must be implemented!");
1115  const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
1118 
1119  if (RS && FrameIndexEliminationScavenging)
1120  RS->enterBasicBlock(*BB);
1121 
1122  bool InsideCallSequence = false;
1123 
1124  for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ) {
1125  if (TII.isFrameInstr(*I)) {
1126  InsideCallSequence = TII.isFrameSetup(*I);
1127  SPAdj += TII.getSPAdjust(*I);
1128  I = TFI->eliminateCallFramePseudoInstr(MF, *BB, I);
1129  continue;
1130  }
1131 
1132  MachineInstr &MI = *I;
1133  bool DoIncr = true;
1134  bool DidFinishLoop = true;
1135  for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
1136  if (!MI.getOperand(i).isFI())
1137  continue;
1138 
1139  // Frame indices in debug values are encoded in a target independent
1140  // way with simply the frame index and offset rather than any
1141  // target-specific addressing mode.
1142  if (MI.isDebugValue()) {
1143  assert(i == 0 && "Frame indices can only appear as the first "
1144  "operand of a DBG_VALUE machine instruction");
1145  unsigned Reg;
1146  int64_t Offset =
1147  TFI->getFrameIndexReference(MF, MI.getOperand(0).getIndex(), Reg);
1148  MI.getOperand(0).ChangeToRegister(Reg, false /*isDef*/);
1149  MI.getOperand(0).setIsDebug();
1150  auto *DIExpr = DIExpression::prepend(MI.getDebugExpression(),
1152  MI.getOperand(3).setMetadata(DIExpr);
1153  continue;
1154  }
1155 
1156  // TODO: This code should be commoned with the code for
1157  // PATCHPOINT. There's no good reason for the difference in
1158  // implementation other than historical accident. The only
1159  // remaining difference is the unconditional use of the stack
1160  // pointer as the base register.
1161  if (MI.getOpcode() == TargetOpcode::STATEPOINT) {
1162  assert((!MI.isDebugValue() || i == 0) &&
1163  "Frame indicies can only appear as the first operand of a "
1164  "DBG_VALUE machine instruction");
1165  unsigned Reg;
1166  MachineOperand &Offset = MI.getOperand(i + 1);
1167  int refOffset = TFI->getFrameIndexReferencePreferSP(
1168  MF, MI.getOperand(i).getIndex(), Reg, /*IgnoreSPUpdates*/ false);
1169  Offset.setImm(Offset.getImm() + refOffset + SPAdj);
1170  MI.getOperand(i).ChangeToRegister(Reg, false /*isDef*/);
1171  continue;
1172  }
1173 
1174  // Some instructions (e.g. inline asm instructions) can have
1175  // multiple frame indices and/or cause eliminateFrameIndex
1176  // to insert more than one instruction. We need the register
1177  // scavenger to go through all of these instructions so that
1178  // it can update its register information. We keep the
1179  // iterator at the point before insertion so that we can
1180  // revisit them in full.
1181  bool AtBeginning = (I == BB->begin());
1182  if (!AtBeginning) --I;
1183 
1184  // If this instruction has a FrameIndex operand, we need to
1185  // use that target machine register info object to eliminate
1186  // it.
1187  TRI.eliminateFrameIndex(MI, SPAdj, i,
1188  FrameIndexEliminationScavenging ? RS : nullptr);
1189 
1190  // Reset the iterator if we were at the beginning of the BB.
1191  if (AtBeginning) {
1192  I = BB->begin();
1193  DoIncr = false;
1194  }
1195 
1196  DidFinishLoop = false;
1197  break;
1198  }
1199 
1200  // If we are looking at a call sequence, we need to keep track of
1201  // the SP adjustment made by each instruction in the sequence.
1202  // This includes both the frame setup/destroy pseudos (handled above),
1203  // as well as other instructions that have side effects w.r.t the SP.
1204  // Note that this must come after eliminateFrameIndex, because
1205  // if I itself referred to a frame index, we shouldn't count its own
1206  // adjustment.
1207  if (DidFinishLoop && InsideCallSequence)
1208  SPAdj += TII.getSPAdjust(MI);
1209 
1210  if (DoIncr && I != BB->end()) ++I;
1211 
1212  // Update register states.
1213  if (RS && FrameIndexEliminationScavenging && DidFinishLoop)
1214  RS->forward(MI);
1215  }
1216 }
unsigned StackSymbolOrdering
StackSymbolOrdering - When true, this will allow CodeGen to order the local stack symbols (for code s...
void resize(unsigned N, bool t=false)
resize - Grow or shrink the bitvector.
Definition: BitVector.h:371
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
void setSavePoint(MachineBasicBlock *NewSave)
void setRestorePoint(MachineBasicBlock *NewRestore)
virtual bool requiresRegisterScavenging(const MachineFunction &MF) const
Returns true if the target requires (and can make use of) the register scavenger. ...
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static void AdjustStackOffset(MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, int64_t &Offset, unsigned &MaxAlign, unsigned Skew)
AdjustStackOffset - Helper function used to adjust the stack frame offset.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
void setCalleeSavedInfoValid(bool v)
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool empty() const
empty - Tests whether there are no bits in this bitvector.
Definition: BitVector.h:166
static void computeFreeStackSlots(MachineFrameInfo &MFI, bool StackGrowsDown, unsigned MinCSFrameIndex, unsigned MaxCSFrameIndex, int64_t FixedCSEnd, BitVector &StackBytesFree)
Compute which bytes of fixed and callee-save stack area are unused and keep track of them in StackByt...
void ChangeToRegister(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
Did not trigger a stack protector.
virtual int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
virtual bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg, int &FrameIdx) const
Return true if target has reserved a spill slot in the stack frame of the given function for the spec...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID&#39;s allocated.
static void updateLiveness(MachineFunction &MF)
Helper function to update the liveness information for the callee-saved registers.
const MachineFunctionProperties & getProperties() const
Get the function properties.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
virtual void adjustForHiPEPrologue(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Adjust the prologue to add Erlang Run-Time System (ERTS) specific code in the assembly prologue to ex...
static void insertCSRSaves(MachineBasicBlock &SaveBlock, ArrayRef< CalleeSavedInfo > CSI)
Insert restore code for the callee-saved registers used in the function.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
virtual bool canSimplifyCallFramePseudos(const MachineFunction &MF) const
canSimplifyCallFramePseudos - When possible, it&#39;s best to simplify the call frame pseudo ops before d...
int64_t getLocalFrameSize() const
Get the size of the local object blob.
unsigned Reg
bool test(unsigned Idx) const
Definition: BitVector.h:501
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:320
virtual MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
F(f)
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
MachineModuleInfo & getMMI() const
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Definition: MathExtras.h:684
unsigned getCallFrameDestroyOpcode() const
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
virtual int getFrameIndexReferencePreferSP(const MachineFunction &MF, int FI, unsigned &FrameReg, bool IgnoreSPUpdates) const
Same as getFrameIndexReference, except that the stack pointer (as opposed to the frame pointer) will ...
iterator end()
Get an iterator to the end of the SetVector.
Definition: SetVector.h:92
int CreateStackObject(uint64_t Size, unsigned 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...
unsigned getSpillSize(const TargetRegisterClass &RC) const
Return the size in bytes of the stack slot allocated to hold a spilled copy of a register from class ...
static DIExpression * prepend(const DIExpression *Expr, bool DerefBefore, int64_t Offset=0, bool DerefAfter=false, bool StackValue=false)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value...
iterator_range< succ_iterator > successors()
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
virtual void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS=nullptr) const
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
bool isVariableSizedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a variable sized object.
unsigned getSpillAlignment(const TargetRegisterClass &RC) const
Return the minimum required alignment in bytes for a spill slot for a register of this class...
virtual const SpillSlot * getCalleeSavedSpillSlots(unsigned &NumEntries) const
getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry...
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:50
void clear()
clear - Removes all bits from the bitvector. Does not change capacity.
Definition: BitVector.h:366
std::pair< int, int64_t > getLocalFrameObjectMap(int i) const
Get the local offset mapping for a for an object.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
virtual bool usesPhysRegsForPEI() const
True if the target uses physical regs at Prolog/Epilog insertion time.
unsigned getNumOperands() const
Retuns the total number of operands.
Definition: MachineInstr.h:411
MachineBasicBlock * getRestorePoint() const
int find_first() const
find_first - Returns the index of the first set bit, -1 if none of the bits are set.
Definition: BitVector.h:331
virtual bool hasFP(const MachineFunction &MF) const =0
hasFP - Return true if the specified function should have a dedicated frame pointer register...
virtual bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
The address of this allocation is exposed and triggered protection.
virtual bool requiresFrameIndexScavenging(const MachineFunction &MF) const
Returns true if the target requires post PEI scavenging of registers for materializing frame index co...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:41
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
static cl::opt< unsigned > WarnStackSize("warn-stack-size", cl::Hidden, cl::init((unsigned) -1), cl::desc("Warn for stack size bigger than the given" " number"))
int find_next(unsigned Prev) const
find_next - Returns the index of the next set bit following the "Prev" bit.
Definition: BitVector.h:339
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1199
This file contains the simple types necessary to represent the attributes associated with functions a...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:408
MachineFunctionPass * createPrologEpilogInserterPass()
virtual unsigned getStackAlignmentSkew(const MachineFunction &MF) const
Return the skew that has to be applied to stack alignment under certain conditions (e...
void scavengeFrameVirtualRegs(MachineFunction &MF, RegScavenger &RS)
Replaces all frame index virtual registers with physical registers.
Diagnostic information for optimization analysis remarks.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
Definition: STLExtras.h:266
bool getUseLocalStackAllocationBlock() const
Get whether the local allocation blob should be allocated together or let PEI allocate the locals in ...
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition: SetVector.h:141
virtual bool targetHandlesStackFrameRounding() const
targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack...
virtual bool needsFrameIndexResolution(const MachineFunction &MF) const
iterator begin()
Get an iterator to the beginning of the SetVector.
Definition: SetVector.h:82
int getObjectIndexBegin() const
Return the minimum frame object index.
bool isObjectPreAllocated(int ObjectIdx) const
Return true if the object was pre-allocated into the local block.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
int getObjectIndexEnd() const
Return one past the maximum frame object index.
SSPLayoutKind getObjectSSPLayout(int ObjectIdx) const
virtual void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const =0
This method must be overriden to eliminate abstract frame indices from instructions which may use the...
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they&#39;re not in a MachineFuncti...
virtual const TargetInstrInfo * getInstrInfo() const
static void stashEntryDbgValues(MachineBasicBlock &MBB, SavedDbgValuesMap &EntryDbgValues)
Stash DBG_VALUEs that describe parameters and which are placed at the start of the block...
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
virtual void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Adjust the prologue to have the function use segmented stacks.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
TargetInstrInfo - Interface to description of machine instruction set.
Array or nested array >= SSP-buffer-size.
virtual void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
===- MachineOptimizationRemarkEmitter.h - Opt Diagnostics -*- C++ -*-—===//
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:422
This file declares the machine register scavenger class.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
unsigned const MachineRegisterInfo * MRI
void initializePEIPass(PassRegistry &)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
DISubprogram * getSubprogram() const
Get the attached subprogram.
Definition: Metadata.cpp:1507
df_ext_iterator< T, SetTy > df_ext_end(const T &G, SetTy &S)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void setStackSize(uint64_t Size)
Set the size of the stack.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:134
StackDirection getStackGrowthDirection() const
getStackGrowthDirection - Return the direction the stack grows
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:370
int getStackProtectorIndex() const
Return the index for the stack protector object.
unsigned getCallFrameSetupOpcode() const
These methods return the opcode of the frame setup/destroy instructions if they exist (-1 otherwise)...
Represent the analysis usage information of a pass.
df_ext_iterator< T, SetTy > df_ext_begin(const T &G, SetTy &S)
BitVector & reset()
Definition: BitVector.h:438
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
void setImm(int64_t immVal)
static bool scavengeStackSlot(MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, unsigned MaxAlign, BitVector &StackBytesFree)
Assign frame object to an unused portion of the stack in the fixed stack object range.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition: SmallPtrSet.h:381
static void assignCalleeSavedSpillSlots(MachineFunction &F, const BitVector &SavedRegs, unsigned &MinCSFrameIndex, unsigned &MaxCSFrameIndex)
INITIALIZE_PASS_BEGIN(PEI, DEBUG_TYPE, "Prologue/Epilogue Insertion", false, false) INITIALIZE_PASS_END(PEI
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn&#39;t already there.
Definition: SmallSet.h:180
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Definition: Function.cpp:192
Used in the streaming interface as the general argument type.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MachineBasicBlock & front() const
typename vector_type::const_iterator const_iterator
Definition: SetVector.h:49
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
A SetVector that performs no allocations if smaller than a certain size.
Definition: SetVector.h:297
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Definition: SmallPtrSet.h:417
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
The optimization diagnostic interface.
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:212
virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
bool isDebugValue() const
Definition: MachineInstr.h:996
MachineOperand class - Representation of each machine instruction operand.
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:839
Prologue Epilogue Insertion &Frame Finalization
bool isFrameInstr(const MachineInstr &I) const
Returns true if the argument is a frame pseudo instruction.
Information about stack frame layout on the target.
int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset, bool IsImmutable=false)
Create a spill slot at a fixed location on the stack.
LLVM_NODISCARD T pop_back_val()
Definition: SmallVector.h:373
const WinEHFuncInfo * getWinEHFuncInfo() const
getWinEHFuncInfo - Return information about how the current function uses Windows exception handling...
static void insertCSRRestores(MachineBasicBlock &RestoreBlock, std::vector< CalleeSavedInfo > &CSI)
Insert restore code for the callee-saved registers used in the function.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition: Pass.cpp:285
int64_t getFrameSize(const MachineInstr &I) const
Returns size of the frame associated with the given frame instruction.
int64_t getImm() const
void setMetadata(const MDNode *MD)
DWARF expression.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
unsigned getTransientStackAlignment() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
virtual bool useFPForScavengingIndex(const MachineFunction &MF) const
Returns true if the target wants to use frame pointer based accesses to spill to the scavenger emerge...
bool fragmentsOverlap(const DIExpression *Other) const
Check if fragments overlap between this DIExpression and Other.
virtual void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
Store the specified register of the given register class to the specified stack frame index...
char & PrologEpilogCodeInserterID
PrologEpilogCodeInserter - This pass inserts prolog and epilog code, and eliminates abstract frame re...
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
bool none() const
none - Returns true if none of the bits are set.
Definition: BitVector.h:201
#define DEBUG_TYPE
virtual bool isFPCloseToIncomingSP() const
isFPCloseToIncomingSP - Return true if the frame pointer is close to the incoming stack pointer...
Representation of each machine instruction.
Definition: MachineInstr.h:63
virtual bool enableStackSlotScavenging(const MachineFunction &MF) const
Returns true if the stack slot holes in the fixed and callee-save stack area should be used when allo...
void setCalleeSavedInfo(const std::vector< CalleeSavedInfo > &CSI)
Used by prolog/epilog inserter to set the function&#39;s callee saved information.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
virtual bool requiresFrameIndexReplacementScavenging(const MachineFunction &MF) const
Returns true if the target requires using the RegScavenger directly for frame elimination despite usi...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:55
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
TargetOptions Options
Definition: TargetMachine.h:96
void push_back(MachineInstr *MI)
#define I(x, y, z)
Definition: MD5.cpp:58
void setMaxCallFrameSize(unsigned S)
unsigned getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
virtual const TargetFrameLowering * getFrameLowering() const
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
size_type size() const
size - Returns the number of bits in this bitvector.
Definition: BitVector.h:169
uint32_t Size
Definition: Profile.cpp:46
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: DenseMap.h:171
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
virtual void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Replace a StackProbe stub (if any) with the actual probe code inline.
MachineBasicBlock * getSavePoint() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasProperty(Property P) const
bool needsStackRealignment(const MachineFunction &MF) const
True if storage within the function requires the stack pointer to be aligned more than the normal cal...
Array or nested array < SSP-buffer-size.
const MCPhysReg * getCalleeSavedRegs() const
Returns list of callee saved registers.
virtual void orderFrameObjects(const MachineFunction &MF, SmallVectorImpl< int > &objectsToAllocate) const
Order the symbols in the local stack frame.
bool isMaxCallFrameSizeComputed() const
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
IRTranslator LLVM IR MI
void setIsDebug(bool Val=true)
#define LLVM_DEBUG(X)
Definition: Debug.h:122
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:413
int64_t getLocalFrameObjectCount() const
Return the number of objects allocated into the local object block.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
static void AssignProtectedObjSet(const StackObjSet &UnassignedObjs, SmallSet< int, 16 > &ProtectedObjs, MachineFrameInfo &MFI, bool StackGrowsDown, int64_t &Offset, unsigned &MaxAlign, unsigned Skew)
AssignProtectedObjSet - Helper function to assign large stack objects (i.e., those required to be clo...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
Load the specified register of the given register class from the specified stack frame index...
bool isReserved(unsigned PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
bool hasCalls() const
Return true if the current function has any function calls.
void resize(size_type N)
Definition: SmallVector.h:343