LLVM  6.0.0svn
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/BitVector.h"
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/DenseSet.h"
20 #include "llvm/ADT/STLExtras.h"
21 #include "llvm/ADT/SmallString.h"
22 #include "llvm/ADT/SmallVector.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/ADT/Twine.h"
41 #include "llvm/IR/Attributes.h"
42 #include "llvm/IR/BasicBlock.h"
43 #include "llvm/IR/Constant.h"
44 #include "llvm/IR/DataLayout.h"
45 #include "llvm/IR/DerivedTypes.h"
46 #include "llvm/IR/Function.h"
47 #include "llvm/IR/GlobalValue.h"
48 #include "llvm/IR/Instruction.h"
49 #include "llvm/IR/Instructions.h"
50 #include "llvm/IR/Metadata.h"
51 #include "llvm/IR/Module.h"
53 #include "llvm/IR/Value.h"
54 #include "llvm/MC/MCContext.h"
55 #include "llvm/MC/MCSymbol.h"
56 #include "llvm/MC/SectionKind.h"
57 #include "llvm/Support/Casting.h"
59 #include "llvm/Support/Compiler.h"
61 #include "llvm/Support/Debug.h"
66 #include <algorithm>
67 #include <cassert>
68 #include <cstddef>
69 #include <cstdint>
70 #include <iterator>
71 #include <string>
72 #include <utility>
73 #include <vector>
74 
75 using namespace llvm;
76 
77 #define DEBUG_TYPE "codegen"
78 
79 static cl::opt<unsigned>
80 AlignAllFunctions("align-all-functions",
81  cl::desc("Force the alignment of all functions."),
82  cl::init(0), cl::Hidden);
83 
86 
87  switch(Prop) {
88  case P::FailedISel: return "FailedISel";
89  case P::IsSSA: return "IsSSA";
90  case P::Legalized: return "Legalized";
91  case P::NoPHIs: return "NoPHIs";
92  case P::NoVRegs: return "NoVRegs";
93  case P::RegBankSelected: return "RegBankSelected";
94  case P::Selected: return "Selected";
95  case P::TracksLiveness: return "TracksLiveness";
96  }
97  llvm_unreachable("Invalid machine function property");
98 }
99 
101  const char *Separator = "";
102  for (BitVector::size_type I = 0; I < Properties.size(); ++I) {
103  if (!Properties[I])
104  continue;
105  OS << Separator << getPropertyName(static_cast<Property>(I));
106  Separator = ", ";
107  }
108 }
109 
110 //===----------------------------------------------------------------------===//
111 // MachineFunction implementation
112 //===----------------------------------------------------------------------===//
113 
114 // Out-of-line virtual method.
116 
118  MBB->getParent()->DeleteMachineBasicBlock(MBB);
119 }
120 
121 static inline unsigned getFnStackAlignment(const TargetSubtargetInfo *STI,
122  const Function *Fn) {
123  if (Fn->hasFnAttribute(Attribute::StackAlignment))
124  return Fn->getFnStackAlignment();
125  return STI->getFrameLowering()->getStackAlignment();
126 }
127 
129  unsigned FunctionNum, MachineModuleInfo &mmi)
130  : Fn(F), Target(TM), STI(TM.getSubtargetImpl(*F)), Ctx(mmi.getContext()),
131  MMI(mmi) {
132  FunctionNumber = FunctionNum;
133  init();
134 }
135 
136 void MachineFunction::init() {
137  // Assume the function starts in SSA form with correct liveness.
140  if (STI->getRegisterInfo())
141  RegInfo = new (Allocator) MachineRegisterInfo(this);
142  else
143  RegInfo = nullptr;
144 
145  MFInfo = nullptr;
146  // We can realign the stack if the target supports it and the user hasn't
147  // explicitly asked us not to.
148  bool CanRealignSP = STI->getFrameLowering()->isStackRealignable() &&
149  !Fn->hasFnAttribute("no-realign-stack");
150  FrameInfo = new (Allocator) MachineFrameInfo(
151  getFnStackAlignment(STI, Fn), /*StackRealignable=*/CanRealignSP,
152  /*ForceRealign=*/CanRealignSP &&
153  Fn->hasFnAttribute(Attribute::StackAlignment));
154 
155  if (Fn->hasFnAttribute(Attribute::StackAlignment))
156  FrameInfo->ensureMaxAlignment(Fn->getFnStackAlignment());
157 
158  ConstantPool = new (Allocator) MachineConstantPool(getDataLayout());
159  Alignment = STI->getTargetLowering()->getMinFunctionAlignment();
160 
161  // FIXME: Shouldn't use pref alignment if explicit alignment is set on Fn.
162  // FIXME: Use Function::optForSize().
163  if (!Fn->hasFnAttribute(Attribute::OptimizeForSize))
164  Alignment = std::max(Alignment,
166 
167  if (AlignAllFunctions)
168  Alignment = AlignAllFunctions;
169 
170  JumpTableInfo = nullptr;
171 
173  Fn->hasPersonalityFn() ? Fn->getPersonalityFn() : nullptr))) {
174  WinEHInfo = new (Allocator) WinEHFuncInfo();
175  }
176 
177  assert(Target.isCompatibleDataLayout(getDataLayout()) &&
178  "Can't create a MachineFunction using a Module with a "
179  "Target-incompatible DataLayout attached\n");
180 
181  PSVManager =
182  llvm::make_unique<PseudoSourceValueManager>(*(getSubtarget().
183  getInstrInfo()));
184 }
185 
187  clear();
188 }
189 
190 void MachineFunction::clear() {
191  Properties.reset();
192  // Don't call destructors on MachineInstr and MachineOperand. All of their
193  // memory comes from the BumpPtrAllocator which is about to be purged.
194  //
195  // Do call MachineBasicBlock destructors, it contains std::vectors.
196  for (iterator I = begin(), E = end(); I != E; I = BasicBlocks.erase(I))
197  I->Insts.clearAndLeakNodesUnsafely();
198 
199  InstructionRecycler.clear(Allocator);
200  OperandRecycler.clear(Allocator);
201  BasicBlockRecycler.clear(Allocator);
202  CodeViewAnnotations.clear();
204  if (RegInfo) {
205  RegInfo->~MachineRegisterInfo();
206  Allocator.Deallocate(RegInfo);
207  }
208  if (MFInfo) {
209  MFInfo->~MachineFunctionInfo();
210  Allocator.Deallocate(MFInfo);
211  }
212 
213  FrameInfo->~MachineFrameInfo();
214  Allocator.Deallocate(FrameInfo);
215 
216  ConstantPool->~MachineConstantPool();
217  Allocator.Deallocate(ConstantPool);
218 
219  if (JumpTableInfo) {
220  JumpTableInfo->~MachineJumpTableInfo();
221  Allocator.Deallocate(JumpTableInfo);
222  }
223 
224  if (WinEHInfo) {
225  WinEHInfo->~WinEHFuncInfo();
226  Allocator.Deallocate(WinEHInfo);
227  }
228 }
229 
231  return Fn->getParent()->getDataLayout();
232 }
233 
234 /// Get the JumpTableInfo for this function.
235 /// If it does not already exist, allocate one.
237 getOrCreateJumpTableInfo(unsigned EntryKind) {
238  if (JumpTableInfo) return JumpTableInfo;
239 
240  JumpTableInfo = new (Allocator)
242  return JumpTableInfo;
243 }
244 
245 /// Should we be emitting segmented stack stuff for the function
247  return getFunction()->hasFnAttribute("split-stack");
248 }
249 
250 /// This discards all of the MachineBasicBlock numbers and recomputes them.
251 /// This guarantees that the MBB numbers are sequential, dense, and match the
252 /// ordering of the blocks within the function. If a specific MachineBasicBlock
253 /// is specified, only that block and those after it are renumbered.
255  if (empty()) { MBBNumbering.clear(); return; }
256  MachineFunction::iterator MBBI, E = end();
257  if (MBB == nullptr)
258  MBBI = begin();
259  else
260  MBBI = MBB->getIterator();
261 
262  // Figure out the block number this should have.
263  unsigned BlockNo = 0;
264  if (MBBI != begin())
265  BlockNo = std::prev(MBBI)->getNumber() + 1;
266 
267  for (; MBBI != E; ++MBBI, ++BlockNo) {
268  if (MBBI->getNumber() != (int)BlockNo) {
269  // Remove use of the old number.
270  if (MBBI->getNumber() != -1) {
271  assert(MBBNumbering[MBBI->getNumber()] == &*MBBI &&
272  "MBB number mismatch!");
273  MBBNumbering[MBBI->getNumber()] = nullptr;
274  }
275 
276  // If BlockNo is already taken, set that block's number to -1.
277  if (MBBNumbering[BlockNo])
278  MBBNumbering[BlockNo]->setNumber(-1);
279 
280  MBBNumbering[BlockNo] = &*MBBI;
281  MBBI->setNumber(BlockNo);
282  }
283  }
284 
285  // Okay, all the blocks are renumbered. If we have compactified the block
286  // numbering, shrink MBBNumbering now.
287  assert(BlockNo <= MBBNumbering.size() && "Mismatch!");
288  MBBNumbering.resize(BlockNo);
289 }
290 
291 /// Allocate a new MachineInstr. Use this instead of `new MachineInstr'.
293  const DebugLoc &DL,
294  bool NoImp) {
295  return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
296  MachineInstr(*this, MCID, DL, NoImp);
297 }
298 
299 /// Create a new MachineInstr which is a copy of the 'Orig' instruction,
300 /// identical in all ways except the instruction has no parent, prev, or next.
301 MachineInstr *
303  return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
304  MachineInstr(*this, *Orig);
305 }
306 
308  MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig) {
309  MachineInstr *FirstClone = nullptr;
311  while (true) {
312  MachineInstr *Cloned = CloneMachineInstr(&*I);
313  MBB.insert(InsertBefore, Cloned);
314  if (FirstClone == nullptr) {
315  FirstClone = Cloned;
316  } else {
317  Cloned->bundleWithPred();
318  }
319 
320  if (!I->isBundledWithSucc())
321  break;
322  ++I;
323  }
324  return *FirstClone;
325 }
326 
327 /// Delete the given MachineInstr.
328 ///
329 /// This function also serves as the MachineInstr destructor - the real
330 /// ~MachineInstr() destructor must be empty.
331 void
333  // Strip it for parts. The operand array and the MI object itself are
334  // independently recyclable.
335  if (MI->Operands)
336  deallocateOperandArray(MI->CapOperands, MI->Operands);
337  // Don't call ~MachineInstr() which must be trivial anyway because
338  // ~MachineFunction drops whole lists of MachineInstrs wihout calling their
339  // destructors.
340  InstructionRecycler.Deallocate(Allocator, MI);
341 }
342 
343 /// Allocate a new MachineBasicBlock. Use this instead of
344 /// `new MachineBasicBlock'.
347  return new (BasicBlockRecycler.Allocate<MachineBasicBlock>(Allocator))
348  MachineBasicBlock(*this, bb);
349 }
350 
351 /// Delete the given MachineBasicBlock.
352 void
354  assert(MBB->getParent() == this && "MBB parent mismatch!");
355  MBB->~MachineBasicBlock();
356  BasicBlockRecycler.Deallocate(Allocator, MBB);
357 }
358 
360  MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s,
361  unsigned base_alignment, const AAMDNodes &AAInfo, const MDNode *Ranges,
362  SyncScope::ID SSID, AtomicOrdering Ordering,
363  AtomicOrdering FailureOrdering) {
364  return new (Allocator)
365  MachineMemOperand(PtrInfo, f, s, base_alignment, AAInfo, Ranges,
366  SSID, Ordering, FailureOrdering);
367 }
368 
371  int64_t Offset, uint64_t Size) {
372  if (MMO->getValue())
373  return new (Allocator)
375  MMO->getOffset()+Offset),
376  MMO->getFlags(), Size, MMO->getBaseAlignment(),
377  AAMDNodes(), nullptr, MMO->getSyncScopeID(),
378  MMO->getOrdering(), MMO->getFailureOrdering());
379  return new (Allocator)
381  MMO->getOffset()+Offset),
382  MMO->getFlags(), Size, MMO->getBaseAlignment(),
383  AAMDNodes(), nullptr, MMO->getSyncScopeID(),
384  MMO->getOrdering(), MMO->getFailureOrdering());
385 }
386 
389  const AAMDNodes &AAInfo) {
390  MachinePointerInfo MPI = MMO->getValue() ?
391  MachinePointerInfo(MMO->getValue(), MMO->getOffset()) :
393 
394  return new (Allocator)
395  MachineMemOperand(MPI, MMO->getFlags(), MMO->getSize(),
396  MMO->getBaseAlignment(), AAInfo,
397  MMO->getRanges(), MMO->getSyncScopeID(),
398  MMO->getOrdering(), MMO->getFailureOrdering());
399 }
400 
403  return Allocator.Allocate<MachineMemOperand *>(Num);
404 }
405 
406 std::pair<MachineInstr::mmo_iterator, MachineInstr::mmo_iterator>
409  // Count the number of load mem refs.
410  unsigned Num = 0;
411  for (MachineInstr::mmo_iterator I = Begin; I != End; ++I)
412  if ((*I)->isLoad())
413  ++Num;
414 
415  // Allocate a new array and populate it with the load information.
417  unsigned Index = 0;
418  for (MachineInstr::mmo_iterator I = Begin; I != End; ++I) {
419  if ((*I)->isLoad()) {
420  if (!(*I)->isStore())
421  // Reuse the MMO.
422  Result[Index] = *I;
423  else {
424  // Clone the MMO and unset the store flag.
425  MachineMemOperand *JustLoad =
426  getMachineMemOperand((*I)->getPointerInfo(),
427  (*I)->getFlags() & ~MachineMemOperand::MOStore,
428  (*I)->getSize(), (*I)->getBaseAlignment(),
429  (*I)->getAAInfo(), nullptr,
430  (*I)->getSyncScopeID(), (*I)->getOrdering(),
431  (*I)->getFailureOrdering());
432  Result[Index] = JustLoad;
433  }
434  ++Index;
435  }
436  }
437  return std::make_pair(Result, Result + Num);
438 }
439 
440 std::pair<MachineInstr::mmo_iterator, MachineInstr::mmo_iterator>
443  // Count the number of load mem refs.
444  unsigned Num = 0;
445  for (MachineInstr::mmo_iterator I = Begin; I != End; ++I)
446  if ((*I)->isStore())
447  ++Num;
448 
449  // Allocate a new array and populate it with the store information.
451  unsigned Index = 0;
452  for (MachineInstr::mmo_iterator I = Begin; I != End; ++I) {
453  if ((*I)->isStore()) {
454  if (!(*I)->isLoad())
455  // Reuse the MMO.
456  Result[Index] = *I;
457  else {
458  // Clone the MMO and unset the load flag.
459  MachineMemOperand *JustStore =
460  getMachineMemOperand((*I)->getPointerInfo(),
461  (*I)->getFlags() & ~MachineMemOperand::MOLoad,
462  (*I)->getSize(), (*I)->getBaseAlignment(),
463  (*I)->getAAInfo(), nullptr,
464  (*I)->getSyncScopeID(), (*I)->getOrdering(),
465  (*I)->getFailureOrdering());
466  Result[Index] = JustStore;
467  }
468  ++Index;
469  }
470  }
471  return std::make_pair(Result, Result + Num);
472 }
473 
475  char *Dest = Allocator.Allocate<char>(Name.size() + 1);
476  std::copy(Name.begin(), Name.end(), Dest);
477  Dest[Name.size()] = 0;
478  return Dest;
479 }
480 
481 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
483  print(dbgs());
484 }
485 #endif
486 
488  assert(getFunction() && "No function!");
489  return getFunction()->getName();
490 }
491 
492 void MachineFunction::print(raw_ostream &OS, const SlotIndexes *Indexes) const {
493  OS << "# Machine code for function " << getName() << ": ";
494  getProperties().print(OS);
495  OS << '\n';
496 
497  // Print Frame Information
498  FrameInfo->print(*this, OS);
499 
500  // Print JumpTable Information
501  if (JumpTableInfo)
502  JumpTableInfo->print(OS);
503 
504  // Print Constant Pool
505  ConstantPool->print(OS);
506 
508 
509  if (RegInfo && !RegInfo->livein_empty()) {
510  OS << "Function Live Ins: ";
512  I = RegInfo->livein_begin(), E = RegInfo->livein_end(); I != E; ++I) {
513  OS << PrintReg(I->first, TRI);
514  if (I->second)
515  OS << " in " << PrintReg(I->second, TRI);
516  if (std::next(I) != E)
517  OS << ", ";
518  }
519  OS << '\n';
520  }
521 
524  for (const auto &BB : *this) {
525  OS << '\n';
526  BB.print(OS, MST, Indexes);
527  }
528 
529  OS << "\n# End machine code for function " << getName() << ".\n\n";
530 }
531 
532 namespace llvm {
533 
534  template<>
537 
538  static std::string getGraphName(const MachineFunction *F) {
539  return ("CFG for '" + F->getName() + "' function").str();
540  }
541 
542  std::string getNodeLabel(const MachineBasicBlock *Node,
543  const MachineFunction *Graph) {
544  std::string OutStr;
545  {
546  raw_string_ostream OSS(OutStr);
547 
548  if (isSimple()) {
549  OSS << "BB#" << Node->getNumber();
550  if (const BasicBlock *BB = Node->getBasicBlock())
551  OSS << ": " << BB->getName();
552  } else
553  Node->print(OSS);
554  }
555 
556  if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
557 
558  // Process string output to make it nicer...
559  for (unsigned i = 0; i != OutStr.length(); ++i)
560  if (OutStr[i] == '\n') { // Left justify
561  OutStr[i] = '\\';
562  OutStr.insert(OutStr.begin()+i+1, 'l');
563  }
564  return OutStr;
565  }
566  };
567 
568 } // end namespace llvm
569 
571 {
572 #ifndef NDEBUG
573  ViewGraph(this, "mf" + getName());
574 #else
575  errs() << "MachineFunction::viewCFG is only available in debug builds on "
576  << "systems with Graphviz or gv!\n";
577 #endif // NDEBUG
578 }
579 
581 {
582 #ifndef NDEBUG
583  ViewGraph(this, "mf" + getName(), true);
584 #else
585  errs() << "MachineFunction::viewCFGOnly is only available in debug builds on "
586  << "systems with Graphviz or gv!\n";
587 #endif // NDEBUG
588 }
589 
590 /// Add the specified physical register as a live-in value and
591 /// create a corresponding virtual register for it.
592 unsigned MachineFunction::addLiveIn(unsigned PReg,
593  const TargetRegisterClass *RC) {
595  unsigned VReg = MRI.getLiveInVirtReg(PReg);
596  if (VReg) {
597  const TargetRegisterClass *VRegRC = MRI.getRegClass(VReg);
598  (void)VRegRC;
599  // A physical register can be added several times.
600  // Between two calls, the register class of the related virtual register
601  // may have been constrained to match some operation constraints.
602  // In that case, check that the current register class includes the
603  // physical register and is a sub class of the specified RC.
604  assert((VRegRC == RC || (VRegRC->contains(PReg) &&
605  RC->hasSubClassEq(VRegRC))) &&
606  "Register class mismatch!");
607  return VReg;
608  }
609  VReg = MRI.createVirtualRegister(RC);
610  MRI.addLiveIn(PReg, VReg);
611  return VReg;
612 }
613 
614 /// Return the MCSymbol for the specified non-empty jump table.
615 /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
616 /// normal 'L' label is returned.
618  bool isLinkerPrivate) const {
619  const DataLayout &DL = getDataLayout();
620  assert(JumpTableInfo && "No jump tables");
621  assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
622 
623  StringRef Prefix = isLinkerPrivate ? DL.getLinkerPrivateGlobalPrefix()
624  : DL.getPrivateGlobalPrefix();
626  raw_svector_ostream(Name)
627  << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
628  return Ctx.getOrCreateSymbol(Name);
629 }
630 
631 /// Return a function-local symbol to represent the PIC base.
633  const DataLayout &DL = getDataLayout();
634  return Ctx.getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
635  Twine(getFunctionNumber()) + "$pb");
636 }
637 
638 /// \name Exception Handling
639 /// \{
640 
643  unsigned N = LandingPads.size();
644  for (unsigned i = 0; i < N; ++i) {
645  LandingPadInfo &LP = LandingPads[i];
646  if (LP.LandingPadBlock == LandingPad)
647  return LP;
648  }
649 
650  LandingPads.push_back(LandingPadInfo(LandingPad));
651  return LandingPads[N];
652 }
653 
655  MCSymbol *BeginLabel, MCSymbol *EndLabel) {
656  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
657  LP.BeginLabels.push_back(BeginLabel);
658  LP.EndLabels.push_back(EndLabel);
659 }
660 
662  MCSymbol *LandingPadLabel = Ctx.createTempSymbol();
663  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
664  LP.LandingPadLabel = LandingPadLabel;
665  return LandingPadLabel;
666 }
667 
670  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
671  for (unsigned N = TyInfo.size(); N; --N)
672  LP.TypeIds.push_back(getTypeIDFor(TyInfo[N - 1]));
673 }
674 
677  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
678  std::vector<unsigned> IdsInFilter(TyInfo.size());
679  for (unsigned I = 0, E = TyInfo.size(); I != E; ++I)
680  IdsInFilter[I] = getTypeIDFor(TyInfo[I]);
681  LP.TypeIds.push_back(getFilterIDFor(IdsInFilter));
682 }
683 
685  for (unsigned i = 0; i != LandingPads.size(); ) {
686  LandingPadInfo &LandingPad = LandingPads[i];
687  if (LandingPad.LandingPadLabel &&
688  !LandingPad.LandingPadLabel->isDefined() &&
689  (!LPMap || (*LPMap)[LandingPad.LandingPadLabel] == 0))
690  LandingPad.LandingPadLabel = nullptr;
691 
692  // Special case: we *should* emit LPs with null LP MBB. This indicates
693  // "nounwind" case.
694  if (!LandingPad.LandingPadLabel && LandingPad.LandingPadBlock) {
695  LandingPads.erase(LandingPads.begin() + i);
696  continue;
697  }
698 
699  for (unsigned j = 0, e = LandingPads[i].BeginLabels.size(); j != e; ++j) {
700  MCSymbol *BeginLabel = LandingPad.BeginLabels[j];
701  MCSymbol *EndLabel = LandingPad.EndLabels[j];
702  if ((BeginLabel->isDefined() ||
703  (LPMap && (*LPMap)[BeginLabel] != 0)) &&
704  (EndLabel->isDefined() ||
705  (LPMap && (*LPMap)[EndLabel] != 0))) continue;
706 
707  LandingPad.BeginLabels.erase(LandingPad.BeginLabels.begin() + j);
708  LandingPad.EndLabels.erase(LandingPad.EndLabels.begin() + j);
709  --j;
710  --e;
711  }
712 
713  // Remove landing pads with no try-ranges.
714  if (LandingPads[i].BeginLabels.empty()) {
715  LandingPads.erase(LandingPads.begin() + i);
716  continue;
717  }
718 
719  // If there is no landing pad, ensure that the list of typeids is empty.
720  // If the only typeid is a cleanup, this is the same as having no typeids.
721  if (!LandingPad.LandingPadBlock ||
722  (LandingPad.TypeIds.size() == 1 && !LandingPad.TypeIds[0]))
723  LandingPad.TypeIds.clear();
724  ++i;
725  }
726 }
727 
729  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
730  LP.TypeIds.push_back(0);
731 }
732 
734  const Function *Filter,
735  const BlockAddress *RecoverBA) {
736  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
737  SEHHandler Handler;
738  Handler.FilterOrFinally = Filter;
739  Handler.RecoverBA = RecoverBA;
740  LP.SEHHandlers.push_back(Handler);
741 }
742 
744  const Function *Cleanup) {
745  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
746  SEHHandler Handler;
747  Handler.FilterOrFinally = Cleanup;
748  Handler.RecoverBA = nullptr;
749  LP.SEHHandlers.push_back(Handler);
750 }
751 
753  ArrayRef<unsigned> Sites) {
754  LPadToCallSiteMap[Sym].append(Sites.begin(), Sites.end());
755 }
756 
758  for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i)
759  if (TypeInfos[i] == TI) return i + 1;
760 
761  TypeInfos.push_back(TI);
762  return TypeInfos.size();
763 }
764 
765 int MachineFunction::getFilterIDFor(std::vector<unsigned> &TyIds) {
766  // If the new filter coincides with the tail of an existing filter, then
767  // re-use the existing filter. Folding filters more than this requires
768  // re-ordering filters and/or their elements - probably not worth it.
769  for (std::vector<unsigned>::iterator I = FilterEnds.begin(),
770  E = FilterEnds.end(); I != E; ++I) {
771  unsigned i = *I, j = TyIds.size();
772 
773  while (i && j)
774  if (FilterIds[--i] != TyIds[--j])
775  goto try_next;
776 
777  if (!j)
778  // The new filter coincides with range [i, end) of the existing filter.
779  return -(1 + i);
780 
781 try_next:;
782  }
783 
784  // Add the new filter.
785  int FilterID = -(1 + FilterIds.size());
786  FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
787  FilterIds.insert(FilterIds.end(), TyIds.begin(), TyIds.end());
788  FilterEnds.push_back(FilterIds.size());
789  FilterIds.push_back(0); // terminator
790  return FilterID;
791 }
792 
794  MachineFunction &MF = *MBB.getParent();
795  if (const auto *PF = dyn_cast<Function>(
797  MF.getMMI().addPersonality(PF);
798 
799  if (I.isCleanup())
800  MF.addCleanup(&MBB);
801 
802  // FIXME: New EH - Add the clauses in reverse order. This isn't 100% correct,
803  // but we need to do it this way because of how the DWARF EH emitter
804  // processes the clauses.
805  for (unsigned i = I.getNumClauses(); i != 0; --i) {
806  Value *Val = I.getClause(i - 1);
807  if (I.isCatch(i - 1)) {
808  MF.addCatchTypeInfo(&MBB,
809  dyn_cast<GlobalValue>(Val->stripPointerCasts()));
810  } else {
811  // Add filters in a list.
812  Constant *CVal = cast<Constant>(Val);
814  for (User::op_iterator II = CVal->op_begin(), IE = CVal->op_end();
815  II != IE; ++II)
816  FilterList.push_back(cast<GlobalValue>((*II)->stripPointerCasts()));
817 
818  MF.addFilterTypeInfo(&MBB, FilterList);
819  }
820  }
821 }
822 
823 /// \}
824 
825 //===----------------------------------------------------------------------===//
826 // MachineJumpTableInfo implementation
827 //===----------------------------------------------------------------------===//
828 
829 /// Return the size of each entry in the jump table.
831  // The size of a jump table entry is 4 bytes unless the entry is just the
832  // address of a block, in which case it is the pointer size.
833  switch (getEntryKind()) {
835  return TD.getPointerSize();
837  return 8;
841  return 4;
843  return 0;
844  }
845  llvm_unreachable("Unknown jump table encoding!");
846 }
847 
848 /// Return the alignment of each entry in the jump table.
850  // The alignment of a jump table entry is the alignment of int32 unless the
851  // entry is just the address of a block, in which case it is the pointer
852  // alignment.
853  switch (getEntryKind()) {
855  return TD.getPointerABIAlignment(0);
857  return TD.getABIIntegerTypeAlignment(64);
861  return TD.getABIIntegerTypeAlignment(32);
863  return 1;
864  }
865  llvm_unreachable("Unknown jump table encoding!");
866 }
867 
868 /// Create a new jump table entry in the jump table info.
870  const std::vector<MachineBasicBlock*> &DestBBs) {
871  assert(!DestBBs.empty() && "Cannot create an empty jump table!");
872  JumpTables.push_back(MachineJumpTableEntry(DestBBs));
873  return JumpTables.size()-1;
874 }
875 
876 /// If Old is the target of any jump tables, update the jump tables to branch
877 /// to New instead.
879  MachineBasicBlock *New) {
880  assert(Old != New && "Not making a change?");
881  bool MadeChange = false;
882  for (size_t i = 0, e = JumpTables.size(); i != e; ++i)
883  ReplaceMBBInJumpTable(i, Old, New);
884  return MadeChange;
885 }
886 
887 /// If Old is a target of the jump tables, update the jump table to branch to
888 /// New instead.
890  MachineBasicBlock *Old,
891  MachineBasicBlock *New) {
892  assert(Old != New && "Not making a change?");
893  bool MadeChange = false;
894  MachineJumpTableEntry &JTE = JumpTables[Idx];
895  for (size_t j = 0, e = JTE.MBBs.size(); j != e; ++j)
896  if (JTE.MBBs[j] == Old) {
897  JTE.MBBs[j] = New;
898  MadeChange = true;
899  }
900  return MadeChange;
901 }
902 
904  if (JumpTables.empty()) return;
905 
906  OS << "Jump Tables:\n";
907 
908  for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) {
909  OS << " jt#" << i << ": ";
910  for (unsigned j = 0, f = JumpTables[i].MBBs.size(); j != f; ++j)
911  OS << " BB#" << JumpTables[i].MBBs[j]->getNumber();
912  }
913 
914  OS << '\n';
915 }
916 
917 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
919 #endif
920 
921 //===----------------------------------------------------------------------===//
922 // MachineConstantPool implementation
923 //===----------------------------------------------------------------------===//
924 
925 void MachineConstantPoolValue::anchor() {}
926 
928  if (isMachineConstantPoolEntry())
929  return Val.MachineCPVal->getType();
930  return Val.ConstVal->getType();
931 }
932 
934  if (isMachineConstantPoolEntry())
935  return true;
936  return Val.ConstVal->needsRelocation();
937 }
938 
941  if (needsRelocation())
943  switch (DL->getTypeAllocSize(getType())) {
944  case 4:
946  case 8:
948  case 16:
950  case 32:
952  default:
953  return SectionKind::getReadOnly();
954  }
955 }
956 
958  // A constant may be a member of both Constants and MachineCPVsSharingEntries,
959  // so keep track of which we've deleted to avoid double deletions.
961  for (unsigned i = 0, e = Constants.size(); i != e; ++i)
962  if (Constants[i].isMachineConstantPoolEntry()) {
963  Deleted.insert(Constants[i].Val.MachineCPVal);
964  delete Constants[i].Val.MachineCPVal;
965  }
967  MachineCPVsSharingEntries.begin(), E = MachineCPVsSharingEntries.end();
968  I != E; ++I) {
969  if (Deleted.count(*I) == 0)
970  delete *I;
971  }
972 }
973 
974 /// Test whether the given two constants can be allocated the same constant pool
975 /// entry.
976 static bool CanShareConstantPoolEntry(const Constant *A, const Constant *B,
977  const DataLayout &DL) {
978  // Handle the trivial case quickly.
979  if (A == B) return true;
980 
981  // If they have the same type but weren't the same constant, quickly
982  // reject them.
983  if (A->getType() == B->getType()) return false;
984 
985  // We can't handle structs or arrays.
986  if (isa<StructType>(A->getType()) || isa<ArrayType>(A->getType()) ||
987  isa<StructType>(B->getType()) || isa<ArrayType>(B->getType()))
988  return false;
989 
990  // For now, only support constants with the same size.
991  uint64_t StoreSize = DL.getTypeStoreSize(A->getType());
992  if (StoreSize != DL.getTypeStoreSize(B->getType()) || StoreSize > 128)
993  return false;
994 
995  Type *IntTy = IntegerType::get(A->getContext(), StoreSize*8);
996 
997  // Try constant folding a bitcast of both instructions to an integer. If we
998  // get two identical ConstantInt's, then we are good to share them. We use
999  // the constant folding APIs to do this so that we get the benefit of
1000  // DataLayout.
1001  if (isa<PointerType>(A->getType()))
1002  A = ConstantFoldCastOperand(Instruction::PtrToInt,
1003  const_cast<Constant *>(A), IntTy, DL);
1004  else if (A->getType() != IntTy)
1005  A = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(A),
1006  IntTy, DL);
1007  if (isa<PointerType>(B->getType()))
1008  B = ConstantFoldCastOperand(Instruction::PtrToInt,
1009  const_cast<Constant *>(B), IntTy, DL);
1010  else if (B->getType() != IntTy)
1011  B = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(B),
1012  IntTy, DL);
1013 
1014  return A == B;
1015 }
1016 
1017 /// Create a new entry in the constant pool or return an existing one.
1018 /// User must specify the log2 of the minimum required alignment for the object.
1020  unsigned Alignment) {
1021  assert(Alignment && "Alignment must be specified!");
1022  if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1023 
1024  // Check to see if we already have this constant.
1025  //
1026  // FIXME, this could be made much more efficient for large constant pools.
1027  for (unsigned i = 0, e = Constants.size(); i != e; ++i)
1028  if (!Constants[i].isMachineConstantPoolEntry() &&
1029  CanShareConstantPoolEntry(Constants[i].Val.ConstVal, C, DL)) {
1030  if ((unsigned)Constants[i].getAlignment() < Alignment)
1031  Constants[i].Alignment = Alignment;
1032  return i;
1033  }
1034 
1035  Constants.push_back(MachineConstantPoolEntry(C, Alignment));
1036  return Constants.size()-1;
1037 }
1038 
1040  unsigned Alignment) {
1041  assert(Alignment && "Alignment must be specified!");
1042  if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1043 
1044  // Check to see if we already have this constant.
1045  //
1046  // FIXME, this could be made much more efficient for large constant pools.
1047  int Idx = V->getExistingMachineCPValue(this, Alignment);
1048  if (Idx != -1) {
1049  MachineCPVsSharingEntries.insert(V);
1050  return (unsigned)Idx;
1051  }
1052 
1053  Constants.push_back(MachineConstantPoolEntry(V, Alignment));
1054  return Constants.size()-1;
1055 }
1056 
1058  if (Constants.empty()) return;
1059 
1060  OS << "Constant Pool:\n";
1061  for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
1062  OS << " cp#" << i << ": ";
1063  if (Constants[i].isMachineConstantPoolEntry())
1064  Constants[i].Val.MachineCPVal->print(OS);
1065  else
1066  Constants[i].Val.ConstVal->printAsOperand(OS, /*PrintType=*/false);
1067  OS << ", align=" << Constants[i].getAlignment();
1068  OS << "\n";
1069  }
1070 }
1071 
1072 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1074 #endif
Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
uint64_t CallInst * C
void bundleWithPred()
Bundle this instruction with its predecessor.
void push_back(const T &Elt)
Definition: SmallVector.h:212
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...
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
unsigned getFnStackAlignment() const
Return the stack alignment for the function.
Definition: Function.h:278
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
livein_iterator livein_begin() const
static SectionKind getMergeableConst32()
Definition: SectionKind.h:195
iterator erase(iterator where)
Definition: ilist.h:280
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
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...
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad. Returns the label ID for the landing pad entry.
StringRef getPrivateGlobalPrefix() const
Definition: DataLayout.h:281
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
iterator begin() const
Definition: ArrayRef.h:137
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
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.
const MachineFunctionProperties & getProperties() const
Get the function properties.
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...
unsigned size() const
AtomicOrdering getFailureOrdering() const
For cmpxchg atomic operations, return the atomic ordering requirements when store does not occur...
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
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Definition: StringRef.h:138
This file contains the declarations for metadata subclasses.
EK_Inline - Jump table entries are emitted inline at their point of use.
std::string getNodeLabel(const MachineBasicBlock *Node, const MachineFunction *Graph)
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
virtual const TargetLowering * getTargetLowering() const
uint64_t getSize() const
Return the size in bytes of the memory reference.
static SectionKind getMergeableConst8()
Definition: SectionKind.h:193
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:728
static SectionKind getMergeableConst16()
Definition: SectionKind.h:194
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:262
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:489
A debug info location.
Definition: DebugLoc.h:34
Metadata node.
Definition: Metadata.h:862
F(f)
MachineModuleInfo & getMMI() const
Manage lifetime of a slot tracker for printing IR.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
uint64_t getBaseAlignment() const
Return the minimum known alignment in bytes of the base address, without the offset.
void dump() const
dump - Print the current MachineFunction to cerr, useful for debugger use.
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.
unsigned getPointerABIAlignment(unsigned AS) const
Layout pointer alignment.
Definition: DataLayout.cpp:587
StringRef getLinkerPrivateGlobalPrefix() const
Definition: DataLayout.h:261
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...
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist...
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about jump tables.
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
void addSEHCleanupHandler(MachineBasicBlock *LandingPad, const Function *Cleanup)
void print(raw_ostream &OS) const
Print the MachineFunctionProperties in human-readable form.
A description of a memory reference used in the backend.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
const DataLayout & getDataLayout() const
Get the data layout for the module&#39;s target platform.
Definition: Module.cpp:361
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
SmallVector< MCSymbol *, 1 > EndLabels
const MDNode * getRanges() const
Return the range tag for the memory reference.
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
SmallVector< SEHHandler, 1 > SEHHandlers
MachineInstr & CloneMachineInstrBundle(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig)
Clones instruction or the whole instruction bundle Orig and insert into MBB before InsertBefore...
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...
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:275
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.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
AtomicOrdering
Atomic ordering for LLVM&#39;s memory model.
static bool isSimple(Instruction *I)
Context object for machine code objects.
Definition: MCContext.h:59
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
This structure is used to retain landing pad info for the current function.
AtomicOrdering getOrdering() const
Return the atomic ordering requirements for this memory operation.
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
SlotIndexes pass.
Definition: SlotIndexes.h:331
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table...
livein_iterator livein_end() const
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 getPrefFunctionAlignment() const
Return the preferred function alignment.
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition: Function.h:634
This class is a data container for one entry in a MachineConstantPool.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they&#39;re not in a MachineFuncti...
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
const Value * getValue() const
Return the base address of the memory access.
static unsigned getFnStackAlignment(const TargetSubtargetInfo *STI, const Function *Fn)
#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:406
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about constant pool objects...
The landingpad instruction holds all of the information necessary to generate correct exception handl...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the TargetLowering::LowerCustomJ...
unsigned const MachineRegisterInfo * MRI
void print(const MachineFunction &MF, raw_ostream &OS) const
Used by the MachineFunction printer to print information about stack objects.
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
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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)
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
void addPersonality(const Function *Personality)
Provide the personality function for the exception information.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
Definition: Constant.h:42
SmallVector< MCSymbol *, 1 > BeginLabels
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:605
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.
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
std::vector< int > TypeIds
const PseudoSourceValue * getPseudoValue() const
static const unsigned End
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
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
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 &#39;dot&#39;, run gv on the postscript file, then cleanup.
Definition: GraphWriter.h:348
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
std::vector< MachineBasicBlock * > MBBs
MBBs - The vector of basic blocks from which to create the jump table.
void incorporateFunction(const Function &F)
Incorporate the given function.
Definition: AsmWriter.cpp:771
void DeleteMachineInstr(MachineInstr *MI)
DeleteMachineInstr - Delete the given MachineInstr.
const Constant * stripPointerCasts() const
Definition: Constant.h:153
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
Definition: Value.cpp:558
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Abstract base class for all machine specific constantpool value subclasses.
static wasm::ValType getType(const TargetRegisterClass *RC)
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 print(raw_ostream &OS, const SlotIndexes *=nullptr) const
print - Print out the MachineFunction in a format suitable for debugging to the specified stream...
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
void addCleanup(MachineBasicBlock *LandingPad)
Add a cleanup action for a landing pad.
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to &#39;dot...
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.
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
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 &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:864
MachineFunction(const Function *Fn, const TargetMachine &TM, unsigned FunctionNum, MachineModuleInfo &MMI)
Module.h This file contains the declarations for the Module class.
iterator end() const
Definition: ArrayRef.h:138
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
unsigned getABIIntegerTypeAlignment(unsigned BitWidth) const
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
Definition: DataLayout.cpp:688
void addCatchTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue *> TyInfo)
Provide the catch typeinfo for a landing pad.
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
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef< unsigned > Sites)
Map the landing pad&#39;s EH symbol to the call site indexes.
Target - Wrapper for Target specific information.
unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
bool isCleanup() const
Return &#39;true&#39; if this landingpad instruction is a cleanup.
MachineJumpTableEntry - One jump table in the jump table info.
iterator begin() const
Definition: StringRef.h:106
MachineBasicBlock * LandingPadBlock
Flags
Flags values. These may be or&#39;d together.
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.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Definition: DataLayout.h:403
static const char * getPropertyName(MachineFunctionProperties::Property Prop)
Representation of each machine instruction.
Definition: MachineInstr.h:59
std::vector< std::pair< unsigned, unsigned > >::const_iterator livein_iterator
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void ensureMaxAlignment(unsigned Align)
Make sure the function is at least Align bytes aligned.
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
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:220
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:108
#define I(x, y, z)
Definition: MD5.cpp:58
#define N
bool isDefined(bool SetUsed=true) const
isDefined - Check if this symbol is defined (i.e., it has an address).
Definition: MCSymbol.h:249
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
bool isCatch(unsigned Idx) const
Return &#39;true&#39; if the clause and index Idx is a catch clause.
Flags getFlags() const
Return the raw flags of the source value,.
virtual const TargetFrameLowering * getFrameLowering() const
SectionKind getSectionKind(const DataLayout *DL) const
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
size_type size() const
size - Returns the number of bits in this bitvector.
Definition: BitVector.h:170
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
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
void dump() const
dump - Call print(cerr) to be called from the debugger.
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
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())
unsigned getMinFunctionAlignment() const
Return the minimum function alignment.
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:462
aarch64 promote const
LandingPadInfo & getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad)
Find or create an LandingPadInfo for the specified MachineBasicBlock.
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:556
LLVM Value Representation.
Definition: Value.h:73
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Definition: Function.cpp:1260
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
Dellocate an array of MachineOperands and recycle the memory.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
Definition: DataLayout.h:386
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID for this memory operation.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
const BlockAddress * RecoverBA
Address of block to recover at. Null for a finally handler.
static const Function * getParent(const Value *V)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
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:57
unsigned createJumpTableIndex(const std::vector< MachineBasicBlock *> &DestBBs)
createJumpTableIndex - Create a new jump table.
void dump() const
dump - Call to stderr.
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
EK_GPRel32BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
unsigned getLiveInVirtReg(unsigned PReg) const
getLiveInVirtReg - If PReg is a live-in physical register, return the corresponding live-in physical ...
iterator end() const
Definition: StringRef.h:108
VariableDbgInfoMapTy VariableDbgInfos
static SectionKind getReadOnly()
Definition: SectionKind.h:182
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
unsigned getConstantPoolIndex(const Constant *C, unsigned Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one...
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry...
This class contains meta information specific to a module.
This file describes how to lower LLVM code to machine code.
void addFilterTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue *> TyInfo)
Provide the filter typeinfo for a landing pad.
const BasicBlock * getParent() const
Definition: Instruction.h:66
void tidyLandingPads(DenseMap< MCSymbol *, uintptr_t > *LPMap=nullptr)
Remap landing pad labels and remove any deleted landing pads.