LLVM  5.0.0
MachineFunction.cpp
Go to the documentation of this file.
1 //===-- MachineFunction.cpp -----------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Collect native machine code information for a function. This allows
11 // target-specific information about the generated code to be stored with each
12 // function.
13 //
14 //===----------------------------------------------------------------------===//
15 
17 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/ADT/SmallString.h"
28 #include "llvm/CodeGen/Passes.h"
31 #include "llvm/IR/DataLayout.h"
32 #include "llvm/IR/DebugInfo.h"
33 #include "llvm/IR/Function.h"
34 #include "llvm/IR/Module.h"
36 #include "llvm/MC/MCAsmInfo.h"
37 #include "llvm/MC/MCContext.h"
38 #include "llvm/Support/Debug.h"
45 using namespace llvm;
46 
47 #define DEBUG_TYPE "codegen"
48 
49 static cl::opt<unsigned>
50  AlignAllFunctions("align-all-functions",
51  cl::desc("Force the alignment of all functions."),
52  cl::init(0), cl::Hidden);
53 
56  switch(Prop) {
57  case P::FailedISel: return "FailedISel";
58  case P::IsSSA: return "IsSSA";
59  case P::Legalized: return "Legalized";
60  case P::NoPHIs: return "NoPHIs";
61  case P::NoVRegs: return "NoVRegs";
62  case P::RegBankSelected: return "RegBankSelected";
63  case P::Selected: return "Selected";
64  case P::TracksLiveness: return "TracksLiveness";
65  }
66  llvm_unreachable("Invalid machine function property");
67 }
68 
70  const char *Separator = "";
71  for (BitVector::size_type I = 0; I < Properties.size(); ++I) {
72  if (!Properties[I])
73  continue;
74  OS << Separator << getPropertyName(static_cast<Property>(I));
75  Separator = ", ";
76  }
77 }
78 
79 //===----------------------------------------------------------------------===//
80 // MachineFunction implementation
81 //===----------------------------------------------------------------------===//
82 
83 // Out-of-line virtual method.
85 
88 }
89 
90 static inline unsigned getFnStackAlignment(const TargetSubtargetInfo *STI,
91  const Function *Fn) {
92  if (Fn->hasFnAttribute(Attribute::StackAlignment))
93  return Fn->getFnStackAlignment();
94  return STI->getFrameLowering()->getStackAlignment();
95 }
96 
98  unsigned FunctionNum, MachineModuleInfo &mmi)
99  : Fn(F), Target(TM), STI(TM.getSubtargetImpl(*F)), Ctx(mmi.getContext()),
100  MMI(mmi) {
101  FunctionNumber = FunctionNum;
102  init();
103 }
104 
105 void MachineFunction::init() {
106  // Assume the function starts in SSA form with correct liveness.
109  if (STI->getRegisterInfo())
110  RegInfo = new (Allocator) MachineRegisterInfo(this);
111  else
112  RegInfo = nullptr;
113 
114  MFInfo = nullptr;
115  // We can realign the stack if the target supports it and the user hasn't
116  // explicitly asked us not to.
117  bool CanRealignSP = STI->getFrameLowering()->isStackRealignable() &&
118  !Fn->hasFnAttribute("no-realign-stack");
119  FrameInfo = new (Allocator) MachineFrameInfo(
120  getFnStackAlignment(STI, Fn), /*StackRealignable=*/CanRealignSP,
121  /*ForceRealign=*/CanRealignSP &&
122  Fn->hasFnAttribute(Attribute::StackAlignment));
123 
124  if (Fn->hasFnAttribute(Attribute::StackAlignment))
125  FrameInfo->ensureMaxAlignment(Fn->getFnStackAlignment());
126 
127  ConstantPool = new (Allocator) MachineConstantPool(getDataLayout());
128  Alignment = STI->getTargetLowering()->getMinFunctionAlignment();
129 
130  // FIXME: Shouldn't use pref alignment if explicit alignment is set on Fn.
131  // FIXME: Use Function::optForSize().
132  if (!Fn->hasFnAttribute(Attribute::OptimizeForSize))
133  Alignment = std::max(Alignment,
135 
136  if (AlignAllFunctions)
137  Alignment = AlignAllFunctions;
138 
139  JumpTableInfo = nullptr;
140 
142  Fn->hasPersonalityFn() ? Fn->getPersonalityFn() : nullptr))) {
143  WinEHInfo = new (Allocator) WinEHFuncInfo();
144  }
145 
146  assert(Target.isCompatibleDataLayout(getDataLayout()) &&
147  "Can't create a MachineFunction using a Module with a "
148  "Target-incompatible DataLayout attached\n");
149 
150  PSVManager = llvm::make_unique<PseudoSourceValueManager>();
151 }
152 
154  clear();
155 }
156 
157 void MachineFunction::clear() {
158  Properties.reset();
159  // Don't call destructors on MachineInstr and MachineOperand. All of their
160  // memory comes from the BumpPtrAllocator which is about to be purged.
161  //
162  // Do call MachineBasicBlock destructors, it contains std::vectors.
163  for (iterator I = begin(), E = end(); I != E; I = BasicBlocks.erase(I))
164  I->Insts.clearAndLeakNodesUnsafely();
165 
166  InstructionRecycler.clear(Allocator);
167  OperandRecycler.clear(Allocator);
168  BasicBlockRecycler.clear(Allocator);
170  if (RegInfo) {
171  RegInfo->~MachineRegisterInfo();
172  Allocator.Deallocate(RegInfo);
173  }
174  if (MFInfo) {
175  MFInfo->~MachineFunctionInfo();
176  Allocator.Deallocate(MFInfo);
177  }
178 
179  FrameInfo->~MachineFrameInfo();
180  Allocator.Deallocate(FrameInfo);
181 
182  ConstantPool->~MachineConstantPool();
183  Allocator.Deallocate(ConstantPool);
184 
185  if (JumpTableInfo) {
186  JumpTableInfo->~MachineJumpTableInfo();
187  Allocator.Deallocate(JumpTableInfo);
188  }
189 
190  if (WinEHInfo) {
191  WinEHInfo->~WinEHFuncInfo();
192  Allocator.Deallocate(WinEHInfo);
193  }
194 }
195 
197  return Fn->getParent()->getDataLayout();
198 }
199 
200 /// Get the JumpTableInfo for this function.
201 /// If it does not already exist, allocate one.
203 getOrCreateJumpTableInfo(unsigned EntryKind) {
204  if (JumpTableInfo) return JumpTableInfo;
205 
206  JumpTableInfo = new (Allocator)
208  return JumpTableInfo;
209 }
210 
211 /// Should we be emitting segmented stack stuff for the function
213  return getFunction()->hasFnAttribute("split-stack");
214 }
215 
216 /// This discards all of the MachineBasicBlock numbers and recomputes them.
217 /// This guarantees that the MBB numbers are sequential, dense, and match the
218 /// ordering of the blocks within the function. If a specific MachineBasicBlock
219 /// is specified, only that block and those after it are renumbered.
221  if (empty()) { MBBNumbering.clear(); return; }
222  MachineFunction::iterator MBBI, E = end();
223  if (MBB == nullptr)
224  MBBI = begin();
225  else
226  MBBI = MBB->getIterator();
227 
228  // Figure out the block number this should have.
229  unsigned BlockNo = 0;
230  if (MBBI != begin())
231  BlockNo = std::prev(MBBI)->getNumber() + 1;
232 
233  for (; MBBI != E; ++MBBI, ++BlockNo) {
234  if (MBBI->getNumber() != (int)BlockNo) {
235  // Remove use of the old number.
236  if (MBBI->getNumber() != -1) {
237  assert(MBBNumbering[MBBI->getNumber()] == &*MBBI &&
238  "MBB number mismatch!");
239  MBBNumbering[MBBI->getNumber()] = nullptr;
240  }
241 
242  // If BlockNo is already taken, set that block's number to -1.
243  if (MBBNumbering[BlockNo])
244  MBBNumbering[BlockNo]->setNumber(-1);
245 
246  MBBNumbering[BlockNo] = &*MBBI;
247  MBBI->setNumber(BlockNo);
248  }
249  }
250 
251  // Okay, all the blocks are renumbered. If we have compactified the block
252  // numbering, shrink MBBNumbering now.
253  assert(BlockNo <= MBBNumbering.size() && "Mismatch!");
254  MBBNumbering.resize(BlockNo);
255 }
256 
257 /// Allocate a new MachineInstr. Use this instead of `new MachineInstr'.
259  const DebugLoc &DL,
260  bool NoImp) {
261  return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
262  MachineInstr(*this, MCID, DL, NoImp);
263 }
264 
265 /// Create a new MachineInstr which is a copy of the 'Orig' instruction,
266 /// identical in all ways except the instruction has no parent, prev, or next.
267 MachineInstr *
269  return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
270  MachineInstr(*this, *Orig);
271 }
272 
273 /// Delete the given MachineInstr.
274 ///
275 /// This function also serves as the MachineInstr destructor - the real
276 /// ~MachineInstr() destructor must be empty.
277 void
279  // Strip it for parts. The operand array and the MI object itself are
280  // independently recyclable.
281  if (MI->Operands)
282  deallocateOperandArray(MI->CapOperands, MI->Operands);
283  // Don't call ~MachineInstr() which must be trivial anyway because
284  // ~MachineFunction drops whole lists of MachineInstrs wihout calling their
285  // destructors.
286  InstructionRecycler.Deallocate(Allocator, MI);
287 }
288 
289 /// Allocate a new MachineBasicBlock. Use this instead of
290 /// `new MachineBasicBlock'.
293  return new (BasicBlockRecycler.Allocate<MachineBasicBlock>(Allocator))
294  MachineBasicBlock(*this, bb);
295 }
296 
297 /// Delete the given MachineBasicBlock.
298 void
300  assert(MBB->getParent() == this && "MBB parent mismatch!");
301  MBB->~MachineBasicBlock();
302  BasicBlockRecycler.Deallocate(Allocator, MBB);
303 }
304 
306  MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s,
307  unsigned base_alignment, const AAMDNodes &AAInfo, const MDNode *Ranges,
308  SyncScope::ID SSID, AtomicOrdering Ordering,
309  AtomicOrdering FailureOrdering) {
310  return new (Allocator)
311  MachineMemOperand(PtrInfo, f, s, base_alignment, AAInfo, Ranges,
312  SSID, Ordering, FailureOrdering);
313 }
314 
317  int64_t Offset, uint64_t Size) {
318  if (MMO->getValue())
319  return new (Allocator)
321  MMO->getOffset()+Offset),
322  MMO->getFlags(), Size, MMO->getBaseAlignment(),
323  AAMDNodes(), nullptr, MMO->getSyncScopeID(),
324  MMO->getOrdering(), MMO->getFailureOrdering());
325  return new (Allocator)
327  MMO->getOffset()+Offset),
328  MMO->getFlags(), Size, MMO->getBaseAlignment(),
329  AAMDNodes(), nullptr, MMO->getSyncScopeID(),
330  MMO->getOrdering(), MMO->getFailureOrdering());
331 }
332 
335  const AAMDNodes &AAInfo) {
336  MachinePointerInfo MPI = MMO->getValue() ?
337  MachinePointerInfo(MMO->getValue(), MMO->getOffset()) :
339 
340  return new (Allocator)
341  MachineMemOperand(MPI, MMO->getFlags(), MMO->getSize(),
342  MMO->getBaseAlignment(), AAInfo,
343  MMO->getRanges(), MMO->getSyncScopeID(),
344  MMO->getOrdering(), MMO->getFailureOrdering());
345 }
346 
349  return Allocator.Allocate<MachineMemOperand *>(Num);
350 }
351 
352 std::pair<MachineInstr::mmo_iterator, MachineInstr::mmo_iterator>
355  // Count the number of load mem refs.
356  unsigned Num = 0;
357  for (MachineInstr::mmo_iterator I = Begin; I != End; ++I)
358  if ((*I)->isLoad())
359  ++Num;
360 
361  // Allocate a new array and populate it with the load information.
363  unsigned Index = 0;
364  for (MachineInstr::mmo_iterator I = Begin; I != End; ++I) {
365  if ((*I)->isLoad()) {
366  if (!(*I)->isStore())
367  // Reuse the MMO.
368  Result[Index] = *I;
369  else {
370  // Clone the MMO and unset the store flag.
371  MachineMemOperand *JustLoad =
372  getMachineMemOperand((*I)->getPointerInfo(),
373  (*I)->getFlags() & ~MachineMemOperand::MOStore,
374  (*I)->getSize(), (*I)->getBaseAlignment(),
375  (*I)->getAAInfo(), nullptr,
376  (*I)->getSyncScopeID(), (*I)->getOrdering(),
377  (*I)->getFailureOrdering());
378  Result[Index] = JustLoad;
379  }
380  ++Index;
381  }
382  }
383  return std::make_pair(Result, Result + Num);
384 }
385 
386 std::pair<MachineInstr::mmo_iterator, MachineInstr::mmo_iterator>
389  // Count the number of load mem refs.
390  unsigned Num = 0;
391  for (MachineInstr::mmo_iterator I = Begin; I != End; ++I)
392  if ((*I)->isStore())
393  ++Num;
394 
395  // Allocate a new array and populate it with the store information.
397  unsigned Index = 0;
398  for (MachineInstr::mmo_iterator I = Begin; I != End; ++I) {
399  if ((*I)->isStore()) {
400  if (!(*I)->isLoad())
401  // Reuse the MMO.
402  Result[Index] = *I;
403  else {
404  // Clone the MMO and unset the load flag.
405  MachineMemOperand *JustStore =
406  getMachineMemOperand((*I)->getPointerInfo(),
407  (*I)->getFlags() & ~MachineMemOperand::MOLoad,
408  (*I)->getSize(), (*I)->getBaseAlignment(),
409  (*I)->getAAInfo(), nullptr,
410  (*I)->getSyncScopeID(), (*I)->getOrdering(),
411  (*I)->getFailureOrdering());
412  Result[Index] = JustStore;
413  }
414  ++Index;
415  }
416  }
417  return std::make_pair(Result, Result + Num);
418 }
419 
421  char *Dest = Allocator.Allocate<char>(Name.size() + 1);
422  std::copy(Name.begin(), Name.end(), Dest);
423  Dest[Name.size()] = 0;
424  return Dest;
425 }
426 
427 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
429  print(dbgs());
430 }
431 #endif
432 
434  assert(getFunction() && "No function!");
435  return getFunction()->getName();
436 }
437 
438 void MachineFunction::print(raw_ostream &OS, const SlotIndexes *Indexes) const {
439  OS << "# Machine code for function " << getName() << ": ";
440  getProperties().print(OS);
441  OS << '\n';
442 
443  // Print Frame Information
444  FrameInfo->print(*this, OS);
445 
446  // Print JumpTable Information
447  if (JumpTableInfo)
448  JumpTableInfo->print(OS);
449 
450  // Print Constant Pool
451  ConstantPool->print(OS);
452 
454 
455  if (RegInfo && !RegInfo->livein_empty()) {
456  OS << "Function Live Ins: ";
458  I = RegInfo->livein_begin(), E = RegInfo->livein_end(); I != E; ++I) {
459  OS << PrintReg(I->first, TRI);
460  if (I->second)
461  OS << " in " << PrintReg(I->second, TRI);
462  if (std::next(I) != E)
463  OS << ", ";
464  }
465  OS << '\n';
466  }
467 
470  for (const auto &BB : *this) {
471  OS << '\n';
472  BB.print(OS, MST, Indexes);
473  }
474 
475  OS << "\n# End machine code for function " << getName() << ".\n\n";
476 }
477 
478 namespace llvm {
479  template<>
481 
483 
484  static std::string getGraphName(const MachineFunction *F) {
485  return ("CFG for '" + F->getName() + "' function").str();
486  }
487 
488  std::string getNodeLabel(const MachineBasicBlock *Node,
489  const MachineFunction *Graph) {
490  std::string OutStr;
491  {
492  raw_string_ostream OSS(OutStr);
493 
494  if (isSimple()) {
495  OSS << "BB#" << Node->getNumber();
496  if (const BasicBlock *BB = Node->getBasicBlock())
497  OSS << ": " << BB->getName();
498  } else
499  Node->print(OSS);
500  }
501 
502  if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
503 
504  // Process string output to make it nicer...
505  for (unsigned i = 0; i != OutStr.length(); ++i)
506  if (OutStr[i] == '\n') { // Left justify
507  OutStr[i] = '\\';
508  OutStr.insert(OutStr.begin()+i+1, 'l');
509  }
510  return OutStr;
511  }
512  };
513 }
514 
516 {
517 #ifndef NDEBUG
518  ViewGraph(this, "mf" + getName());
519 #else
520  errs() << "MachineFunction::viewCFG is only available in debug builds on "
521  << "systems with Graphviz or gv!\n";
522 #endif // NDEBUG
523 }
524 
526 {
527 #ifndef NDEBUG
528  ViewGraph(this, "mf" + getName(), true);
529 #else
530  errs() << "MachineFunction::viewCFGOnly is only available in debug builds on "
531  << "systems with Graphviz or gv!\n";
532 #endif // NDEBUG
533 }
534 
535 /// Add the specified physical register as a live-in value and
536 /// create a corresponding virtual register for it.
537 unsigned MachineFunction::addLiveIn(unsigned PReg,
538  const TargetRegisterClass *RC) {
540  unsigned VReg = MRI.getLiveInVirtReg(PReg);
541  if (VReg) {
542  const TargetRegisterClass *VRegRC = MRI.getRegClass(VReg);
543  (void)VRegRC;
544  // A physical register can be added several times.
545  // Between two calls, the register class of the related virtual register
546  // may have been constrained to match some operation constraints.
547  // In that case, check that the current register class includes the
548  // physical register and is a sub class of the specified RC.
549  assert((VRegRC == RC || (VRegRC->contains(PReg) &&
550  RC->hasSubClassEq(VRegRC))) &&
551  "Register class mismatch!");
552  return VReg;
553  }
554  VReg = MRI.createVirtualRegister(RC);
555  MRI.addLiveIn(PReg, VReg);
556  return VReg;
557 }
558 
559 /// Return the MCSymbol for the specified non-empty jump table.
560 /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
561 /// normal 'L' label is returned.
563  bool isLinkerPrivate) const {
564  const DataLayout &DL = getDataLayout();
565  assert(JumpTableInfo && "No jump tables");
566  assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
567 
568  StringRef Prefix = isLinkerPrivate ? DL.getLinkerPrivateGlobalPrefix()
569  : DL.getPrivateGlobalPrefix();
571  raw_svector_ostream(Name)
572  << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
573  return Ctx.getOrCreateSymbol(Name);
574 }
575 
576 /// Return a function-local symbol to represent the PIC base.
578  const DataLayout &DL = getDataLayout();
580  Twine(getFunctionNumber()) + "$pb");
581 }
582 
583 /// \name Exception Handling
584 /// \{
585 
588  unsigned N = LandingPads.size();
589  for (unsigned i = 0; i < N; ++i) {
590  LandingPadInfo &LP = LandingPads[i];
591  if (LP.LandingPadBlock == LandingPad)
592  return LP;
593  }
594 
595  LandingPads.push_back(LandingPadInfo(LandingPad));
596  return LandingPads[N];
597 }
598 
600  MCSymbol *BeginLabel, MCSymbol *EndLabel) {
601  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
602  LP.BeginLabels.push_back(BeginLabel);
603  LP.EndLabels.push_back(EndLabel);
604 }
605 
607  MCSymbol *LandingPadLabel = Ctx.createTempSymbol();
608  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
609  LP.LandingPadLabel = LandingPadLabel;
610  return LandingPadLabel;
611 }
612 
615  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
616  for (unsigned N = TyInfo.size(); N; --N)
617  LP.TypeIds.push_back(getTypeIDFor(TyInfo[N - 1]));
618 }
619 
622  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
623  std::vector<unsigned> IdsInFilter(TyInfo.size());
624  for (unsigned I = 0, E = TyInfo.size(); I != E; ++I)
625  IdsInFilter[I] = getTypeIDFor(TyInfo[I]);
626  LP.TypeIds.push_back(getFilterIDFor(IdsInFilter));
627 }
628 
630  for (unsigned i = 0; i != LandingPads.size(); ) {
631  LandingPadInfo &LandingPad = LandingPads[i];
632  if (LandingPad.LandingPadLabel &&
633  !LandingPad.LandingPadLabel->isDefined() &&
634  (!LPMap || (*LPMap)[LandingPad.LandingPadLabel] == 0))
635  LandingPad.LandingPadLabel = nullptr;
636 
637  // Special case: we *should* emit LPs with null LP MBB. This indicates
638  // "nounwind" case.
639  if (!LandingPad.LandingPadLabel && LandingPad.LandingPadBlock) {
640  LandingPads.erase(LandingPads.begin() + i);
641  continue;
642  }
643 
644  for (unsigned j = 0, e = LandingPads[i].BeginLabels.size(); j != e; ++j) {
645  MCSymbol *BeginLabel = LandingPad.BeginLabels[j];
646  MCSymbol *EndLabel = LandingPad.EndLabels[j];
647  if ((BeginLabel->isDefined() ||
648  (LPMap && (*LPMap)[BeginLabel] != 0)) &&
649  (EndLabel->isDefined() ||
650  (LPMap && (*LPMap)[EndLabel] != 0))) continue;
651 
652  LandingPad.BeginLabels.erase(LandingPad.BeginLabels.begin() + j);
653  LandingPad.EndLabels.erase(LandingPad.EndLabels.begin() + j);
654  --j;
655  --e;
656  }
657 
658  // Remove landing pads with no try-ranges.
659  if (LandingPads[i].BeginLabels.empty()) {
660  LandingPads.erase(LandingPads.begin() + i);
661  continue;
662  }
663 
664  // If there is no landing pad, ensure that the list of typeids is empty.
665  // If the only typeid is a cleanup, this is the same as having no typeids.
666  if (!LandingPad.LandingPadBlock ||
667  (LandingPad.TypeIds.size() == 1 && !LandingPad.TypeIds[0]))
668  LandingPad.TypeIds.clear();
669  ++i;
670  }
671 }
672 
674  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
675  LP.TypeIds.push_back(0);
676 }
677 
679  const Function *Filter,
680  const BlockAddress *RecoverBA) {
681  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
682  SEHHandler Handler;
683  Handler.FilterOrFinally = Filter;
684  Handler.RecoverBA = RecoverBA;
685  LP.SEHHandlers.push_back(Handler);
686 }
687 
689  const Function *Cleanup) {
690  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
691  SEHHandler Handler;
692  Handler.FilterOrFinally = Cleanup;
693  Handler.RecoverBA = nullptr;
694  LP.SEHHandlers.push_back(Handler);
695 }
696 
698  ArrayRef<unsigned> Sites) {
699  LPadToCallSiteMap[Sym].append(Sites.begin(), Sites.end());
700 }
701 
703  for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i)
704  if (TypeInfos[i] == TI) return i + 1;
705 
706  TypeInfos.push_back(TI);
707  return TypeInfos.size();
708 }
709 
710 int MachineFunction::getFilterIDFor(std::vector<unsigned> &TyIds) {
711  // If the new filter coincides with the tail of an existing filter, then
712  // re-use the existing filter. Folding filters more than this requires
713  // re-ordering filters and/or their elements - probably not worth it.
714  for (std::vector<unsigned>::iterator I = FilterEnds.begin(),
715  E = FilterEnds.end(); I != E; ++I) {
716  unsigned i = *I, j = TyIds.size();
717 
718  while (i && j)
719  if (FilterIds[--i] != TyIds[--j])
720  goto try_next;
721 
722  if (!j)
723  // The new filter coincides with range [i, end) of the existing filter.
724  return -(1 + i);
725 
726 try_next:;
727  }
728 
729  // Add the new filter.
730  int FilterID = -(1 + FilterIds.size());
731  FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
732  FilterIds.insert(FilterIds.end(), TyIds.begin(), TyIds.end());
733  FilterEnds.push_back(FilterIds.size());
734  FilterIds.push_back(0); // terminator
735  return FilterID;
736 }
737 
739  MachineFunction &MF = *MBB.getParent();
740  if (const auto *PF = dyn_cast<Function>(
742  MF.getMMI().addPersonality(PF);
743 
744  if (I.isCleanup())
745  MF.addCleanup(&MBB);
746 
747  // FIXME: New EH - Add the clauses in reverse order. This isn't 100% correct,
748  // but we need to do it this way because of how the DWARF EH emitter
749  // processes the clauses.
750  for (unsigned i = I.getNumClauses(); i != 0; --i) {
751  Value *Val = I.getClause(i - 1);
752  if (I.isCatch(i - 1)) {
753  MF.addCatchTypeInfo(&MBB,
754  dyn_cast<GlobalValue>(Val->stripPointerCasts()));
755  } else {
756  // Add filters in a list.
757  Constant *CVal = cast<Constant>(Val);
759  for (User::op_iterator II = CVal->op_begin(), IE = CVal->op_end();
760  II != IE; ++II)
761  FilterList.push_back(cast<GlobalValue>((*II)->stripPointerCasts()));
762 
763  MF.addFilterTypeInfo(&MBB, FilterList);
764  }
765  }
766 }
767 
768 /// \}
769 
770 //===----------------------------------------------------------------------===//
771 // MachineJumpTableInfo implementation
772 //===----------------------------------------------------------------------===//
773 
774 /// Return the size of each entry in the jump table.
776  // The size of a jump table entry is 4 bytes unless the entry is just the
777  // address of a block, in which case it is the pointer size.
778  switch (getEntryKind()) {
780  return TD.getPointerSize();
782  return 8;
786  return 4;
788  return 0;
789  }
790  llvm_unreachable("Unknown jump table encoding!");
791 }
792 
793 /// Return the alignment of each entry in the jump table.
795  // The alignment of a jump table entry is the alignment of int32 unless the
796  // entry is just the address of a block, in which case it is the pointer
797  // alignment.
798  switch (getEntryKind()) {
800  return TD.getPointerABIAlignment();
802  return TD.getABIIntegerTypeAlignment(64);
806  return TD.getABIIntegerTypeAlignment(32);
808  return 1;
809  }
810  llvm_unreachable("Unknown jump table encoding!");
811 }
812 
813 /// Create a new jump table entry in the jump table info.
815  const std::vector<MachineBasicBlock*> &DestBBs) {
816  assert(!DestBBs.empty() && "Cannot create an empty jump table!");
817  JumpTables.push_back(MachineJumpTableEntry(DestBBs));
818  return JumpTables.size()-1;
819 }
820 
821 /// If Old is the target of any jump tables, update the jump tables to branch
822 /// to New instead.
824  MachineBasicBlock *New) {
825  assert(Old != New && "Not making a change?");
826  bool MadeChange = false;
827  for (size_t i = 0, e = JumpTables.size(); i != e; ++i)
828  ReplaceMBBInJumpTable(i, Old, New);
829  return MadeChange;
830 }
831 
832 /// If Old is a target of the jump tables, update the jump table to branch to
833 /// New instead.
835  MachineBasicBlock *Old,
836  MachineBasicBlock *New) {
837  assert(Old != New && "Not making a change?");
838  bool MadeChange = false;
839  MachineJumpTableEntry &JTE = JumpTables[Idx];
840  for (size_t j = 0, e = JTE.MBBs.size(); j != e; ++j)
841  if (JTE.MBBs[j] == Old) {
842  JTE.MBBs[j] = New;
843  MadeChange = true;
844  }
845  return MadeChange;
846 }
847 
849  if (JumpTables.empty()) return;
850 
851  OS << "Jump Tables:\n";
852 
853  for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) {
854  OS << " jt#" << i << ": ";
855  for (unsigned j = 0, f = JumpTables[i].MBBs.size(); j != f; ++j)
856  OS << " BB#" << JumpTables[i].MBBs[j]->getNumber();
857  }
858 
859  OS << '\n';
860 }
861 
862 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
864 #endif
865 
866 
867 //===----------------------------------------------------------------------===//
868 // MachineConstantPool implementation
869 //===----------------------------------------------------------------------===//
870 
871 void MachineConstantPoolValue::anchor() { }
872 
875  return Val.MachineCPVal->getType();
876  return Val.ConstVal->getType();
877 }
878 
881  return true;
882  return Val.ConstVal->needsRelocation();
883 }
884 
887  if (needsRelocation())
889  switch (DL->getTypeAllocSize(getType())) {
890  case 4:
892  case 8:
894  case 16:
896  case 32:
898  default:
899  return SectionKind::getReadOnly();
900  }
901 }
902 
904  // A constant may be a member of both Constants and MachineCPVsSharingEntries,
905  // so keep track of which we've deleted to avoid double deletions.
907  for (unsigned i = 0, e = Constants.size(); i != e; ++i)
908  if (Constants[i].isMachineConstantPoolEntry()) {
909  Deleted.insert(Constants[i].Val.MachineCPVal);
910  delete Constants[i].Val.MachineCPVal;
911  }
913  MachineCPVsSharingEntries.begin(), E = MachineCPVsSharingEntries.end();
914  I != E; ++I) {
915  if (Deleted.count(*I) == 0)
916  delete *I;
917  }
918 }
919 
920 /// Test whether the given two constants can be allocated the same constant pool
921 /// entry.
922 static bool CanShareConstantPoolEntry(const Constant *A, const Constant *B,
923  const DataLayout &DL) {
924  // Handle the trivial case quickly.
925  if (A == B) return true;
926 
927  // If they have the same type but weren't the same constant, quickly
928  // reject them.
929  if (A->getType() == B->getType()) return false;
930 
931  // We can't handle structs or arrays.
932  if (isa<StructType>(A->getType()) || isa<ArrayType>(A->getType()) ||
933  isa<StructType>(B->getType()) || isa<ArrayType>(B->getType()))
934  return false;
935 
936  // For now, only support constants with the same size.
937  uint64_t StoreSize = DL.getTypeStoreSize(A->getType());
938  if (StoreSize != DL.getTypeStoreSize(B->getType()) || StoreSize > 128)
939  return false;
940 
941  Type *IntTy = IntegerType::get(A->getContext(), StoreSize*8);
942 
943  // Try constant folding a bitcast of both instructions to an integer. If we
944  // get two identical ConstantInt's, then we are good to share them. We use
945  // the constant folding APIs to do this so that we get the benefit of
946  // DataLayout.
947  if (isa<PointerType>(A->getType()))
948  A = ConstantFoldCastOperand(Instruction::PtrToInt,
949  const_cast<Constant *>(A), IntTy, DL);
950  else if (A->getType() != IntTy)
951  A = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(A),
952  IntTy, DL);
953  if (isa<PointerType>(B->getType()))
954  B = ConstantFoldCastOperand(Instruction::PtrToInt,
955  const_cast<Constant *>(B), IntTy, DL);
956  else if (B->getType() != IntTy)
957  B = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(B),
958  IntTy, DL);
959 
960  return A == B;
961 }
962 
963 /// Create a new entry in the constant pool or return an existing one.
964 /// User must specify the log2 of the minimum required alignment for the object.
966  unsigned Alignment) {
967  assert(Alignment && "Alignment must be specified!");
968  if (Alignment > PoolAlignment) PoolAlignment = Alignment;
969 
970  // Check to see if we already have this constant.
971  //
972  // FIXME, this could be made much more efficient for large constant pools.
973  for (unsigned i = 0, e = Constants.size(); i != e; ++i)
974  if (!Constants[i].isMachineConstantPoolEntry() &&
975  CanShareConstantPoolEntry(Constants[i].Val.ConstVal, C, DL)) {
976  if ((unsigned)Constants[i].getAlignment() < Alignment)
977  Constants[i].Alignment = Alignment;
978  return i;
979  }
980 
981  Constants.push_back(MachineConstantPoolEntry(C, Alignment));
982  return Constants.size()-1;
983 }
984 
986  unsigned Alignment) {
987  assert(Alignment && "Alignment must be specified!");
988  if (Alignment > PoolAlignment) PoolAlignment = Alignment;
989 
990  // Check to see if we already have this constant.
991  //
992  // FIXME, this could be made much more efficient for large constant pools.
993  int Idx = V->getExistingMachineCPValue(this, Alignment);
994  if (Idx != -1) {
995  MachineCPVsSharingEntries.insert(V);
996  return (unsigned)Idx;
997  }
998 
999  Constants.push_back(MachineConstantPoolEntry(V, Alignment));
1000  return Constants.size()-1;
1001 }
1002 
1004  if (Constants.empty()) return;
1005 
1006  OS << "Constant Pool:\n";
1007  for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
1008  OS << " cp#" << i << ": ";
1009  if (Constants[i].isMachineConstantPoolEntry())
1010  Constants[i].Val.MachineCPVal->print(OS);
1011  else
1012  Constants[i].Val.ConstVal->printAsOperand(OS, /*PrintType=*/false);
1013  OS << ", align=" << Constants[i].getAlignment();
1014  OS << "\n";
1015  }
1016 }
1017 
1018 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1020 #endif
Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
void push_back(const T &Elt)
Definition: SmallVector.h:211
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:109
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
SectionKind getSectionKind(const DataLayout *DL) const
StringRef getPrivateGlobalPrefix() const
Definition: DataLayout.h:281
union llvm::MachineConstantPoolEntry::@132 Val
The constant itself.
size_type size() const
size - Returns the number of bits in this bitvector.
Definition: BitVector.h:170
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Flags getFlags() const
Return the raw flags of the source value,.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
static SectionKind getMergeableConst32()
Definition: SectionKind.h:195
iterator erase(iterator where)
Definition: ilist.h:280
unsigned getPrefFunctionAlignment() const
Return the preferred function alignment.
MachineFunctionProperties & reset(Property P)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
Definition: Compiler.h:449
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them...
livein_iterator livein_end() const
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad. Returns the label ID for the landing pad entry.
StringRef getLinkerPrivateGlobalPrefix() const
Definition: DataLayout.h:261
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
Definition: Value.cpp:527
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
void addLiveIn(unsigned Reg, unsigned vreg=0)
addLiveIn - Add the specified register as a live-in.
const Function * FilterOrFinally
Filter or finally function. Null indicates a catch-all.
Implements a dense probed hash-table based set.
Definition: DenseSet.h:221
void addLandingPadInfo(const LandingPadInst &I, MachineBasicBlock &MBB)
Extract the exception handling information from the landingpad instruction and add them to the specif...
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
unsigned addLiveIn(unsigned PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:163
iterator end() const
Definition: ArrayRef.h:138
DataLayout DL
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
EK_Inline - Jump table entries are emitted inline at their point of use.
std::string getNodeLabel(const MachineBasicBlock *Node, const MachineFunction *Graph)
static SectionKind getMergeableConst8()
Definition: SectionKind.h:193
static SectionKind getMergeableConst16()
Definition: SectionKind.h:194
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:490
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:108
A debug info location.
Definition: DebugLoc.h:34
Metadata node.
Definition: Metadata.h:862
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
Manage lifetime of a slot tracker for printing IR.
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL, bool NoImp=false)
CreateMachineInstr - Allocate a new MachineInstr.
void DeleteMachineBasicBlock(MachineBasicBlock *MBB)
DeleteMachineBasicBlock - Delete the given MachineBasicBlock.
static SectionKind getMergeableConst4()
Definition: SectionKind.h:192
op_iterator op_begin()
Definition: User.h:214
bool ReplaceMBBInJumpTable(unsigned Idx, MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTable - If Old is a target of the jump tables, update the jump table to branch to New...
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:218
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist...
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
JTEntryKind
JTEntryKind - This enum indicates how each entry of the jump table is represented and emitted...
The address of a basic block.
Definition: Constants.h:813
AtomicOrdering getOrdering() const
Return the atomic ordering requirements for this memory operation.
void addSEHCleanupHandler(MachineBasicBlock *LandingPad, const Function *Cleanup)
A description of a memory reference used in the backend.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
SmallVector< MCSymbol *, 1 > EndLabels
unsigned getPointerABIAlignment(unsigned AS=0) const
Layout pointer alignment FIXME: The defaults need to be removed once all of the backends/clients are ...
Definition: DataLayout.cpp:585
const Constant * stripPointerCasts() const
Definition: Constant.h:153
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
SmallVector< SEHHandler, 1 > SEHHandlers
void addCatchTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the catch typeinfo for a landing pad.
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
const MachineFunctionProperties & getProperties() const
Get the function properties.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Definition: Function.cpp:1255
void addFilterTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the filter typeinfo for a landing pad.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
std::pair< MachineInstr::mmo_iterator, MachineInstr::mmo_iterator > extractLoadMemRefs(MachineInstr::mmo_iterator Begin, MachineInstr::mmo_iterator End)
extractLoadMemRefs - Allocate an array and populate it with just the load information from the given ...
int getFilterIDFor(std::vector< unsigned > &TyIds)
Return the id of the filter encoded by TyIds. This is function wide.
void Deallocate(const void *Ptr, size_t Size)
Definition: Allocator.h:272
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
AtomicOrdering
Atomic ordering for LLVM's memory model.
static bool isSimple(Instruction *I)
Context object for machine code objects.
Definition: MCContext.h:59
This structure is used to retain landing pad info for the current function.
void print(const MachineFunction &MF, raw_ostream &OS) const
Used by the MachineFunction printer to print information about stack objects.
#define F(x, y, z)
Definition: MD5.cpp:55
SlotIndexes pass.
Definition: SlotIndexes.h:331
unsigned createJumpTableIndex(const std::vector< MachineBasicBlock * > &DestBBs)
createJumpTableIndex - Create a new jump table.
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table...
virtual int getExistingMachineCPValue(MachineConstantPool *CP, unsigned Alignment)=0
static std::string getGraphName(const MachineFunction *F)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
EK_BlockAddress - Each entry is a plain address of block, e.g.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
This class is a data container for one entry in a MachineConstantPool.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Definition: StringRef.h:138
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
const char * Name
BasicBlockListType::iterator iterator
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
iterator begin() const
Definition: StringRef.h:106
static unsigned getFnStackAlignment(const TargetSubtargetInfo *STI, const Function *Fn)
unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
#define P(N)
EK_GPRel64BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:401
unsigned getABIIntegerTypeAlignment(unsigned BitWidth) const
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
Definition: DataLayout.cpp:686
The landingpad instruction holds all of the information necessary to generate correct exception handl...
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:215
EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the TargetLowering::LowerCustomJ...
unsigned const MachineRegisterInfo * MRI
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
void addInvoke(MachineBasicBlock *LandingPad, MCSymbol *BeginLabel, MCSymbol *EndLabel)
Provide the begin and end labels of an invoke style call and associate it with a try landing pad bloc...
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
void addSEHCatchHandler(MachineBasicBlock *LandingPad, const Function *Filter, const BlockAddress *RecoverLabel)
static cl::opt< unsigned > AlignAllFunctions("align-all-functions", cl::desc("Force the alignment of all functions."), cl::init(0), cl::Hidden)
void addPersonality(const Function *Personality)
Provide the personality function for the exception information.
This is an important base class in LLVM.
Definition: Constant.h:42
SmallVector< MCSymbol *, 1 > BeginLabels
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:212
static bool CanShareConstantPoolEntry(const Constant *A, const Constant *B, const DataLayout &DL)
Test whether the given two constants can be allocated the same constant pool entry.
unsigned getLiveInVirtReg(unsigned PReg) const
getLiveInVirtReg - If PReg is a live-in physical register, return the corresponding live-in physical ...
#define A
Definition: LargeTest.cpp:12
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition: Function.h:626
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
op_iterator op_end()
Definition: User.h:216
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
std::vector< int > TypeIds
std::vector< std::pair< unsigned, unsigned >>::const_iterator livein_iterator
void print(raw_ostream &OS) const
Print the MachineFunctionProperties in human-readable form.
static const unsigned End
iterator begin() const
Definition: ArrayRef.h:137
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:23
self_iterator getIterator()
Definition: ilist_node.h:82
const PseudoSourceValue * getPseudoValue() const
void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file, then cleanup.
Definition: GraphWriter.h:348
std::vector< MachineBasicBlock * > MBBs
MBBs - The vector of basic blocks from which to create the jump table.
unsigned size() const
void incorporateFunction(const Function &F)
Incorporate the given function.
Definition: AsmWriter.cpp:769
void DeleteMachineInstr(MachineInstr *MI)
DeleteMachineInstr - Delete the given MachineInstr.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID for this memory operation.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:697
Abstract base class for all machine specific constantpool value subclasses.
This class contains a discriminated union of information about pointers in memory operands...
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
void dump() const
dump - Print the current MachineFunction to cerr, useful for debugger use.
void addCleanup(MachineBasicBlock *LandingPad)
Add a cleanup action for a landing pad.
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about constant pool objects...
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
virtual const TargetFrameLowering * getFrameLowering() const
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:240
Iterator for intrusive lists based on ilist_node.
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about jump tables.
#define E
Definition: LargeTest.cpp:27
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
#define B
Definition: LargeTest.cpp:24
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Definition: DataLayout.h:405
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
CloneMachineInstr - Create a new MachineInstr which is a copy of the 'Orig' instruction, identical in all ways except the instruction has no parent, prev, or next.
static const char * Separator
bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTables - If Old is the target of any jump tables, update the jump tables to branch to...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
MachineFunction(const Function *Fn, const TargetMachine &TM, unsigned FunctionNum, MachineModuleInfo &MMI)
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
virtual const TargetLowering * getTargetLowering() const
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:642
static SectionKind getReadOnlyWithRel()
Definition: SectionKind.h:203
const size_t N
livein_iterator livein_begin() const
bool isDefined(bool SetUsed=true) const
isDefined - Check if this symbol is defined (i.e., it has an address).
Definition: MCSymbol.h:249
void clear(AllocatorType &Allocator)
Release all the tracked allocations to the allocator.
static void deleteNode(NodeTy *V)
Definition: ilist.h:42
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef< unsigned > Sites)
Map the landing pad's EH symbol to the call site indexes.
Target - Wrapper for Target specific information.
const Value * getValue() const
Return the base address of the memory access.
MachineJumpTableEntry - One jump table in the jump table info.
MachineBasicBlock * LandingPadBlock
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Flags
Flags values. These may be or'd together.
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
MachineFunctionProperties & set(Property P)
TargetSubtargetInfo - Generic base class for all target subtargets.
static const char * getPropertyName(MachineFunctionProperties::Property Prop)
Representation of each machine instruction.
Definition: MachineInstr.h:59
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:361
void ensureMaxAlignment(unsigned Align)
Make sure the function is at least Align bytes aligned.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:254
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:121
#define C
Definition: LargeTest.cpp:25
unsigned getMinFunctionAlignment() const
Return the minimum function alignment.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
#define I(x, y, z)
Definition: MD5.cpp:58
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
print - Print out the MachineFunction in a format suitable for debugging to the specified stream...
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
Definition: DataLayout.h:388
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
Definition: DenseSet.h:91
JTEntryKind getEntryKind() const
std::pair< MachineInstr::mmo_iterator, MachineInstr::mmo_iterator > extractStoreMemRefs(MachineInstr::mmo_iterator Begin, MachineInstr::mmo_iterator End)
extractStoreMemRefs - Allocate an array and populate it with just the store information from the give...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry...
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:463
aarch64 promote const
const MDNode * getRanges() const
Return the range tag for the memory reference.
LandingPadInfo & getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad)
Find or create an LandingPadInfo for the specified MachineBasicBlock.
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:545
LLVM Value Representation.
Definition: Value.h:73
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
Dellocate an array of MachineOperands and recycle the memory.
const BlockAddress * RecoverBA
Address of block to recover at. Null for a finally handler.
static const Function * getParent(const Value *V)
iterator end() const
Definition: StringRef.h:108
uint64_t getSize() const
Return the size in bytes of the memory reference.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
void dump() const
dump - Call print(cerr) to be called from the debugger.
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:56
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
IRTranslator LLVM IR MI
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
MachineModuleInfo & getMMI() const
EK_GPRel32BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
AtomicOrdering getFailureOrdering() const
For cmpxchg atomic operations, return the atomic ordering requirements when store does not occur...
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
Definition: DataLayout.cpp:603
VariableDbgInfoMapTy VariableDbgInfos
static SectionKind getReadOnly()
Definition: SectionKind.h:182
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
const BasicBlock * getParent() const
Definition: Instruction.h:66
unsigned getFnStackAlignment() const
Return the stack alignment for the function.
Definition: Function.h:270
unsigned getConstantPoolIndex(const Constant *C, unsigned Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one...
This class contains meta information specific to a module.
This file describes how to lower LLVM code to machine code.
void dump() const
dump - Call to stderr.
uint64_t getBaseAlignment() const
Return the minimum known alignment in bytes of the base address, without the offset.
void tidyLandingPads(DenseMap< MCSymbol *, uintptr_t > *LPMap=nullptr)
Remap landing pad labels and remove any deleted landing pads.
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.