LLVM  14.0.0git
MachineFunction.cpp
Go to the documentation of this file.
1 //===- MachineFunction.cpp ------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Collect native machine code information for a function. This allows
10 // target-specific information about the generated code to be stored with each
11 // function.
12 //
13 //===----------------------------------------------------------------------===//
14 
16 #include "llvm/ADT/BitVector.h"
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/DenseSet.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/ADT/SmallString.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/ADT/Twine.h"
42 #include "llvm/Config/llvm-config.h"
43 #include "llvm/IR/Attributes.h"
44 #include "llvm/IR/BasicBlock.h"
45 #include "llvm/IR/Constant.h"
46 #include "llvm/IR/DataLayout.h"
48 #include "llvm/IR/DerivedTypes.h"
49 #include "llvm/IR/Function.h"
50 #include "llvm/IR/GlobalValue.h"
51 #include "llvm/IR/Instruction.h"
52 #include "llvm/IR/Instructions.h"
53 #include "llvm/IR/Metadata.h"
54 #include "llvm/IR/Module.h"
56 #include "llvm/IR/Value.h"
57 #include "llvm/MC/MCContext.h"
58 #include "llvm/MC/MCSymbol.h"
59 #include "llvm/MC/SectionKind.h"
60 #include "llvm/Support/Casting.h"
62 #include "llvm/Support/Compiler.h"
64 #include "llvm/Support/Debug.h"
69 #include <algorithm>
70 #include <cassert>
71 #include <cstddef>
72 #include <cstdint>
73 #include <iterator>
74 #include <string>
75 #include <type_traits>
76 #include <utility>
77 #include <vector>
78 
79 using namespace llvm;
80 
81 #define DEBUG_TYPE "codegen"
82 
84  "align-all-functions",
85  cl::desc("Force the alignment of all functions in log2 format (e.g. 4 "
86  "means align on 16B boundaries)."),
87  cl::init(0), cl::Hidden);
88 
91 
92  switch(Prop) {
93  case P::FailedISel: return "FailedISel";
94  case P::IsSSA: return "IsSSA";
95  case P::Legalized: return "Legalized";
96  case P::NoPHIs: return "NoPHIs";
97  case P::NoVRegs: return "NoVRegs";
98  case P::RegBankSelected: return "RegBankSelected";
99  case P::Selected: return "Selected";
100  case P::TracksLiveness: return "TracksLiveness";
101  case P::TiedOpsRewritten: return "TiedOpsRewritten";
102  case P::FailsVerification: return "FailsVerification";
103  }
104  llvm_unreachable("Invalid machine function property");
105 }
106 
107 // Pin the vtable to this file.
108 void MachineFunction::Delegate::anchor() {}
109 
111  const char *Separator = "";
112  for (BitVector::size_type I = 0; I < Properties.size(); ++I) {
113  if (!Properties[I])
114  continue;
115  OS << Separator << getPropertyName(static_cast<Property>(I));
116  Separator = ", ";
117  }
118 }
119 
120 //===----------------------------------------------------------------------===//
121 // MachineFunction implementation
122 //===----------------------------------------------------------------------===//
123 
124 // Out-of-line virtual method.
126 
129 }
130 
131 static inline unsigned getFnStackAlignment(const TargetSubtargetInfo *STI,
132  const Function &F) {
133  if (auto MA = F.getFnStackAlign())
134  return MA->value();
135  return STI->getFrameLowering()->getStackAlign().value();
136 }
137 
139  const TargetSubtargetInfo &STI,
140  unsigned FunctionNum, MachineModuleInfo &mmi)
141  : F(F), Target(Target), STI(&STI), Ctx(mmi.getContext()), MMI(mmi) {
142  FunctionNumber = FunctionNum;
143  init();
144 }
145 
146 void MachineFunction::handleInsertion(MachineInstr &MI) {
147  if (TheDelegate)
148  TheDelegate->MF_HandleInsertion(MI);
149 }
150 
151 void MachineFunction::handleRemoval(MachineInstr &MI) {
152  if (TheDelegate)
153  TheDelegate->MF_HandleRemoval(MI);
154 }
155 
156 void MachineFunction::init() {
157  // Assume the function starts in SSA form with correct liveness.
160  if (STI->getRegisterInfo())
161  RegInfo = new (Allocator) MachineRegisterInfo(this);
162  else
163  RegInfo = nullptr;
164 
165  MFInfo = nullptr;
166  // We can realign the stack if the target supports it and the user hasn't
167  // explicitly asked us not to.
168  bool CanRealignSP = STI->getFrameLowering()->isStackRealignable() &&
169  !F.hasFnAttribute("no-realign-stack");
170  FrameInfo = new (Allocator) MachineFrameInfo(
171  getFnStackAlignment(STI, F), /*StackRealignable=*/CanRealignSP,
172  /*ForcedRealign=*/CanRealignSP &&
173  F.hasFnAttribute(Attribute::StackAlignment));
174 
175  if (F.hasFnAttribute(Attribute::StackAlignment))
176  FrameInfo->ensureMaxAlignment(*F.getFnStackAlign());
177 
178  ConstantPool = new (Allocator) MachineConstantPool(getDataLayout());
179  Alignment = STI->getTargetLowering()->getMinFunctionAlignment();
180 
181  // FIXME: Shouldn't use pref alignment if explicit alignment is set on F.
182  // FIXME: Use Function::hasOptSize().
183  if (!F.hasFnAttribute(Attribute::OptimizeForSize))
184  Alignment = std::max(Alignment,
186 
187  if (AlignAllFunctions)
188  Alignment = Align(1ULL << AlignAllFunctions);
189 
190  JumpTableInfo = nullptr;
191 
193  F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr))) {
194  WinEHInfo = new (Allocator) WinEHFuncInfo();
195  }
196 
198  F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr))) {
199  WasmEHInfo = new (Allocator) WasmEHFuncInfo();
200  }
201 
202  assert(Target.isCompatibleDataLayout(getDataLayout()) &&
203  "Can't create a MachineFunction using a Module with a "
204  "Target-incompatible DataLayout attached\n");
205 
206  PSVManager =
207  std::make_unique<PseudoSourceValueManager>(*(getSubtarget().
208  getInstrInfo()));
209 }
210 
212  clear();
213 }
214 
215 void MachineFunction::clear() {
216  Properties.reset();
217  // Don't call destructors on MachineInstr and MachineOperand. All of their
218  // memory comes from the BumpPtrAllocator which is about to be purged.
219  //
220  // Do call MachineBasicBlock destructors, it contains std::vectors.
221  for (iterator I = begin(), E = end(); I != E; I = BasicBlocks.erase(I))
222  I->Insts.clearAndLeakNodesUnsafely();
223  MBBNumbering.clear();
224 
225  InstructionRecycler.clear(Allocator);
226  OperandRecycler.clear(Allocator);
227  BasicBlockRecycler.clear(Allocator);
228  CodeViewAnnotations.clear();
230  if (RegInfo) {
231  RegInfo->~MachineRegisterInfo();
232  Allocator.Deallocate(RegInfo);
233  }
234  if (MFInfo) {
235  MFInfo->~MachineFunctionInfo();
236  Allocator.Deallocate(MFInfo);
237  }
238 
239  FrameInfo->~MachineFrameInfo();
240  Allocator.Deallocate(FrameInfo);
241 
242  ConstantPool->~MachineConstantPool();
243  Allocator.Deallocate(ConstantPool);
244 
245  if (JumpTableInfo) {
246  JumpTableInfo->~MachineJumpTableInfo();
247  Allocator.Deallocate(JumpTableInfo);
248  }
249 
250  if (WinEHInfo) {
251  WinEHInfo->~WinEHFuncInfo();
252  Allocator.Deallocate(WinEHInfo);
253  }
254 
255  if (WasmEHInfo) {
256  WasmEHInfo->~WasmEHFuncInfo();
257  Allocator.Deallocate(WasmEHInfo);
258  }
259 }
260 
262  return F.getParent()->getDataLayout();
263 }
264 
265 /// Get the JumpTableInfo for this function.
266 /// If it does not already exist, allocate one.
268 getOrCreateJumpTableInfo(unsigned EntryKind) {
269  if (JumpTableInfo) return JumpTableInfo;
270 
271  JumpTableInfo = new (Allocator)
273  return JumpTableInfo;
274 }
275 
277  return F.getDenormalMode(FPType);
278 }
279 
280 /// Should we be emitting segmented stack stuff for the function
282  return getFunction().hasFnAttribute("split-stack");
283 }
284 
285 LLVM_NODISCARD unsigned
287  FrameInstructions.push_back(Inst);
288  return FrameInstructions.size() - 1;
289 }
290 
291 /// This discards all of the MachineBasicBlock numbers and recomputes them.
292 /// This guarantees that the MBB numbers are sequential, dense, and match the
293 /// ordering of the blocks within the function. If a specific MachineBasicBlock
294 /// is specified, only that block and those after it are renumbered.
296  if (empty()) { MBBNumbering.clear(); return; }
298  if (MBB == nullptr)
299  MBBI = begin();
300  else
301  MBBI = MBB->getIterator();
302 
303  // Figure out the block number this should have.
304  unsigned BlockNo = 0;
305  if (MBBI != begin())
306  BlockNo = std::prev(MBBI)->getNumber() + 1;
307 
308  for (; MBBI != E; ++MBBI, ++BlockNo) {
309  if (MBBI->getNumber() != (int)BlockNo) {
310  // Remove use of the old number.
311  if (MBBI->getNumber() != -1) {
312  assert(MBBNumbering[MBBI->getNumber()] == &*MBBI &&
313  "MBB number mismatch!");
314  MBBNumbering[MBBI->getNumber()] = nullptr;
315  }
316 
317  // If BlockNo is already taken, set that block's number to -1.
318  if (MBBNumbering[BlockNo])
319  MBBNumbering[BlockNo]->setNumber(-1);
320 
321  MBBNumbering[BlockNo] = &*MBBI;
322  MBBI->setNumber(BlockNo);
323  }
324  }
325 
326  // Okay, all the blocks are renumbered. If we have compactified the block
327  // numbering, shrink MBBNumbering now.
328  assert(BlockNo <= MBBNumbering.size() && "Mismatch!");
329  MBBNumbering.resize(BlockNo);
330 }
331 
332 /// This method iterates over the basic blocks and assigns their IsBeginSection
333 /// and IsEndSection fields. This must be called after MBB layout is finalized
334 /// and the SectionID's are assigned to MBBs.
337  auto CurrentSectionID = front().getSectionID();
338  for (auto MBBI = std::next(begin()), E = end(); MBBI != E; ++MBBI) {
339  if (MBBI->getSectionID() == CurrentSectionID)
340  continue;
342  std::prev(MBBI)->setIsEndSection();
343  CurrentSectionID = MBBI->getSectionID();
344  }
345  back().setIsEndSection();
346 }
347 
348 /// Allocate a new MachineInstr. Use this instead of `new MachineInstr'.
350  const DebugLoc &DL,
351  bool NoImplicit) {
352  return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
353  MachineInstr(*this, MCID, DL, NoImplicit);
354 }
355 
356 /// Create a new MachineInstr which is a copy of the 'Orig' instruction,
357 /// identical in all ways except the instruction has no parent, prev, or next.
358 MachineInstr *
360  return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
361  MachineInstr(*this, *Orig);
362 }
363 
365  MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig) {
366  MachineInstr *FirstClone = nullptr;
368  while (true) {
369  MachineInstr *Cloned = CloneMachineInstr(&*I);
370  MBB.insert(InsertBefore, Cloned);
371  if (FirstClone == nullptr) {
372  FirstClone = Cloned;
373  } else {
374  Cloned->bundleWithPred();
375  }
376 
377  if (!I->isBundledWithSucc())
378  break;
379  ++I;
380  }
381  // Copy over call site info to the cloned instruction if needed. If Orig is in
382  // a bundle, copyCallSiteInfo takes care of finding the call instruction in
383  // the bundle.
384  if (Orig.shouldUpdateCallSiteInfo())
385  copyCallSiteInfo(&Orig, FirstClone);
386  return *FirstClone;
387 }
388 
389 /// Delete the given MachineInstr.
390 ///
391 /// This function also serves as the MachineInstr destructor - the real
392 /// ~MachineInstr() destructor must be empty.
393 void
395  // Verify that a call site info is at valid state. This assertion should
396  // be triggered during the implementation of support for the
397  // call site info of a new architecture. If the assertion is triggered,
398  // back trace will tell where to insert a call to updateCallSiteInfo().
399  assert((!MI->isCandidateForCallSiteEntry() ||
400  CallSitesInfo.find(MI) == CallSitesInfo.end()) &&
401  "Call site info was not updated!");
402  // Strip it for parts. The operand array and the MI object itself are
403  // independently recyclable.
404  if (MI->Operands)
405  deallocateOperandArray(MI->CapOperands, MI->Operands);
406  // Don't call ~MachineInstr() which must be trivial anyway because
407  // ~MachineFunction drops whole lists of MachineInstrs wihout calling their
408  // destructors.
409  InstructionRecycler.Deallocate(Allocator, MI);
410 }
411 
412 /// Allocate a new MachineBasicBlock. Use this instead of
413 /// `new MachineBasicBlock'.
416  return new (BasicBlockRecycler.Allocate<MachineBasicBlock>(Allocator))
417  MachineBasicBlock(*this, bb);
418 }
419 
420 /// Delete the given MachineBasicBlock.
421 void
423  assert(MBB->getParent() == this && "MBB parent mismatch!");
424  // Clean up any references to MBB in jump tables before deleting it.
425  if (JumpTableInfo)
426  JumpTableInfo->RemoveMBBFromJumpTables(MBB);
427  MBB->~MachineBasicBlock();
428  BasicBlockRecycler.Deallocate(Allocator, MBB);
429 }
430 
433  Align base_alignment, const AAMDNodes &AAInfo, const MDNode *Ranges,
434  SyncScope::ID SSID, AtomicOrdering Ordering,
435  AtomicOrdering FailureOrdering) {
436  return new (Allocator)
437  MachineMemOperand(PtrInfo, f, s, base_alignment, AAInfo, Ranges,
438  SSID, Ordering, FailureOrdering);
439 }
440 
443  Align base_alignment, const AAMDNodes &AAInfo, const MDNode *Ranges,
444  SyncScope::ID SSID, AtomicOrdering Ordering,
445  AtomicOrdering FailureOrdering) {
446  return new (Allocator)
447  MachineMemOperand(PtrInfo, f, MemTy, base_alignment, AAInfo, Ranges, SSID,
448  Ordering, FailureOrdering);
449 }
450 
452  const MachineMemOperand *MMO, const MachinePointerInfo &PtrInfo, uint64_t Size) {
453  return new (Allocator)
454  MachineMemOperand(PtrInfo, MMO->getFlags(), Size, MMO->getBaseAlign(),
455  AAMDNodes(), nullptr, MMO->getSyncScopeID(),
456  MMO->getSuccessOrdering(), MMO->getFailureOrdering());
457 }
458 
460  const MachineMemOperand *MMO, const MachinePointerInfo &PtrInfo, LLT Ty) {
461  return new (Allocator)
462  MachineMemOperand(PtrInfo, MMO->getFlags(), Ty, MMO->getBaseAlign(),
463  AAMDNodes(), nullptr, MMO->getSyncScopeID(),
464  MMO->getSuccessOrdering(), MMO->getFailureOrdering());
465 }
466 
469  int64_t Offset, LLT Ty) {
470  const MachinePointerInfo &PtrInfo = MMO->getPointerInfo();
471 
472  // If there is no pointer value, the offset isn't tracked so we need to adjust
473  // the base alignment.
474  Align Alignment = PtrInfo.V.isNull()
476  : MMO->getBaseAlign();
477 
478  // Do not preserve ranges, since we don't necessarily know what the high bits
479  // are anymore.
480  return new (Allocator) MachineMemOperand(
481  PtrInfo.getWithOffset(Offset), MMO->getFlags(), Ty, Alignment,
482  MMO->getAAInfo(), nullptr, MMO->getSyncScopeID(),
483  MMO->getSuccessOrdering(), MMO->getFailureOrdering());
484 }
485 
488  const AAMDNodes &AAInfo) {
489  MachinePointerInfo MPI = MMO->getValue() ?
490  MachinePointerInfo(MMO->getValue(), MMO->getOffset()) :
492 
493  return new (Allocator) MachineMemOperand(
494  MPI, MMO->getFlags(), MMO->getSize(), MMO->getBaseAlign(), AAInfo,
495  MMO->getRanges(), MMO->getSyncScopeID(), MMO->getSuccessOrdering(),
496  MMO->getFailureOrdering());
497 }
498 
501  MachineMemOperand::Flags Flags) {
502  return new (Allocator) MachineMemOperand(
503  MMO->getPointerInfo(), Flags, MMO->getSize(), MMO->getBaseAlign(),
504  MMO->getAAInfo(), MMO->getRanges(), MMO->getSyncScopeID(),
505  MMO->getSuccessOrdering(), MMO->getFailureOrdering());
506 }
507 
508 MachineInstr::ExtraInfo *MachineFunction::createMIExtraInfo(
509  ArrayRef<MachineMemOperand *> MMOs, MCSymbol *PreInstrSymbol,
510  MCSymbol *PostInstrSymbol, MDNode *HeapAllocMarker) {
511  return MachineInstr::ExtraInfo::create(Allocator, MMOs, PreInstrSymbol,
512  PostInstrSymbol, HeapAllocMarker);
513 }
514 
516  char *Dest = Allocator.Allocate<char>(Name.size() + 1);
517  llvm::copy(Name, Dest);
518  Dest[Name.size()] = 0;
519  return Dest;
520 }
521 
523  unsigned NumRegs = getSubtarget().getRegisterInfo()->getNumRegs();
524  unsigned Size = MachineOperand::getRegMaskSize(NumRegs);
525  uint32_t *Mask = Allocator.Allocate<uint32_t>(Size);
526  memset(Mask, 0, Size * sizeof(Mask[0]));
527  return Mask;
528 }
529 
531  int* AllocMask = Allocator.Allocate<int>(Mask.size());
532  copy(Mask, AllocMask);
533  return {AllocMask, Mask.size()};
534 }
535 
536 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
538  print(dbgs());
539 }
540 #endif
541 
543  return getFunction().getName();
544 }
545 
546 void MachineFunction::print(raw_ostream &OS, const SlotIndexes *Indexes) const {
547  OS << "# Machine code for function " << getName() << ": ";
548  getProperties().print(OS);
549  OS << '\n';
550 
551  // Print Frame Information
552  FrameInfo->print(*this, OS);
553 
554  // Print JumpTable Information
555  if (JumpTableInfo)
556  JumpTableInfo->print(OS);
557 
558  // Print Constant Pool
559  ConstantPool->print(OS);
560 
562 
563  if (RegInfo && !RegInfo->livein_empty()) {
564  OS << "Function Live Ins: ";
566  I = RegInfo->livein_begin(), E = RegInfo->livein_end(); I != E; ++I) {
567  OS << printReg(I->first, TRI);
568  if (I->second)
569  OS << " in " << printReg(I->second, TRI);
570  if (std::next(I) != E)
571  OS << ", ";
572  }
573  OS << '\n';
574  }
575 
578  for (const auto &BB : *this) {
579  OS << '\n';
580  // If we print the whole function, print it at its most verbose level.
581  BB.print(OS, MST, Indexes, /*IsStandalone=*/true);
582  }
583 
584  OS << "\n# End machine code for function " << getName() << ".\n\n";
585 }
586 
587 /// True if this function needs frame moves for debug or exceptions.
589  return getMMI().hasDebugInfo() ||
592 }
593 
594 namespace llvm {
595 
596  template<>
599 
600  static std::string getGraphName(const MachineFunction *F) {
601  return ("CFG for '" + F->getName() + "' function").str();
602  }
603 
604  std::string getNodeLabel(const MachineBasicBlock *Node,
605  const MachineFunction *Graph) {
606  std::string OutStr;
607  {
608  raw_string_ostream OSS(OutStr);
609 
610  if (isSimple()) {
611  OSS << printMBBReference(*Node);
612  if (const BasicBlock *BB = Node->getBasicBlock())
613  OSS << ": " << BB->getName();
614  } else
615  Node->print(OSS);
616  }
617 
618  if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
619 
620  // Process string output to make it nicer...
621  for (unsigned i = 0; i != OutStr.length(); ++i)
622  if (OutStr[i] == '\n') { // Left justify
623  OutStr[i] = '\\';
624  OutStr.insert(OutStr.begin()+i+1, 'l');
625  }
626  return OutStr;
627  }
628  };
629 
630 } // end namespace llvm
631 
633 {
634 #ifndef NDEBUG
635  ViewGraph(this, "mf" + getName());
636 #else
637  errs() << "MachineFunction::viewCFG is only available in debug builds on "
638  << "systems with Graphviz or gv!\n";
639 #endif // NDEBUG
640 }
641 
643 {
644 #ifndef NDEBUG
645  ViewGraph(this, "mf" + getName(), true);
646 #else
647  errs() << "MachineFunction::viewCFGOnly is only available in debug builds on "
648  << "systems with Graphviz or gv!\n";
649 #endif // NDEBUG
650 }
651 
652 /// Add the specified physical register as a live-in value and
653 /// create a corresponding virtual register for it.
655  const TargetRegisterClass *RC) {
657  Register VReg = MRI.getLiveInVirtReg(PReg);
658  if (VReg) {
659  const TargetRegisterClass *VRegRC = MRI.getRegClass(VReg);
660  (void)VRegRC;
661  // A physical register can be added several times.
662  // Between two calls, the register class of the related virtual register
663  // may have been constrained to match some operation constraints.
664  // In that case, check that the current register class includes the
665  // physical register and is a sub class of the specified RC.
666  assert((VRegRC == RC || (VRegRC->contains(PReg) &&
667  RC->hasSubClassEq(VRegRC))) &&
668  "Register class mismatch!");
669  return VReg;
670  }
671  VReg = MRI.createVirtualRegister(RC);
672  MRI.addLiveIn(PReg, VReg);
673  return VReg;
674 }
675 
676 /// Return the MCSymbol for the specified non-empty jump table.
677 /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
678 /// normal 'L' label is returned.
680  bool isLinkerPrivate) const {
681  const DataLayout &DL = getDataLayout();
682  assert(JumpTableInfo && "No jump tables");
683  assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
684 
685  StringRef Prefix = isLinkerPrivate ? DL.getLinkerPrivateGlobalPrefix()
686  : DL.getPrivateGlobalPrefix();
689  << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
690  return Ctx.getOrCreateSymbol(Name);
691 }
692 
693 /// Return a function-local symbol to represent the PIC base.
695  const DataLayout &DL = getDataLayout();
696  return Ctx.getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
697  Twine(getFunctionNumber()) + "$pb");
698 }
699 
700 /// \name Exception Handling
701 /// \{
702 
705  unsigned N = LandingPads.size();
706  for (unsigned i = 0; i < N; ++i) {
707  LandingPadInfo &LP = LandingPads[i];
708  if (LP.LandingPadBlock == LandingPad)
709  return LP;
710  }
711 
712  LandingPads.push_back(LandingPadInfo(LandingPad));
713  return LandingPads[N];
714 }
715 
717  MCSymbol *BeginLabel, MCSymbol *EndLabel) {
718  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
719  LP.BeginLabels.push_back(BeginLabel);
720  LP.EndLabels.push_back(EndLabel);
721 }
722 
724  MCSymbol *LandingPadLabel = Ctx.createTempSymbol();
725  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
726  LP.LandingPadLabel = LandingPadLabel;
727 
728  const Instruction *FirstI = LandingPad->getBasicBlock()->getFirstNonPHI();
729  if (const auto *LPI = dyn_cast<LandingPadInst>(FirstI)) {
730  if (const auto *PF =
731  dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts()))
732  getMMI().addPersonality(PF);
733 
734  if (LPI->isCleanup())
735  addCleanup(LandingPad);
736 
737  // FIXME: New EH - Add the clauses in reverse order. This isn't 100%
738  // correct, but we need to do it this way because of how the DWARF EH
739  // emitter processes the clauses.
740  for (unsigned I = LPI->getNumClauses(); I != 0; --I) {
741  Value *Val = LPI->getClause(I - 1);
742  if (LPI->isCatch(I - 1)) {
743  addCatchTypeInfo(LandingPad,
744  dyn_cast<GlobalValue>(Val->stripPointerCasts()));
745  } else {
746  // Add filters in a list.
747  auto *CVal = cast<Constant>(Val);
749  for (const Use &U : CVal->operands())
750  FilterList.push_back(cast<GlobalValue>(U->stripPointerCasts()));
751 
752  addFilterTypeInfo(LandingPad, FilterList);
753  }
754  }
755 
756  } else if (const auto *CPI = dyn_cast<CatchPadInst>(FirstI)) {
757  for (unsigned I = CPI->getNumArgOperands(); I != 0; --I) {
758  Value *TypeInfo = CPI->getArgOperand(I - 1)->stripPointerCasts();
759  addCatchTypeInfo(LandingPad, dyn_cast<GlobalValue>(TypeInfo));
760  }
761 
762  } else {
763  assert(isa<CleanupPadInst>(FirstI) && "Invalid landingpad!");
764  }
765 
766  return LandingPadLabel;
767 }
768 
771  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
772  for (unsigned N = TyInfo.size(); N; --N)
773  LP.TypeIds.push_back(getTypeIDFor(TyInfo[N - 1]));
774 }
775 
778  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
779  std::vector<unsigned> IdsInFilter(TyInfo.size());
780  for (unsigned I = 0, E = TyInfo.size(); I != E; ++I)
781  IdsInFilter[I] = getTypeIDFor(TyInfo[I]);
782  LP.TypeIds.push_back(getFilterIDFor(IdsInFilter));
783 }
784 
786  bool TidyIfNoBeginLabels) {
787  for (unsigned i = 0; i != LandingPads.size(); ) {
788  LandingPadInfo &LandingPad = LandingPads[i];
789  if (LandingPad.LandingPadLabel &&
790  !LandingPad.LandingPadLabel->isDefined() &&
791  (!LPMap || (*LPMap)[LandingPad.LandingPadLabel] == 0))
792  LandingPad.LandingPadLabel = nullptr;
793 
794  // Special case: we *should* emit LPs with null LP MBB. This indicates
795  // "nounwind" case.
796  if (!LandingPad.LandingPadLabel && LandingPad.LandingPadBlock) {
797  LandingPads.erase(LandingPads.begin() + i);
798  continue;
799  }
800 
801  if (TidyIfNoBeginLabels) {
802  for (unsigned j = 0, e = LandingPads[i].BeginLabels.size(); j != e; ++j) {
803  MCSymbol *BeginLabel = LandingPad.BeginLabels[j];
804  MCSymbol *EndLabel = LandingPad.EndLabels[j];
805  if ((BeginLabel->isDefined() || (LPMap && (*LPMap)[BeginLabel] != 0)) &&
806  (EndLabel->isDefined() || (LPMap && (*LPMap)[EndLabel] != 0)))
807  continue;
808 
809  LandingPad.BeginLabels.erase(LandingPad.BeginLabels.begin() + j);
810  LandingPad.EndLabels.erase(LandingPad.EndLabels.begin() + j);
811  --j;
812  --e;
813  }
814 
815  // Remove landing pads with no try-ranges.
816  if (LandingPads[i].BeginLabels.empty()) {
817  LandingPads.erase(LandingPads.begin() + i);
818  continue;
819  }
820  }
821 
822  // If there is no landing pad, ensure that the list of typeids is empty.
823  // If the only typeid is a cleanup, this is the same as having no typeids.
824  if (!LandingPad.LandingPadBlock ||
825  (LandingPad.TypeIds.size() == 1 && !LandingPad.TypeIds[0]))
826  LandingPad.TypeIds.clear();
827  ++i;
828  }
829 }
830 
832  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
833  LP.TypeIds.push_back(0);
834 }
835 
837  const Function *Filter,
838  const BlockAddress *RecoverBA) {
839  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
840  SEHHandler Handler;
841  Handler.FilterOrFinally = Filter;
842  Handler.RecoverBA = RecoverBA;
843  LP.SEHHandlers.push_back(Handler);
844 }
845 
847  const Function *Cleanup) {
848  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
849  SEHHandler Handler;
850  Handler.FilterOrFinally = Cleanup;
851  Handler.RecoverBA = nullptr;
852  LP.SEHHandlers.push_back(Handler);
853 }
854 
856  ArrayRef<unsigned> Sites) {
857  LPadToCallSiteMap[Sym].append(Sites.begin(), Sites.end());
858 }
859 
861  for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i)
862  if (TypeInfos[i] == TI) return i + 1;
863 
864  TypeInfos.push_back(TI);
865  return TypeInfos.size();
866 }
867 
868 int MachineFunction::getFilterIDFor(std::vector<unsigned> &TyIds) {
869  // If the new filter coincides with the tail of an existing filter, then
870  // re-use the existing filter. Folding filters more than this requires
871  // re-ordering filters and/or their elements - probably not worth it.
872  for (unsigned i : FilterEnds) {
873  unsigned j = TyIds.size();
874 
875  while (i && j)
876  if (FilterIds[--i] != TyIds[--j])
877  goto try_next;
878 
879  if (!j)
880  // The new filter coincides with range [i, end) of the existing filter.
881  return -(1 + i);
882 
883 try_next:;
884  }
885 
886  // Add the new filter.
887  int FilterID = -(1 + FilterIds.size());
888  FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
889  llvm::append_range(FilterIds, TyIds);
890  FilterEnds.push_back(FilterIds.size());
891  FilterIds.push_back(0); // terminator
892  return FilterID;
893 }
894 
896 MachineFunction::getCallSiteInfo(const MachineInstr *MI) {
897  assert(MI->isCandidateForCallSiteEntry() &&
898  "Call site info refers only to call (MI) candidates");
899 
900  if (!Target.Options.EmitCallSiteInfo)
901  return CallSitesInfo.end();
902  return CallSitesInfo.find(MI);
903 }
904 
905 /// Return the call machine instruction or find a call within bundle.
906 static const MachineInstr *getCallInstr(const MachineInstr *MI) {
907  if (!MI->isBundle())
908  return MI;
909 
910  for (auto &BMI : make_range(getBundleStart(MI->getIterator()),
911  getBundleEnd(MI->getIterator())))
912  if (BMI.isCandidateForCallSiteEntry())
913  return &BMI;
914 
915  llvm_unreachable("Unexpected bundle without a call site candidate");
916 }
917 
919  assert(MI->shouldUpdateCallSiteInfo() &&
920  "Call site info refers only to call (MI) candidates or "
921  "candidates inside bundles");
922 
923  const MachineInstr *CallMI = getCallInstr(MI);
924  CallSiteInfoMap::iterator CSIt = getCallSiteInfo(CallMI);
925  if (CSIt == CallSitesInfo.end())
926  return;
927  CallSitesInfo.erase(CSIt);
928 }
929 
931  const MachineInstr *New) {
933  "Call site info refers only to call (MI) candidates or "
934  "candidates inside bundles");
935 
936  if (!New->isCandidateForCallSiteEntry())
937  return eraseCallSiteInfo(Old);
938 
939  const MachineInstr *OldCallMI = getCallInstr(Old);
940  CallSiteInfoMap::iterator CSIt = getCallSiteInfo(OldCallMI);
941  if (CSIt == CallSitesInfo.end())
942  return;
943 
944  CallSiteInfo CSInfo = CSIt->second;
945  CallSitesInfo[New] = CSInfo;
946 }
947 
949  const MachineInstr *New) {
951  "Call site info refers only to call (MI) candidates or "
952  "candidates inside bundles");
953 
954  if (!New->isCandidateForCallSiteEntry())
955  return eraseCallSiteInfo(Old);
956 
957  const MachineInstr *OldCallMI = getCallInstr(Old);
958  CallSiteInfoMap::iterator CSIt = getCallSiteInfo(OldCallMI);
959  if (CSIt == CallSitesInfo.end())
960  return;
961 
962  CallSiteInfo CSInfo = std::move(CSIt->second);
963  CallSitesInfo.erase(CSIt);
964  CallSitesInfo[New] = CSInfo;
965 }
966 
969 }
970 
973  unsigned Subreg) {
974  // Catch any accidental self-loops.
975  assert(A.first != B.first);
976  // Don't allow any substitutions _from_ the memory operand number.
977  assert(A.second != DebugOperandMemNumber);
978 
979  DebugValueSubstitutions.push_back({A, B, Subreg});
980 }
981 
983  MachineInstr &New,
984  unsigned MaxOperand) {
985  // If the Old instruction wasn't tracked at all, there is no work to do.
986  unsigned OldInstrNum = Old.peekDebugInstrNum();
987  if (!OldInstrNum)
988  return;
989 
990  // Iterate over all operands looking for defs to create substitutions for.
991  // Avoid creating new instr numbers unless we create a new substitution.
992  // While this has no functional effect, it risks confusing someone reading
993  // MIR output.
994  // Examine all the operands, or the first N specified by the caller.
995  MaxOperand = std::min(MaxOperand, Old.getNumOperands());
996  for (unsigned int I = 0; I < MaxOperand; ++I) {
997  const auto &OldMO = Old.getOperand(I);
998  auto &NewMO = New.getOperand(I);
999  (void)NewMO;
1000 
1001  if (!OldMO.isReg() || !OldMO.isDef())
1002  continue;
1003  assert(NewMO.isDef());
1004 
1005  unsigned NewInstrNum = New.getDebugInstrNum();
1006  makeDebugValueSubstitution(std::make_pair(OldInstrNum, I),
1007  std::make_pair(NewInstrNum, I));
1008  }
1009 }
1010 
1013  MachineRegisterInfo &MRI = getRegInfo();
1015  const TargetInstrInfo &TII = *getSubtarget().getInstrInfo();
1016 
1017  // Chase the value read by a copy-like instruction back to the instruction
1018  // that ultimately _defines_ that value. This may pass:
1019  // * Through multiple intermediate copies, including subregister moves /
1020  // copies,
1021  // * Copies from physical registers that must then be traced back to the
1022  // defining instruction,
1023  // * Or, physical registers may be live-in to (only) the entry block, which
1024  // requires a DBG_PHI to be created.
1025  // We can pursue this problem in that order: trace back through copies,
1026  // optionally through a physical register, to a defining instruction. We
1027  // should never move from physreg to vreg. As we're still in SSA form, no need
1028  // to worry about partial definitions of registers.
1029 
1030  // Helper lambda to interpret a copy-like instruction. Takes instruction,
1031  // returns the register read and any subregister identifying which part is
1032  // read.
1033  auto GetRegAndSubreg =
1034  [&](const MachineInstr &Cpy) -> std::pair<Register, unsigned> {
1035  Register NewReg, OldReg;
1036  unsigned SubReg;
1037  if (Cpy.isCopy()) {
1038  OldReg = Cpy.getOperand(0).getReg();
1039  NewReg = Cpy.getOperand(1).getReg();
1040  SubReg = Cpy.getOperand(1).getSubReg();
1041  } else if (Cpy.isSubregToReg()) {
1042  OldReg = Cpy.getOperand(0).getReg();
1043  NewReg = Cpy.getOperand(2).getReg();
1044  SubReg = Cpy.getOperand(3).getImm();
1045  } else {
1046  auto CopyDetails = *TII.isCopyInstr(Cpy);
1047  const MachineOperand &Src = *CopyDetails.Source;
1048  const MachineOperand &Dest = *CopyDetails.Destination;
1049  OldReg = Dest.getReg();
1050  NewReg = Src.getReg();
1051  SubReg = Src.getSubReg();
1052  }
1053 
1054  return {NewReg, SubReg};
1055  };
1056 
1057  // First seek either the defining instruction, or a copy from a physreg.
1058  // During search, the current state is the current copy instruction, and which
1059  // register we've read. Accumulate qualifying subregisters into SubregsSeen;
1060  // deal with those later.
1061  auto State = GetRegAndSubreg(MI);
1062  auto CurInst = MI.getIterator();
1063  SmallVector<unsigned, 4> SubregsSeen;
1064  while (true) {
1065  // If we've found a copy from a physreg, first portion of search is over.
1066  if (!State.first.isVirtual())
1067  break;
1068 
1069  // Record any subregister qualifier.
1070  if (State.second)
1071  SubregsSeen.push_back(State.second);
1072 
1073  assert(MRI.hasOneDef(State.first));
1074  MachineInstr &Inst = *MRI.def_begin(State.first)->getParent();
1075  CurInst = Inst.getIterator();
1076 
1077  // Any non-copy instruction is the defining instruction we're seeking.
1078  if (!Inst.isCopyLike() && !TII.isCopyInstr(Inst))
1079  break;
1080  State = GetRegAndSubreg(Inst);
1081  };
1082 
1083  // Helper lambda to apply additional subregister substitutions to a known
1084  // instruction/operand pair. Adds new (fake) substitutions so that we can
1085  // record the subregister. FIXME: this isn't very space efficient if multiple
1086  // values are tracked back through the same copies; cache something later.
1087  auto ApplySubregisters =
1089  for (unsigned Subreg : reverse(SubregsSeen)) {
1090  // Fetch a new instruction number, not attached to an actual instruction.
1091  unsigned NewInstrNumber = getNewDebugInstrNum();
1092  // Add a substitution from the "new" number to the known one, with a
1093  // qualifying subreg.
1094  makeDebugValueSubstitution({NewInstrNumber, 0}, P, Subreg);
1095  // Return the new number; to find the underlying value, consumers need to
1096  // deal with the qualifying subreg.
1097  P = {NewInstrNumber, 0};
1098  }
1099  return P;
1100  };
1101 
1102  // If we managed to find the defining instruction after COPYs, return an
1103  // instruction / operand pair after adding subregister qualifiers.
1104  if (State.first.isVirtual()) {
1105  // Virtual register def -- we can just look up where this happens.
1106  MachineInstr *Inst = MRI.def_begin(State.first)->getParent();
1107  for (auto &MO : Inst->operands()) {
1108  if (!MO.isReg() || !MO.isDef() || MO.getReg() != State.first)
1109  continue;
1110  return ApplySubregisters(
1111  {Inst->getDebugInstrNum(), Inst->getOperandNo(&MO)});
1112  }
1113 
1114  llvm_unreachable("Vreg def with no corresponding operand?");
1115  }
1116 
1117  // Our search ended in a copy from a physreg: walk back up the function
1118  // looking for whatever defines the physreg.
1119  assert(CurInst->isCopyLike() || TII.isCopyInstr(*CurInst));
1120  State = GetRegAndSubreg(*CurInst);
1121  Register RegToSeek = State.first;
1122 
1123  auto RMII = CurInst->getReverseIterator();
1124  auto PrevInstrs = make_range(RMII, CurInst->getParent()->instr_rend());
1125  for (auto &ToExamine : PrevInstrs) {
1126  for (auto &MO : ToExamine.operands()) {
1127  // Test for operand that defines something aliasing RegToSeek.
1128  if (!MO.isReg() || !MO.isDef() ||
1129  !TRI.regsOverlap(RegToSeek, MO.getReg()))
1130  continue;
1131 
1132  return ApplySubregisters(
1133  {ToExamine.getDebugInstrNum(), ToExamine.getOperandNo(&MO)});
1134  }
1135  }
1136 
1137  MachineBasicBlock &InsertBB = *CurInst->getParent();
1138 
1139  // We reached the start of the block before finding a defining instruction.
1140  // It could be from a constant register, otherwise it must be an argument.
1141  if (TRI.isConstantPhysReg(State.first)) {
1142  // We can produce a DBG_PHI that identifies the constant physreg. Doesn't
1143  // matter where we put it, as it's constant valued.
1144  assert(CurInst->isCopy());
1145  } else if (State.first == TRI.getFrameRegister(*this)) {
1146  // LLVM IR is allowed to read the framepointer by calling a
1147  // llvm.frameaddress.* intrinsic. We can support this by emitting a
1148  // DBG_PHI $fp. This isn't ideal, because it extends the behaviours /
1149  // position that DBG_PHIs appear at, limiting what can be done later.
1150  // TODO: see if there's a better way of expressing these variable
1151  // locations.
1152  ;
1153  } else {
1154  // Assert that this is the entry block, or an EH pad. If it isn't, then
1155  // there is some code construct we don't recognise that deals with physregs
1156  // across blocks.
1157  assert(!State.first.isVirtual());
1158  assert(&*InsertBB.getParent()->begin() == &InsertBB || InsertBB.isEHPad());
1159  }
1160 
1161  // Create DBG_PHI for specified physreg.
1162  auto Builder = BuildMI(InsertBB, InsertBB.getFirstNonPHI(), DebugLoc(),
1163  TII.get(TargetOpcode::DBG_PHI));
1164  Builder.addReg(State.first);
1165  unsigned NewNum = getNewDebugInstrNum();
1166  Builder.addImm(NewNum);
1167  return ApplySubregisters({NewNum, 0u});
1168 }
1169 
1171  auto *TII = getSubtarget().getInstrInfo();
1172 
1173  auto MakeUndefDbgValue = [&](MachineInstr &MI) {
1174  const MCInstrDesc &RefII = TII->get(TargetOpcode::DBG_VALUE);
1175  MI.setDesc(RefII);
1176  MI.getOperand(0).setReg(0);
1177  MI.getOperand(1).ChangeToRegister(0, false);
1178  };
1179 
1180  if (!useDebugInstrRef())
1181  return;
1182 
1183  for (auto &MBB : *this) {
1184  for (auto &MI : MBB) {
1185  if (!MI.isDebugRef() || !MI.getOperand(0).isReg())
1186  continue;
1187 
1188  Register Reg = MI.getOperand(0).getReg();
1189 
1190  // Some vregs can be deleted as redundant in the meantime. Mark those
1191  // as DBG_VALUE $noreg. Additionally, some normal instructions are
1192  // quickly deleted, leaving dangling references to vregs with no def.
1193  if (Reg == 0 || !RegInfo->hasOneDef(Reg)) {
1194  MakeUndefDbgValue(MI);
1195  continue;
1196  }
1197 
1198  assert(Reg.isVirtual());
1199  MachineInstr &DefMI = *RegInfo->def_instr_begin(Reg);
1200 
1201  // If we've found a copy-like instruction, follow it back to the
1202  // instruction that defines the source value, see salvageCopySSA docs
1203  // for why this is important.
1204  if (DefMI.isCopyLike() || TII->isCopyInstr(DefMI)) {
1205  auto Result = salvageCopySSA(DefMI);
1206  MI.getOperand(0).ChangeToImmediate(Result.first);
1207  MI.getOperand(1).setImm(Result.second);
1208  } else {
1209  // Otherwise, identify the operand number that the VReg refers to.
1210  unsigned OperandIdx = 0;
1211  for (const auto &MO : DefMI.operands()) {
1212  if (MO.isReg() && MO.isDef() && MO.getReg() == Reg)
1213  break;
1214  ++OperandIdx;
1215  }
1216  assert(OperandIdx < DefMI.getNumOperands());
1217 
1218  // Morph this instr ref to point at the given instruction and operand.
1219  unsigned ID = DefMI.getDebugInstrNum();
1220  MI.getOperand(0).ChangeToImmediate(ID);
1221  MI.getOperand(1).setImm(OperandIdx);
1222  }
1223  }
1224  }
1225 }
1226 
1228  // Disable instr-ref at -O0: it's very slow (in compile time). We can still
1229  // have optimized code inlined into this unoptimized code, however with
1230  // fewer and less aggressive optimizations happening, coverage and accuracy
1231  // should not suffer.
1232  if (getTarget().getOptLevel() == CodeGenOpt::None)
1233  return false;
1234 
1235  // Don't use instr-ref if this function is marked optnone.
1236  if (F.hasFnAttribute(Attribute::OptimizeNone))
1237  return false;
1238 
1239  if (getTarget().Options.ValueTrackingVariableLocations)
1240  return true;
1241 
1242  return false;
1243 }
1244 
1245 // Use one million as a high / reserved number.
1246 const unsigned MachineFunction::DebugOperandMemNumber = 1000000;
1247 
1248 /// \}
1249 
1250 //===----------------------------------------------------------------------===//
1251 // MachineJumpTableInfo implementation
1252 //===----------------------------------------------------------------------===//
1253 
1254 /// Return the size of each entry in the jump table.
1256  // The size of a jump table entry is 4 bytes unless the entry is just the
1257  // address of a block, in which case it is the pointer size.
1258  switch (getEntryKind()) {
1260  return TD.getPointerSize();
1262  return 8;
1266  return 4;
1268  return 0;
1269  }
1270  llvm_unreachable("Unknown jump table encoding!");
1271 }
1272 
1273 /// Return the alignment of each entry in the jump table.
1275  // The alignment of a jump table entry is the alignment of int32 unless the
1276  // entry is just the address of a block, in which case it is the pointer
1277  // alignment.
1278  switch (getEntryKind()) {
1280  return TD.getPointerABIAlignment(0).value();
1282  return TD.getABIIntegerTypeAlignment(64).value();
1286  return TD.getABIIntegerTypeAlignment(32).value();
1288  return 1;
1289  }
1290  llvm_unreachable("Unknown jump table encoding!");
1291 }
1292 
1293 /// Create a new jump table entry in the jump table info.
1295  const std::vector<MachineBasicBlock*> &DestBBs) {
1296  assert(!DestBBs.empty() && "Cannot create an empty jump table!");
1297  JumpTables.push_back(MachineJumpTableEntry(DestBBs));
1298  return JumpTables.size()-1;
1299 }
1300 
1301 /// If Old is the target of any jump tables, update the jump tables to branch
1302 /// to New instead.
1304  MachineBasicBlock *New) {
1305  assert(Old != New && "Not making a change?");
1306  bool MadeChange = false;
1307  for (size_t i = 0, e = JumpTables.size(); i != e; ++i)
1308  ReplaceMBBInJumpTable(i, Old, New);
1309  return MadeChange;
1310 }
1311 
1312 /// If MBB is present in any jump tables, remove it.
1314  bool MadeChange = false;
1315  for (MachineJumpTableEntry &JTE : JumpTables) {
1316  auto removeBeginItr = std::remove(JTE.MBBs.begin(), JTE.MBBs.end(), MBB);
1317  MadeChange |= (removeBeginItr != JTE.MBBs.end());
1318  JTE.MBBs.erase(removeBeginItr, JTE.MBBs.end());
1319  }
1320  return MadeChange;
1321 }
1322 
1323 /// If Old is a target of the jump tables, update the jump table to branch to
1324 /// New instead.
1326  MachineBasicBlock *Old,
1327  MachineBasicBlock *New) {
1328  assert(Old != New && "Not making a change?");
1329  bool MadeChange = false;
1330  MachineJumpTableEntry &JTE = JumpTables[Idx];
1331  for (MachineBasicBlock *&MBB : JTE.MBBs)
1332  if (MBB == Old) {
1333  MBB = New;
1334  MadeChange = true;
1335  }
1336  return MadeChange;
1337 }
1338 
1340  if (JumpTables.empty()) return;
1341 
1342  OS << "Jump Tables:\n";
1343 
1344  for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) {
1345  OS << printJumpTableEntryReference(i) << ':';
1346  for (const MachineBasicBlock *MBB : JumpTables[i].MBBs)
1347  OS << ' ' << printMBBReference(*MBB);
1348  if (i != e)
1349  OS << '\n';
1350  }
1351 
1352  OS << '\n';
1353 }
1354 
1355 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1357 #endif
1358 
1360  return Printable([Idx](raw_ostream &OS) { OS << "%jump-table." << Idx; });
1361 }
1362 
1363 //===----------------------------------------------------------------------===//
1364 // MachineConstantPool implementation
1365 //===----------------------------------------------------------------------===//
1366 
1367 void MachineConstantPoolValue::anchor() {}
1368 
1370  return DL.getTypeAllocSize(Ty);
1371 }
1372 
1375  return Val.MachineCPVal->getSizeInBytes(DL);
1376  return DL.getTypeAllocSize(Val.ConstVal->getType());
1377 }
1378 
1381  return true;
1382  return Val.ConstVal->needsDynamicRelocation();
1383 }
1384 
1387  if (needsRelocation())
1389  switch (getSizeInBytes(*DL)) {
1390  case 4:
1392  case 8:
1394  case 16:
1396  case 32:
1398  default:
1399  return SectionKind::getReadOnly();
1400  }
1401 }
1402 
1404  // A constant may be a member of both Constants and MachineCPVsSharingEntries,
1405  // so keep track of which we've deleted to avoid double deletions.
1407  for (unsigned i = 0, e = Constants.size(); i != e; ++i)
1408  if (Constants[i].isMachineConstantPoolEntry()) {
1409  Deleted.insert(Constants[i].Val.MachineCPVal);
1410  delete Constants[i].Val.MachineCPVal;
1411  }
1412  for (MachineConstantPoolValue *CPV : MachineCPVsSharingEntries) {
1413  if (Deleted.count(CPV) == 0)
1414  delete CPV;
1415  }
1416 }
1417 
1418 /// Test whether the given two constants can be allocated the same constant pool
1419 /// entry.
1420 static bool CanShareConstantPoolEntry(const Constant *A, const Constant *B,
1421  const DataLayout &DL) {
1422  // Handle the trivial case quickly.
1423  if (A == B) return true;
1424 
1425  // If they have the same type but weren't the same constant, quickly
1426  // reject them.
1427  if (A->getType() == B->getType()) return false;
1428 
1429  // We can't handle structs or arrays.
1430  if (isa<StructType>(A->getType()) || isa<ArrayType>(A->getType()) ||
1431  isa<StructType>(B->getType()) || isa<ArrayType>(B->getType()))
1432  return false;
1433 
1434  // For now, only support constants with the same size.
1435  uint64_t StoreSize = DL.getTypeStoreSize(A->getType());
1436  if (StoreSize != DL.getTypeStoreSize(B->getType()) || StoreSize > 128)
1437  return false;
1438 
1439  Type *IntTy = IntegerType::get(A->getContext(), StoreSize*8);
1440 
1441  // Try constant folding a bitcast of both instructions to an integer. If we
1442  // get two identical ConstantInt's, then we are good to share them. We use
1443  // the constant folding APIs to do this so that we get the benefit of
1444  // DataLayout.
1445  if (isa<PointerType>(A->getType()))
1446  A = ConstantFoldCastOperand(Instruction::PtrToInt,
1447  const_cast<Constant *>(A), IntTy, DL);
1448  else if (A->getType() != IntTy)
1449  A = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(A),
1450  IntTy, DL);
1451  if (isa<PointerType>(B->getType()))
1452  B = ConstantFoldCastOperand(Instruction::PtrToInt,
1453  const_cast<Constant *>(B), IntTy, DL);
1454  else if (B->getType() != IntTy)
1455  B = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(B),
1456  IntTy, DL);
1457 
1458  return A == B;
1459 }
1460 
1461 /// Create a new entry in the constant pool or return an existing one.
1462 /// User must specify the log2 of the minimum required alignment for the object.
1464  Align Alignment) {
1465  if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1466 
1467  // Check to see if we already have this constant.
1468  //
1469  // FIXME, this could be made much more efficient for large constant pools.
1470  for (unsigned i = 0, e = Constants.size(); i != e; ++i)
1471  if (!Constants[i].isMachineConstantPoolEntry() &&
1472  CanShareConstantPoolEntry(Constants[i].Val.ConstVal, C, DL)) {
1473  if (Constants[i].getAlign() < Alignment)
1474  Constants[i].Alignment = Alignment;
1475  return i;
1476  }
1477 
1478  Constants.push_back(MachineConstantPoolEntry(C, Alignment));
1479  return Constants.size()-1;
1480 }
1481 
1483  Align Alignment) {
1484  if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1485 
1486  // Check to see if we already have this constant.
1487  //
1488  // FIXME, this could be made much more efficient for large constant pools.
1489  int Idx = V->getExistingMachineCPValue(this, Alignment);
1490  if (Idx != -1) {
1491  MachineCPVsSharingEntries.insert(V);
1492  return (unsigned)Idx;
1493  }
1494 
1495  Constants.push_back(MachineConstantPoolEntry(V, Alignment));
1496  return Constants.size()-1;
1497 }
1498 
1500  if (Constants.empty()) return;
1501 
1502  OS << "Constant Pool:\n";
1503  for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
1504  OS << " cp#" << i << ": ";
1505  if (Constants[i].isMachineConstantPoolEntry())
1506  Constants[i].Val.MachineCPVal->print(OS);
1507  else
1508  Constants[i].Val.ConstVal->printAsOperand(OS, /*PrintType=*/false);
1509  OS << ", align=" << Constants[i].getAlign().value();
1510  OS << "\n";
1511  }
1512 }
1513 
1514 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1516 #endif
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::MachineRegisterInfo::addLiveIn
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
Definition: MachineRegisterInfo.h:957
i
i
Definition: README.txt:29
llvm::WasmEHFuncInfo
Definition: WasmEHFuncInfo.h:32
llvm::DOTGraphTraits< const MachineFunction * >::getNodeLabel
std::string getNodeLabel(const MachineBasicBlock *Node, const MachineFunction *Graph)
Definition: MachineFunction.cpp:604
llvm::MachineInstr::getDebugInstrNum
unsigned getDebugInstrNum()
Fetch the instruction number of this MachineInstr.
Definition: MachineInstr.cpp:2373
llvm::SectionKind::getReadOnlyWithRel
static SectionKind getReadOnlyWithRel()
Definition: SectionKind.h:207
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:105
llvm::MachineInstr::getOperandNo
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
Definition: MachineInstr.h:683
MachineInstr.h
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:506
llvm::PointerUnion::isNull
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
Definition: PointerUnion.h:143
llvm::MachineRegisterInfo::def_begin
def_iterator def_begin(Register RegNo) const
Definition: MachineRegisterInfo.h:384
llvm::MachineConstantPool::getConstantPoolIndex
unsigned getConstantPoolIndex(const Constant *C, Align Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one.
Definition: MachineFunction.cpp:1463
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::MachineJumpTableInfo::RemoveMBBFromJumpTables
bool RemoveMBBFromJumpTables(MachineBasicBlock *MBB)
RemoveMBBFromJumpTables - If MBB is present in any jump tables, remove it.
Definition: MachineFunction.cpp:1313
Reg
unsigned Reg
Definition: MachineSink.cpp:1558
llvm::dwarf::Constants
Constants
Definition: Dwarf.h:427
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
TargetFrameLowering.h
llvm::MachineJumpTableInfo::createJumpTableIndex
unsigned createJumpTableIndex(const std::vector< MachineBasicBlock * > &DestBBs)
createJumpTableIndex - Create a new jump table.
Definition: MachineFunction.cpp:1294
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
llvm::MachineBasicBlock::getBasicBlock
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
Definition: MachineBasicBlock.h:202
Metadata.h
llvm::MachineRegisterInfo::createVirtualRegister
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
Definition: MachineRegisterInfo.cpp:158
llvm::MachineFunction::DebugInstrOperandPair
std::pair< unsigned, unsigned > DebugInstrOperandPair
Pair of instruction number and operand number.
Definition: MachineFunction.h:456
llvm::MachineFunction::allocateRegMask
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
Definition: MachineFunction.cpp:522
llvm::MachineFunctionProperties::print
void print(raw_ostream &OS) const
Print the MachineFunctionProperties in human-readable form.
Definition: MachineFunction.cpp:110
DebugInfoMetadata.h
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:164
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:52
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:72
llvm::Function
Definition: Function.h:62
llvm::MachineFunctionProperties::Property
Property
Definition: MachineFunction.h:155
llvm::MachineFunction::getContext
MCContext & getContext() const
Definition: MachineFunction.h:586
StringRef.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::TargetSubtargetInfo::getInstrInfo
virtual const TargetInstrInfo * getInstrInfo() const
Definition: TargetSubtargetInfo.h:92
llvm::MachineFunction::assignBeginEndSections
void assignBeginEndSections()
Assign IsBeginSection IsEndSection fields for basic blocks in this function.
Definition: MachineFunction.cpp:335
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:625
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::MachineRegisterInfo::def_instr_begin
def_instr_iterator def_instr_begin(Register RegNo) const
Definition: MachineRegisterInfo.h:397
llvm::Function::getFnStackAlign
MaybeAlign getFnStackAlign() const
Return the stack alignment for the function.
Definition: Function.h:419
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::MachineFunction::useDebugInstrRef
bool useDebugInstrRef() const
Returns true if the function's variable locations should be tracked with instruction referencing.
Definition: MachineFunction.cpp:1227
AlignAllFunctions
static cl::opt< unsigned > AlignAllFunctions("align-all-functions", cl::desc("Force the alignment of all functions in log2 format (e.g. 4 " "means align on 16B boundaries)."), cl::init(0), cl::Hidden)
llvm::TargetLoweringBase::getPrefFunctionAlignment
Align getPrefFunctionAlignment() const
Return the preferred function alignment.
Definition: TargetLowering.h:1777
llvm::MachineFunction::end
iterator end()
Definition: MachineFunction.h:818
llvm::LandingPadInfo::LandingPadLabel
MCSymbol * LandingPadLabel
Definition: MachineFunction.h:227
llvm::MachineFunction::getMachineMemOperand
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, Align 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.
Definition: MachineFunction.cpp:431
llvm::MachineMemOperand::getOffset
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
Definition: MachineMemOperand.h:227
llvm::printMBBReference
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
Definition: MachineBasicBlock.cpp:119
llvm::MachineRegisterInfo::livein_empty
bool livein_empty() const
Definition: MachineRegisterInfo.h:967
llvm::TargetRegisterInfo::isConstantPhysReg
virtual bool isConstantPhysReg(MCRegister PhysReg) const
Returns true if PhysReg is unallocatable and constant throughout the function.
Definition: TargetRegisterInfo.h:548
ErrorHandling.h
llvm::LandingPadInfo::SEHHandlers
SmallVector< SEHHandler, 1 > SEHHandlers
Definition: MachineFunction.h:226
llvm::MachineFunction::copyCallSiteInfo
void copyCallSiteInfo(const MachineInstr *Old, const MachineInstr *New)
Copy the call site info from Old to \ New.
Definition: MachineFunction.cpp:930
llvm::MCRegisterInfo::getNumRegs
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
Definition: MCRegisterInfo.h:491
llvm::MachineRegisterInfo::getTargetRegisterInfo
const TargetRegisterInfo * getTargetRegisterInfo() const
Definition: MachineRegisterInfo.h:153
llvm::MachineFunction::getOrCreateJumpTableInfo
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist,...
Definition: MachineFunction.cpp:268
llvm::MachineFunction::getFunctionNumber
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
Definition: MachineFunction.h:609
llvm::MachineInstr::bundleWithPred
void bundleWithPred()
Bundle this instruction with its predecessor.
Definition: MachineInstr.cpp:762
llvm::MachineFunction::back
const MachineBasicBlock & back() const
Definition: MachineFunction.h:830
MachineBasicBlock.h
llvm::ConstantPool
Definition: ConstantPools.h:43
llvm::TargetSubtargetInfo::getRegisterInfo
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
Definition: TargetSubtargetInfo.h:124
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
llvm::DenseMapBase::erase
bool erase(const KeyT &Val)
Definition: DenseMap.h:302
llvm::MachineModuleInfo::hasDebugInfo
bool hasDebugInfo() const
Returns true if valid debug info is present.
Definition: MachineModuleInfo.h:203
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:233
llvm::MachineFunction::moveCallSiteInfo
void moveCallSiteInfo(const MachineInstr *Old, const MachineInstr *New)
Move the call site info from Old to \New call site info.
Definition: MachineFunction.cpp:948
llvm::MachineConstantPoolValue
Abstract base class for all machine specific constantpool value subclasses.
Definition: MachineConstantPool.h:35
llvm::AAMDNodes
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:651
llvm::DenseMapIterator
Definition: DenseMap.h:56
llvm::MachineFunction::Delegate::MF_HandleRemoval
virtual void MF_HandleRemoval(MachineInstr &MI)=0
Callback before a removal. This should not modify the MI directly.
MachineJumpTableInfo.h
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
DenseMap.h
Module.h
llvm::reverse
auto reverse(ContainerTy &&C, std::enable_if_t< has_rbegin< ContainerTy >::value > *=nullptr)
Definition: STLExtras.h:359
llvm::MCSymbol::isDefined
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
Definition: MCSymbol.h:243
TargetInstrInfo.h
llvm::SectionKind::getMergeableConst16
static SectionKind getMergeableConst16()
Definition: SectionKind.h:197
llvm::MachineMemOperand
A description of a memory reference used in the backend.
Definition: MachineMemOperand.h:128
EHPersonalities.h
llvm::MachineRegisterInfo::getLiveInVirtReg
Register getLiveInVirtReg(MCRegister PReg) const
getLiveInVirtReg - If PReg is a live-in physical register, return the corresponding live-in virtual r...
Definition: MachineRegisterInfo.cpp:452
llvm::copy
OutputIt copy(R &&Range, OutputIt Out)
Definition: STLExtras.h:1632
llvm::MachineFunction::setCallSiteLandingPad
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef< unsigned > Sites)
Map the landing pad's EH symbol to the call site indexes.
Definition: MachineFunction.cpp:855
llvm::MachineJumpTableInfo::EK_BlockAddress
@ EK_BlockAddress
EK_BlockAddress - Each entry is a plain address of block, e.g.
Definition: MachineJumpTableInfo.h:49
llvm::MachineFunctionProperties::Property::IsSSA
@ IsSSA
getFnStackAlignment
static unsigned getFnStackAlignment(const TargetSubtargetInfo *STI, const Function &F)
Definition: MachineFunction.cpp:131
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::MachineInstr::peekDebugInstrNum
unsigned peekDebugInstrNum() const
Examine the instruction number of this MachineInstr.
Definition: MachineInstr.h:465
llvm::MachineFunction::addSEHCatchHandler
void addSEHCatchHandler(MachineBasicBlock *LandingPad, const Function *Filter, const BlockAddress *RecoverBA)
Definition: MachineFunction.cpp:836
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:893
llvm::ViewGraph
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:430
llvm::ModuleSlotTracker::incorporateFunction
void incorporateFunction(const Function &F)
Incorporate the given function.
Definition: AsmWriter.cpp:852
STLExtras.h
llvm::MachineFunction::getJTISymbol
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
Definition: MachineFunction.cpp:679
llvm::MachineMemOperand::getAAInfo
AAMDNodes getAAInfo() const
Return the AA tags for the memory reference.
Definition: MachineMemOperand.h:258
llvm::MachineJumpTableInfo::EK_Custom32
@ EK_Custom32
EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the TargetLowering::LowerCustomJ...
Definition: MachineJumpTableInfo.h:76
llvm::BitmaskEnumDetail::Mask
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
llvm::ModuleSlotTracker
Manage lifetime of a slot tracker for printing IR.
Definition: ModuleSlotTracker.h:44
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1559
ConstantFolding.h
llvm::SEHHandler::FilterOrFinally
const Function * FilterOrFinally
Filter or finally function. Null indicates a catch-all.
Definition: MachineFunction.h:215
F
#define F(x, y, z)
Definition: MD5.cpp:56
getPropertyName
static const char * getPropertyName(MachineFunctionProperties::Property Prop)
Definition: MachineFunction.cpp:89
llvm::MachineFunction::iterator
BasicBlockListType::iterator iterator
Definition: MachineFunction.h:798
MachineRegisterInfo.h
llvm::iplist_impl::erase
iterator erase(iterator where)
Definition: ilist.h:267
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::MachineJumpTableInfo::getEntrySize
unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
Definition: MachineFunction.cpp:1255
llvm::getBundleEnd
MachineBasicBlock::instr_iterator getBundleEnd(MachineBasicBlock::instr_iterator I)
Returns an iterator pointing beyond the bundle containing I.
Definition: MachineInstrBundle.h:60
llvm::MachineJumpTableInfo::ReplaceMBBInJumpTables
bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTables - If Old is the target of any jump tables, update the jump tables to branch to...
Definition: MachineFunction.cpp:1303
llvm::MachineJumpTableInfo::getEntryKind
JTEntryKind getEntryKind() const
Definition: MachineJumpTableInfo.h:84
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::MachineJumpTableInfo::dump
void dump() const
dump - Call to stderr.
Definition: MachineFunction.cpp:1356
llvm::classifyEHPersonality
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
Definition: EHPersonalities.cpp:21
llvm::SectionKind::getReadOnly
static SectionKind getReadOnly()
Definition: SectionKind.h:185
llvm::MachineMemOperand::getPointerInfo
const MachinePointerInfo & getPointerInfo() const
Definition: MachineMemOperand.h:202
LoopDeletionResult::Deleted
@ Deleted
Instruction.h
CommandLine.h
TargetLowering.h
llvm::MachineFunction::substituteDebugValuesForInst
void substituteDebugValuesForInst(const MachineInstr &Old, MachineInstr &New, unsigned MaxOperand=UINT_MAX)
Create substitutions for any tracked values in Old, to point at New.
Definition: MachineFunction.cpp:982
llvm::TargetRegisterClass::contains
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
Definition: TargetRegisterInfo.h:93
bb
< i1 > br i1 label label bb bb
Definition: README.txt:978
llvm::MachineFunction::front
const MachineBasicBlock & front() const
Definition: MachineFunction.h:828
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition: MachineFunction.h:644
llvm::MCContext::getOrCreateSymbol
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:191
llvm::TargetInstrInfo
TargetInstrInfo - Interface to description of machine instruction set.
Definition: TargetInstrInfo.h:97
GlobalValue.h
TargetMachine.h
llvm::BumpPtrAllocatorImpl::Allocate
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:145
llvm::MachineMemOperand::getBaseAlign
Align getBaseAlign() const
Return the minimum known alignment in bytes of the base address, without the offset.
Definition: MachineMemOperand.h:255
llvm::LandingPadInfo::EndLabels
SmallVector< MCSymbol *, 1 > EndLabels
Definition: MachineFunction.h:225
SmallString.h
f
Itanium Name Demangler i e convert the string _Z1fv into f()". You can also use the CRTP base ManglingParser to perform some simple analysis on the mangled name
llvm::MachineFrameInfo::ensureMaxAlignment
void ensureMaxAlignment(Align Alignment)
Make sure the function is at least Align bytes aligned.
Definition: MachineFrameInfo.cpp:31
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::MachineOperand::getRegMaskSize
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
Definition: MachineOperand.h:636
llvm::ConstantFoldCastOperand
Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
Definition: ConstantFolding.cpp:1275
llvm::MachineMemOperand::getValue
const Value * getValue() const
Return the base address of the memory access.
Definition: MachineMemOperand.h:211
llvm::TargetFrameLowering::getStackAlign
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
Definition: TargetFrameLowering.h:100
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::MachineInstr::getOperand
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:499
llvm::MachineFunction::getDenormalMode
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
Definition: MachineFunction.cpp:276
llvm::TargetOptions::ForceDwarfFrameSection
unsigned ForceDwarfFrameSection
Emit DWARF debug frame section.
Definition: TargetOptions.h:336
Twine.h
llvm::MachineFunction::salvageCopySSA
DebugInstrOperandPair salvageCopySSA(MachineInstr &MI)
Find the underlying defining instruction / operand for a COPY instruction while in SSA form.
Definition: MachineFunction.cpp:1011
llvm::MachineFunction::addCatchTypeInfo
void addCatchTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the catch typeinfo for a landing pad.
Definition: MachineFunction.cpp:769
MCContext.h
llvm::TargetLoweringBase::getMinFunctionAlignment
Align getMinFunctionAlignment() const
Return the minimum function alignment.
Definition: TargetLowering.h:1774
llvm::DataLayout::getABIIntegerTypeAlignment
Align getABIIntegerTypeAlignment(unsigned BitWidth) const
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
Definition: DataLayout.h:536
llvm::MachineFunction::DeleteMachineInstr
void DeleteMachineInstr(MachineInstr *MI)
DeleteMachineInstr - Delete the given MachineInstr.
Definition: MachineFunction.cpp:394
llvm::MachineJumpTableEntry::MBBs
std::vector< MachineBasicBlock * > MBBs
MBBs - The vector of basic blocks from which to create the jump table.
Definition: MachineJumpTableInfo.h:36
llvm::MachineFrameInfo::print
void print(const MachineFunction &MF, raw_ostream &OS) const
Used by the MachineFunction printer to print information about stack objects.
Definition: MachineFrameInfo.cpp:212
llvm::TargetRegisterClass
Definition: TargetRegisterInfo.h:46
llvm::MachineFunctionInfo::~MachineFunctionInfo
virtual ~MachineFunctionInfo()
MCSymbol.h
llvm::MachineFunction::getProperties
const MachineFunctionProperties & getProperties() const
Get the function properties.
Definition: MachineFunction.h:725
DenseSet.h
llvm::LandingPadInfo::TypeIds
std::vector< int > TypeIds
Definition: MachineFunction.h:228
PseudoSourceValue.h
TII
const HexagonInstrInfo * TII
Definition: HexagonCopyToCombine.cpp:129
llvm::MachineFunction::setDebugInstrNumberingCount
void setDebugInstrNumberingCount(unsigned Num)
Set value of DebugInstrNumberingCount field.
Definition: MachineFunction.cpp:967
llvm::MachineFunction::size
unsigned size() const
Definition: MachineFunction.h:826
llvm::MachineConstantPoolEntry::getSectionKind
SectionKind getSectionKind(const DataLayout *DL) const
Definition: MachineFunction.cpp:1386
llvm::MachineFunction::getTypeIDFor
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
Definition: MachineFunction.cpp:860
llvm::MCInstrDesc
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:195
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:49
llvm::MachineFunctionProperties::set
MachineFunctionProperties & set(Property P)
Definition: MachineFunction.h:173
llvm::Instruction
Definition: Instruction.h:45
llvm::MachineModuleInfo
This class contains meta information specific to a module.
Definition: MachineModuleInfo.h:78
llvm::MachineInstr::shouldUpdateCallSiteInfo
bool shouldUpdateCallSiteInfo() const
Return true if copying, moving, or erasing this instruction requires updating Call Site Info (see cop...
Definition: MachineInstr.cpp:723
llvm::TargetFrameLowering::isStackRealignable
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
Definition: TargetFrameLowering.h:122
llvm::MachineFunction::viewCFG
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
Definition: MachineFunction.cpp:632
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::Function::hasPersonalityFn
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition: Function.h:775
llvm::MachineFunction::shouldSplitStack
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
Definition: MachineFunction.cpp:281
llvm::TargetRegisterInfo::regsOverlap
bool regsOverlap(Register regA, Register regB) const
Returns true if the two registers are equal or alias each other.
Definition: TargetRegisterInfo.h:418
BitVector.h
llvm::MachineFunction::begin
iterator begin()
Definition: MachineFunction.h:816
llvm::SlotIndexes
SlotIndexes pass.
Definition: SlotIndexes.h:314
llvm::MachineConstantPool::~MachineConstantPool
~MachineConstantPool()
Definition: MachineFunction.cpp:1403
llvm::MachineFunction::addFilterTypeInfo
void addFilterTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the filter typeinfo for a landing pad.
Definition: MachineFunction.cpp:776
llvm::printJumpTableEntryReference
Printable printJumpTableEntryReference(unsigned Idx)
Prints a jump table entry reference.
Definition: MachineFunction.cpp:1359
llvm::MachineRegisterInfo::livein_begin
livein_iterator livein_begin() const
Definition: MachineRegisterInfo.h:965
CanShareConstantPoolEntry
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.
Definition: MachineFunction.cpp:1420
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::BasicBlock::getFirstNonPHI
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Definition: BasicBlock.cpp:216
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::MachineOperand::getParent
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
Definition: MachineOperand.h:238
llvm::MachineMemOperand::getSyncScopeID
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID for this memory operation.
Definition: MachineMemOperand.h:264
llvm::MachineFunction::tidyLandingPads
void tidyLandingPads(DenseMap< MCSymbol *, uintptr_t > *LPMap=nullptr, bool TidyIfNoBeginLabels=true)
Remap landing pad labels and remove any deleted landing pads.
Definition: MachineFunction.cpp:785
llvm::MachineFunction::addInvoke
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...
Definition: MachineFunction.cpp:716
llvm::MCCFIInstruction
Definition: MCDwarf.h:470
getCallInstr
static const MachineInstr * getCallInstr(const MachineInstr *MI)
Return the call machine instruction or find a call within bundle.
Definition: MachineFunction.cpp:906
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::SmallString
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:25
llvm::MachineFunction::viewCFGOnly
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
Definition: MachineFunction.cpp:642
llvm::MachineJumpTableInfo::EK_LabelDifference32
@ EK_LabelDifference32
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table.
Definition: MachineJumpTableInfo.h:68
llvm::DOTGraphTraits
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
Definition: DOTGraphTraits.h:166
llvm::MachineRegisterInfo::getRegClass
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
Definition: MachineRegisterInfo.h:634
llvm::MachineConstantPoolEntry::Val
union llvm::MachineConstantPoolEntry::@182 Val
The constant itself.
llvm::DOTGraphTraits< const MachineFunction * >::getGraphName
static std::string getGraphName(const MachineFunction *F)
Definition: MachineFunction.cpp:600
llvm::MachineFunction::getMMI
MachineModuleInfo & getMMI() const
Definition: MachineFunction.h:585
llvm::MachineFunction::deallocateOperandArray
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
Dellocate an array of MachineOperands and recycle the memory.
Definition: MachineFunction.h:979
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:634
llvm::AtomicOrdering
AtomicOrdering
Atomic ordering for LLVM's memory model.
Definition: AtomicOrdering.h:56
llvm::Function::hasFnAttribute
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.cpp:626
BasicBlock.h
llvm::cl::opt
Definition: CommandLine.h:1432
llvm::ClrHandlerType::Filter
@ Filter
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::MachineJumpTableInfo::EK_GPRel64BlockAddress
@ EK_GPRel64BlockAddress
EK_GPRel64BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative,...
Definition: MachineJumpTableInfo.h:54
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::WinEHFuncInfo
Definition: WinEHFuncInfo.h:90
llvm::MachineConstantPoolValue::getSizeInBytes
virtual unsigned getSizeInBytes(const DataLayout &DL) const
Definition: MachineFunction.cpp:1369
llvm::LandingPadInfo::BeginLabels
SmallVector< MCSymbol *, 1 > BeginLabels
Definition: MachineFunction.h:224
llvm::MachineFunctionProperties::Property::TracksLiveness
@ TracksLiveness
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
uint64_t
llvm::MachineFunction::createMIExtraInfo
MachineInstr::ExtraInfo * createMIExtraInfo(ArrayRef< MachineMemOperand * > MMOs, MCSymbol *PreInstrSymbol=nullptr, MCSymbol *PostInstrSymbol=nullptr, MDNode *HeapAllocMarker=nullptr)
Allocate and construct an extra info structure for a MachineInstr.
Definition: MachineFunction.cpp:508
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:578
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::MachineFunction::addSEHCleanupHandler
void addSEHCleanupHandler(MachineBasicBlock *LandingPad, const Function *Cleanup)
Definition: MachineFunction.cpp:846
llvm::MachineFunction::CloneMachineInstr
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
Definition: MachineFunction.cpp:359
s
multiplies can be turned into SHL s
Definition: README.txt:370
llvm::MachinePointerInfo
This class contains a discriminated union of information about pointers in memory operands,...
Definition: MachineMemOperand.h:38
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::TargetRegisterInfo::getFrameRegister
virtual Register getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::DenseMap
Definition: DenseMap.h:714
llvm::SyncScope::ID
uint8_t ID
Definition: LLVMContext.h:47
llvm::MachineConstantPool
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
Definition: MachineConstantPool.h:117
llvm::MachineFunction::dump
void dump() const
dump - Print the current MachineFunction to cerr, useful for debugger use.
Definition: MachineFunction.cpp:537
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::isScopedEHPersonality
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch,...
Definition: EHPersonalities.h:80
llvm::DenormalMode
Represent subnormal handling kind for floating point instruction inputs and outputs.
Definition: FloatingPointMode.h:67
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:441
llvm::MachineBasicBlock::getFirstNonPHI
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Definition: MachineBasicBlock.cpp:199
MachineConstantPool.h
llvm::MachineJumpTableInfo::JTEntryKind
JTEntryKind
JTEntryKind - This enum indicates how each entry of the jump table is represented and emitted.
Definition: MachineJumpTableInfo.h:46
llvm::MachineFunction::CreateMachineBasicBlock
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
Definition: MachineFunction.cpp:415
llvm::MachineFunction::finalizeDebugInstrRefs
void finalizeDebugInstrRefs()
Finalise any partially emitted debug instructions.
Definition: MachineFunction.cpp:1170
llvm::MachineBasicBlock::setIsEndSection
void setIsEndSection(bool V=true)
Definition: MachineBasicBlock.h:571
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:150
llvm::MachineMemOperand::Flags
Flags
Flags values. These may be or'd together.
Definition: MachineMemOperand.h:131
llvm::MachineFunction::getName
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Definition: MachineFunction.cpp:542
llvm::TargetMachine::Options
TargetOptions Options
Definition: TargetMachine.h:121
llvm::MachineFunction::~MachineFunction
~MachineFunction()
Definition: MachineFunction.cpp:211
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::MachineConstantPoolEntry::isMachineConstantPoolEntry
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
Definition: MachineConstantPool.h:93
llvm::LandingPadInfo::LandingPadBlock
MachineBasicBlock * LandingPadBlock
Definition: MachineFunction.h:223
llvm::DataLayout::getPointerABIAlignment
Align getPointerABIAlignment(unsigned AS) const
Layout pointer alignment.
Definition: DataLayout.cpp:698
llvm::MachineBasicBlock::getParent
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Definition: MachineBasicBlock.h:225
llvm::BitVector::size_type
unsigned size_type
Definition: BitVector.h:88
llvm::MachineMemOperand::getSuccessOrdering
AtomicOrdering getSuccessOrdering() const
Return the atomic ordering requirements for this memory operation.
Definition: MachineMemOperand.h:271
llvm::MachineFunction::makeDebugValueSubstitution
void makeDebugValueSubstitution(DebugInstrOperandPair, DebugInstrOperandPair, unsigned SubReg=0)
Create a substitution between one <instr,operand> value to a different, new value.
Definition: MachineFunction.cpp:971
MachineModuleInfo.h
llvm::MachineOperand::getReg
Register getReg() const
getReg - Returns the register number.
Definition: MachineOperand.h:360
llvm::MachineRegisterInfo::hasOneDef
bool hasOneDef(Register RegNo) const
Return true if there is exactly one operand defining the specified register.
Definition: MachineRegisterInfo.h:444
llvm::MDNode
Metadata node.
Definition: Metadata.h:906
llvm::MachinePointerInfo::getWithOffset
MachinePointerInfo getWithOffset(int64_t O) const
Definition: MachineMemOperand.h:80
llvm::ArrayRecycler::clear
void clear(AllocatorType &Allocator)
Release all the tracked allocations to the allocator.
Definition: ArrayRecycler.h:104
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:650
llvm::MachineFunction
Definition: MachineFunction.h:234
llvm::MachineConstantPoolEntry::needsRelocation
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry.
Definition: MachineFunction.cpp:1379
llvm::MachineFunction::addLiveIn
Register addLiveIn(MCRegister PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
Definition: MachineFunction.cpp:654
llvm::CodeGenOpt::None
@ None
Definition: CodeGen.h:53
llvm::sys::fs::remove
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
llvm::BlockAddress
The address of a basic block.
Definition: Constants.h:848
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::MachineBasicBlock::getNumber
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
Definition: MachineBasicBlock.h:1056
llvm::MachinePointerInfo::V
PointerUnion< const Value *, const PseudoSourceValue * > V
This is the IR pointer value for the access, or it is null if unknown.
Definition: MachineMemOperand.h:42
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
DataLayout.h
llvm::MachineFunction::DeleteMachineBasicBlock
void DeleteMachineBasicBlock(MachineBasicBlock *MBB)
DeleteMachineBasicBlock - Delete the given MachineBasicBlock.
Definition: MachineFunction.cpp:422
llvm::MachineFunction::allocateShuffleMask
ArrayRef< int > allocateShuffleMask(ArrayRef< int > Mask)
Definition: MachineFunction.cpp:530
llvm::MachineBasicBlock::isEHPad
bool isEHPad() const
Returns true if the block is a landing pad.
Definition: MachineBasicBlock.h:526
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
MBBI
MachineBasicBlock MachineBasicBlock::iterator MBBI
Definition: AArch64SLSHardening.cpp:75
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
A
* A
Definition: README_ALTIVEC.txt:89
getParent
static const Function * getParent(const Value *V)
Definition: BasicAliasAnalysis.cpp:870
uint32_t
Compiler.h
llvm::getBundleStart
MachineBasicBlock::instr_iterator getBundleStart(MachineBasicBlock::instr_iterator I)
Returns an iterator to the first instruction in the bundle containing I.
Definition: MachineInstrBundle.h:44
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Definition: STLExtras.h:1778
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition: ilist_node.h:81
llvm::MachineJumpTableInfo::print
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about jump tables.
Definition: MachineFunction.cpp:1339
TargetSubtargetInfo.h
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::MachineJumpTableInfo::ReplaceMBBInJumpTable
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...
Definition: MachineFunction.cpp:1325
llvm::MachineFunctionProperties::reset
MachineFunctionProperties & reset(Property P)
Definition: MachineFunction.h:178
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:309
llvm::MCContext::createTempSymbol
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Definition: MCContext.cpp:303
llvm::TargetSubtargetInfo
TargetSubtargetInfo - Generic base class for all target subtargets.
Definition: TargetSubtargetInfo.h:59
llvm::MachineBasicBlock::getSectionID
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
Definition: MachineBasicBlock.h:574
llvm::MachineFunction::DebugInstrNumberingCount
unsigned DebugInstrNumberingCount
A count of how many instructions in the function have had numbers assigned to them.
Definition: MachineFunction.h:449
llvm::Function::getDenormalMode
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
Definition: Function.cpp:672
llvm::MachineFunction::CloneMachineInstrBundle
MachineInstr & CloneMachineInstrBundle(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig)
Clones instruction or the whole instruction bundle Orig and insert into MBB before InsertBefore.
Definition: MachineFunction.cpp:364
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::Value::stripPointerCasts
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition: Value.cpp:685
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::MachineFunction::getFilterIDFor
int getFilterIDFor(std::vector< unsigned > &TyIds)
Return the id of the filter encoded by TyIds. This is function wide.
Definition: MachineFunction.cpp:868
llvm::MachineBasicBlock::setNumber
void setNumber(int N)
Definition: MachineBasicBlock.h:1057
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
Attributes.h
j
return j(j<< 16)
llvm::SectionKind::getMergeableConst8
static SectionKind getMergeableConst8()
Definition: SectionKind.h:196
Constant.h
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::commonAlignment
Align commonAlignment(Align A, Align B)
Returns the alignment that satisfies both alignments.
Definition: Alignment.h:211
llvm::SectionKind
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
llvm::MachineConstantPoolEntry
This class is a data container for one entry in a MachineConstantPool.
Definition: MachineConstantPool.h:67
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
GraphWriter.h
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:600
llvm::TargetSubtargetInfo::getFrameLowering
virtual const TargetFrameLowering * getFrameLowering() const
Definition: TargetSubtargetInfo.h:93
llvm::MachineFunction::needsFrameMoves
bool needsFrameMoves() const
True if this function needs frame moves for debug or exceptions.
Definition: MachineFunction.cpp:588
llvm::MachineInstr::isCopyLike
bool isCopyLike() const
Return true if the instruction behaves like a copy.
Definition: MachineInstr.h:1305
llvm::MachineFunction::getTarget
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Definition: MachineFunction.h:630
llvm::DenseMapBase::end
iterator end()
Definition: DenseMap.h:83
llvm::ArrayRef::begin
iterator begin() const
Definition: ArrayRef.h:151
llvm::MachineBasicBlock::insert
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
Definition: MachineBasicBlock.cpp:1314
llvm::ilist_iterator
Iterator for intrusive lists based on ilist_node.
Definition: ilist_iterator.h:57
MachineFrameInfo.h
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
WasmEHFuncInfo.h
llvm::MachineMemOperand::getSize
uint64_t getSize() const
Return the size in bytes of the memory reference.
Definition: MachineMemOperand.h:236
llvm::MachineJumpTableInfo::EK_Inline
@ EK_Inline
EK_Inline - Jump table entries are emitted inline at their point of use.
Definition: MachineJumpTableInfo.h:72
llvm::MachineBasicBlock::setIsBeginSection
void setIsBeginSection(bool V=true)
Definition: MachineBasicBlock.h:569
Casting.h
llvm::fltSemantics
Definition: APFloat.cpp:54
llvm::MachineRegisterInfo::livein_iterator
std::vector< std::pair< MCRegister, Register > >::const_iterator livein_iterator
Definition: MachineRegisterInfo.h:964
Function.h
llvm::MachineFunction::print
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
print - Print out the MachineFunction in a format suitable for debugging to the specified stream.
Definition: MachineFunction.cpp:546
llvm::MachineJumpTableEntry
MachineJumpTableEntry - One jump table in the jump table info.
Definition: MachineJumpTableInfo.h:34
DOTGraphTraits.h
LLVM_NODISCARD
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
Definition: Compiler.h:161
llvm::Function::needsUnwindTableEntry
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
Definition: Function.h:636
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:406
llvm::SmallVectorImpl::clear
void clear()
Definition: SmallVector.h:585
llvm::MachineFunction::MachineFunction
MachineFunction(Function &F, const LLVMTargetMachine &Target, const TargetSubtargetInfo &STI, unsigned FunctionNum, MachineModuleInfo &MMI)
Definition: MachineFunction.cpp:138
isSimple
static bool isSimple(Instruction *I)
Definition: SLPVectorizer.cpp:561
llvm::Function::getPersonalityFn
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Definition: Function.cpp:1829
SectionKind.h
llvm::MachineFunction::addCleanup
void addCleanup(MachineBasicBlock *LandingPad)
Add a cleanup action for a landing pad.
Definition: MachineFunction.cpp:831
llvm::MachineConstantPool::print
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about constant pool objects.
Definition: MachineFunction.cpp:1499
llvm::getAlign
bool getAlign(const Function &F, unsigned index, unsigned &align)
Definition: NVPTXUtilities.cpp:284
WinEHFuncInfo.h
llvm::MachineFunction::getPICBaseSymbol
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
Definition: MachineFunction.cpp:694
llvm::SEHHandler
Definition: MachineFunction.h:213
llvm::MachineFunction::addFrameInst
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
Definition: MachineFunction.cpp:286
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:107
Instructions.h
llvm::TargetSubtargetInfo::getTargetLowering
virtual const TargetLowering * getTargetLowering() const
Definition: TargetSubtargetInfo.h:96
SmallVector.h
llvm::ilist_alloc_traits::deleteNode
static void deleteNode(NodeTy *V)
Definition: ilist.h:41
llvm::MachineConstantPoolValue::getExistingMachineCPValue
virtual int getExistingMachineCPValue(MachineConstantPool *CP, Align Alignment)=0
llvm::Printable
Simple wrapper around std::function<void(raw_ostream&)>.
Definition: Printable.h:38
llvm::MachineModuleInfo::addPersonality
void addPersonality(const Function *Personality)
Provide the personality function for the exception information.
Definition: MachineModuleInfo.cpp:278
llvm::BuildMI
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Definition: MachineInstrBuilder.h:328
llvm::SectionKind::getMergeableConst4
static SectionKind getMergeableConst4()
Definition: SectionKind.h:195
N
#define N
DefMI
MachineInstrBuilder MachineInstrBuilder & DefMI
Definition: AArch64ExpandPseudoInsts.cpp:103
llvm::MachineFunction::DebugValueSubstitutions
SmallVector< DebugSubstitution, 8 > DebugValueSubstitutions
Debug value substitutions: a collection of DebugSubstitution objects, recording changes in where a va...
Definition: MachineFunction.h:488
llvm::MachineInstr::getNumOperands
unsigned getNumOperands() const
Retuns the total number of operands.
Definition: MachineInstr.h:492
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:163
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340
llvm::MachineFunction::getDataLayout
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Definition: MachineFunction.cpp:261
llvm::raw_svector_ostream
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:658
llvm::MachineJumpTableInfo::EK_GPRel32BlockAddress
@ EK_GPRel32BlockAddress
EK_GPRel32BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative,...
Definition: MachineJumpTableInfo.h:59
ModuleSlotTracker.h
MachineMemOperand.h
llvm::DefaultDOTGraphTraits
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
Definition: DOTGraphTraits.h:28
llvm::MachineMemOperand::getFailureOrdering
AtomicOrdering getFailureOrdering() const
For cmpxchg atomic operations, return the atomic ordering requirements when store does not occur.
Definition: MachineMemOperand.h:277
llvm::Module::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:401
DerivedTypes.h
llvm::LandingPadInfo
This structure is used to retain landing pad info for the current function.
Definition: MachineFunction.h:222
llvm::IntegerType::get
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:313
llvm::TargetRegisterClass::hasSubClassEq
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
Definition: TargetRegisterInfo.h:126
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::MachineFunction::createExternalSymbolName
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
Definition: MachineFunction.cpp:515
llvm::MachineJumpTableInfo::getEntryAlignment
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
Definition: MachineFunction.cpp:1274
llvm::MachineFunction::CreateMachineInstr
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL, bool NoImplicit=false)
CreateMachineInstr - Allocate a new MachineInstr.
Definition: MachineFunction.cpp:349
llvm::MachineFunction::DebugOperandMemNumber
const static unsigned int DebugOperandMemNumber
A reserved operand number representing the instructions memory operand, for instructions that have a ...
Definition: MachineFunction.h:549
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::MachineFunction::addLandingPad
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad, and extract the exception handling information from the landingpad instruction...
Definition: MachineFunction.cpp:723
llvm::cl::desc
Definition: CommandLine.h:412
llvm::MachineJumpTableInfo
Definition: MachineJumpTableInfo.h:42
llvm::SectionKind::getMergeableConst32
static SectionKind getMergeableConst32()
Definition: SectionKind.h:198
raw_ostream.h
llvm::MachineMemOperand::getRanges
const MDNode * getRanges() const
Return the range tag for the memory reference.
Definition: MachineMemOperand.h:261
llvm::MachineConstantPool::dump
void dump() const
dump - Call print(cerr) to be called from the debugger.
Definition: MachineFunction.cpp:1515
llvm::MachineFunction::empty
bool empty() const
Definition: MachineFunction.h:827
MachineFunction.h
llvm::printReg
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
Definition: TargetRegisterInfo.cpp:110
llvm::MachineFunction::eraseCallSiteInfo
void eraseCallSiteInfo(const MachineInstr *MI)
Following functions update call site info.
Definition: MachineFunction.cpp:918
llvm::MachineFunction::VariableDbgInfos
VariableDbgInfoMapTy VariableDbgInfos
Definition: MachineFunction.h:444
llvm::MachineInstrBundleIterator< MachineInstr >
Value.h
llvm::MachineRegisterInfo::livein_end
livein_iterator livein_end() const
Definition: MachineRegisterInfo.h:966
llvm::SEHHandler::RecoverBA
const BlockAddress * RecoverBA
Address of block to recover at. Null for a finally handler.
Definition: MachineFunction.h:218
llvm::DOTGraphTraits< const MachineFunction * >::DOTGraphTraits
DOTGraphTraits(bool isSimple=false)
Definition: MachineFunction.cpp:598
llvm::MachineInstr::operands
iterator_range< mop_iterator > operands()
Definition: MachineInstr.h:618
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::MachineMemOperand::getFlags
Flags getFlags() const
Return the raw flags of the source value,.
Definition: MachineMemOperand.h:220
TargetRegisterInfo.h
Debug.h
llvm::BumpPtrAllocatorImpl::Deallocate
void Deallocate(const void *Ptr, size_t Size, size_t)
Definition: Allocator.h:213
SubReg
unsigned SubReg
Definition: AArch64AdvSIMDScalarPass.cpp:104
llvm::MachineFunction::RenumberBlocks
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them.
Definition: MachineFunction.cpp:295
llvm::ArrayRef::end
iterator end() const
Definition: ArrayRef.h:152
llvm::MachineFunction::getOrCreateLandingPadInfo
LandingPadInfo & getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad)
Find or create an LandingPadInfo for the specified MachineBasicBlock.
Definition: MachineFunction.cpp:704
llvm::isFuncletEHPersonality
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
Definition: EHPersonalities.h:65
llvm::DataLayout::getPointerSize
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:706
llvm::MachineConstantPoolEntry::getSizeInBytes
unsigned getSizeInBytes(const DataLayout &DL) const
Definition: MachineFunction.cpp:1373
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:44
llvm::MCRegister
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:24
llvm::MachineMemOperand::getPseudoValue
const PseudoSourceValue * getPseudoValue() const
Definition: MachineMemOperand.h:213
llvm::MachineFunction::Delegate::MF_HandleInsertion
virtual void MF_HandleInsertion(MachineInstr &MI)=0
Callback after an insertion. This should not modify the MI directly.
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::LLT
Definition: LowLevelTypeImpl.h:40