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  // clang-format off
93  switch(Prop) {
94  case P::FailedISel: return "FailedISel";
95  case P::IsSSA: return "IsSSA";
96  case P::Legalized: return "Legalized";
97  case P::NoPHIs: return "NoPHIs";
98  case P::NoVRegs: return "NoVRegs";
99  case P::RegBankSelected: return "RegBankSelected";
100  case P::Selected: return "Selected";
101  case P::TracksLiveness: return "TracksLiveness";
102  case P::TiedOpsRewritten: return "TiedOpsRewritten";
103  case P::FailsVerification: return "FailsVerification";
104  case P::TracksDebugUserValues: return "TracksDebugUserValues";
105  }
106  // clang-format on
107  llvm_unreachable("Invalid machine function property");
108 }
109 
110 // Pin the vtable to this file.
111 void MachineFunction::Delegate::anchor() {}
112 
114  const char *Separator = "";
115  for (BitVector::size_type I = 0; I < Properties.size(); ++I) {
116  if (!Properties[I])
117  continue;
118  OS << Separator << getPropertyName(static_cast<Property>(I));
119  Separator = ", ";
120  }
121 }
122 
123 //===----------------------------------------------------------------------===//
124 // MachineFunction implementation
125 //===----------------------------------------------------------------------===//
126 
127 // Out-of-line virtual method.
129 
132 }
133 
134 static inline unsigned getFnStackAlignment(const TargetSubtargetInfo *STI,
135  const Function &F) {
136  if (auto MA = F.getFnStackAlign())
137  return MA->value();
138  return STI->getFrameLowering()->getStackAlign().value();
139 }
140 
142  const TargetSubtargetInfo &STI,
143  unsigned FunctionNum, MachineModuleInfo &mmi)
144  : F(F), Target(Target), STI(&STI), Ctx(mmi.getContext()), MMI(mmi) {
145  FunctionNumber = FunctionNum;
146  init();
147 }
148 
149 void MachineFunction::handleInsertion(MachineInstr &MI) {
150  if (TheDelegate)
151  TheDelegate->MF_HandleInsertion(MI);
152 }
153 
154 void MachineFunction::handleRemoval(MachineInstr &MI) {
155  if (TheDelegate)
156  TheDelegate->MF_HandleRemoval(MI);
157 }
158 
159 void MachineFunction::init() {
160  // Assume the function starts in SSA form with correct liveness.
163  if (STI->getRegisterInfo())
164  RegInfo = new (Allocator) MachineRegisterInfo(this);
165  else
166  RegInfo = nullptr;
167 
168  MFInfo = nullptr;
169  // We can realign the stack if the target supports it and the user hasn't
170  // explicitly asked us not to.
171  bool CanRealignSP = STI->getFrameLowering()->isStackRealignable() &&
172  !F.hasFnAttribute("no-realign-stack");
173  FrameInfo = new (Allocator) MachineFrameInfo(
174  getFnStackAlignment(STI, F), /*StackRealignable=*/CanRealignSP,
175  /*ForcedRealign=*/CanRealignSP &&
176  F.hasFnAttribute(Attribute::StackAlignment));
177 
178  if (F.hasFnAttribute(Attribute::StackAlignment))
179  FrameInfo->ensureMaxAlignment(*F.getFnStackAlign());
180 
181  ConstantPool = new (Allocator) MachineConstantPool(getDataLayout());
182  Alignment = STI->getTargetLowering()->getMinFunctionAlignment();
183 
184  // FIXME: Shouldn't use pref alignment if explicit alignment is set on F.
185  // FIXME: Use Function::hasOptSize().
186  if (!F.hasFnAttribute(Attribute::OptimizeForSize))
187  Alignment = std::max(Alignment,
189 
190  if (AlignAllFunctions)
191  Alignment = Align(1ULL << AlignAllFunctions);
192 
193  JumpTableInfo = nullptr;
194 
196  F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr))) {
197  WinEHInfo = new (Allocator) WinEHFuncInfo();
198  }
199 
201  F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr))) {
202  WasmEHInfo = new (Allocator) WasmEHFuncInfo();
203  }
204 
205  assert(Target.isCompatibleDataLayout(getDataLayout()) &&
206  "Can't create a MachineFunction using a Module with a "
207  "Target-incompatible DataLayout attached\n");
208 
209  PSVManager =
210  std::make_unique<PseudoSourceValueManager>(*(getSubtarget().
211  getInstrInfo()));
212 }
213 
215  clear();
216 }
217 
218 void MachineFunction::clear() {
219  Properties.reset();
220  // Don't call destructors on MachineInstr and MachineOperand. All of their
221  // memory comes from the BumpPtrAllocator which is about to be purged.
222  //
223  // Do call MachineBasicBlock destructors, it contains std::vectors.
224  for (iterator I = begin(), E = end(); I != E; I = BasicBlocks.erase(I))
225  I->Insts.clearAndLeakNodesUnsafely();
226  MBBNumbering.clear();
227 
228  InstructionRecycler.clear(Allocator);
229  OperandRecycler.clear(Allocator);
230  BasicBlockRecycler.clear(Allocator);
231  CodeViewAnnotations.clear();
233  if (RegInfo) {
234  RegInfo->~MachineRegisterInfo();
235  Allocator.Deallocate(RegInfo);
236  }
237  if (MFInfo) {
238  MFInfo->~MachineFunctionInfo();
239  Allocator.Deallocate(MFInfo);
240  }
241 
242  FrameInfo->~MachineFrameInfo();
243  Allocator.Deallocate(FrameInfo);
244 
245  ConstantPool->~MachineConstantPool();
246  Allocator.Deallocate(ConstantPool);
247 
248  if (JumpTableInfo) {
249  JumpTableInfo->~MachineJumpTableInfo();
250  Allocator.Deallocate(JumpTableInfo);
251  }
252 
253  if (WinEHInfo) {
254  WinEHInfo->~WinEHFuncInfo();
255  Allocator.Deallocate(WinEHInfo);
256  }
257 
258  if (WasmEHInfo) {
259  WasmEHInfo->~WasmEHFuncInfo();
260  Allocator.Deallocate(WasmEHInfo);
261  }
262 }
263 
265  return F.getParent()->getDataLayout();
266 }
267 
268 /// Get the JumpTableInfo for this function.
269 /// If it does not already exist, allocate one.
271 getOrCreateJumpTableInfo(unsigned EntryKind) {
272  if (JumpTableInfo) return JumpTableInfo;
273 
274  JumpTableInfo = new (Allocator)
276  return JumpTableInfo;
277 }
278 
280  return F.getDenormalMode(FPType);
281 }
282 
283 /// Should we be emitting segmented stack stuff for the function
285  return getFunction().hasFnAttribute("split-stack");
286 }
287 
288 LLVM_NODISCARD unsigned
290  FrameInstructions.push_back(Inst);
291  return FrameInstructions.size() - 1;
292 }
293 
294 /// This discards all of the MachineBasicBlock numbers and recomputes them.
295 /// This guarantees that the MBB numbers are sequential, dense, and match the
296 /// ordering of the blocks within the function. If a specific MachineBasicBlock
297 /// is specified, only that block and those after it are renumbered.
299  if (empty()) { MBBNumbering.clear(); return; }
301  if (MBB == nullptr)
302  MBBI = begin();
303  else
304  MBBI = MBB->getIterator();
305 
306  // Figure out the block number this should have.
307  unsigned BlockNo = 0;
308  if (MBBI != begin())
309  BlockNo = std::prev(MBBI)->getNumber() + 1;
310 
311  for (; MBBI != E; ++MBBI, ++BlockNo) {
312  if (MBBI->getNumber() != (int)BlockNo) {
313  // Remove use of the old number.
314  if (MBBI->getNumber() != -1) {
315  assert(MBBNumbering[MBBI->getNumber()] == &*MBBI &&
316  "MBB number mismatch!");
317  MBBNumbering[MBBI->getNumber()] = nullptr;
318  }
319 
320  // If BlockNo is already taken, set that block's number to -1.
321  if (MBBNumbering[BlockNo])
322  MBBNumbering[BlockNo]->setNumber(-1);
323 
324  MBBNumbering[BlockNo] = &*MBBI;
325  MBBI->setNumber(BlockNo);
326  }
327  }
328 
329  // Okay, all the blocks are renumbered. If we have compactified the block
330  // numbering, shrink MBBNumbering now.
331  assert(BlockNo <= MBBNumbering.size() && "Mismatch!");
332  MBBNumbering.resize(BlockNo);
333 }
334 
335 /// This method iterates over the basic blocks and assigns their IsBeginSection
336 /// and IsEndSection fields. This must be called after MBB layout is finalized
337 /// and the SectionID's are assigned to MBBs.
340  auto CurrentSectionID = front().getSectionID();
341  for (auto MBBI = std::next(begin()), E = end(); MBBI != E; ++MBBI) {
342  if (MBBI->getSectionID() == CurrentSectionID)
343  continue;
345  std::prev(MBBI)->setIsEndSection();
346  CurrentSectionID = MBBI->getSectionID();
347  }
348  back().setIsEndSection();
349 }
350 
351 /// Allocate a new MachineInstr. Use this instead of `new MachineInstr'.
353  DebugLoc DL,
354  bool NoImplicit) {
355  return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
356  MachineInstr(*this, MCID, std::move(DL), NoImplicit);
357 }
358 
359 /// Create a new MachineInstr which is a copy of the 'Orig' instruction,
360 /// identical in all ways except the instruction has no parent, prev, or next.
361 MachineInstr *
363  return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
364  MachineInstr(*this, *Orig);
365 }
366 
368  MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig) {
369  MachineInstr *FirstClone = nullptr;
371  while (true) {
372  MachineInstr *Cloned = CloneMachineInstr(&*I);
373  MBB.insert(InsertBefore, Cloned);
374  if (FirstClone == nullptr) {
375  FirstClone = Cloned;
376  } else {
377  Cloned->bundleWithPred();
378  }
379 
380  if (!I->isBundledWithSucc())
381  break;
382  ++I;
383  }
384  // Copy over call site info to the cloned instruction if needed. If Orig is in
385  // a bundle, copyCallSiteInfo takes care of finding the call instruction in
386  // the bundle.
387  if (Orig.shouldUpdateCallSiteInfo())
388  copyCallSiteInfo(&Orig, FirstClone);
389  return *FirstClone;
390 }
391 
392 /// Delete the given MachineInstr.
393 ///
394 /// This function also serves as the MachineInstr destructor - the real
395 /// ~MachineInstr() destructor must be empty.
396 void
398  // Verify that a call site info is at valid state. This assertion should
399  // be triggered during the implementation of support for the
400  // call site info of a new architecture. If the assertion is triggered,
401  // back trace will tell where to insert a call to updateCallSiteInfo().
402  assert((!MI->isCandidateForCallSiteEntry() ||
403  CallSitesInfo.find(MI) == CallSitesInfo.end()) &&
404  "Call site info was not updated!");
405  // Strip it for parts. The operand array and the MI object itself are
406  // independently recyclable.
407  if (MI->Operands)
408  deallocateOperandArray(MI->CapOperands, MI->Operands);
409  // Don't call ~MachineInstr() which must be trivial anyway because
410  // ~MachineFunction drops whole lists of MachineInstrs wihout calling their
411  // destructors.
412  InstructionRecycler.Deallocate(Allocator, MI);
413 }
414 
415 /// Allocate a new MachineBasicBlock. Use this instead of
416 /// `new MachineBasicBlock'.
419  return new (BasicBlockRecycler.Allocate<MachineBasicBlock>(Allocator))
420  MachineBasicBlock(*this, bb);
421 }
422 
423 /// Delete the given MachineBasicBlock.
424 void
426  assert(MBB->getParent() == this && "MBB parent mismatch!");
427  // Clean up any references to MBB in jump tables before deleting it.
428  if (JumpTableInfo)
429  JumpTableInfo->RemoveMBBFromJumpTables(MBB);
430  MBB->~MachineBasicBlock();
431  BasicBlockRecycler.Deallocate(Allocator, MBB);
432 }
433 
436  Align base_alignment, const AAMDNodes &AAInfo, const MDNode *Ranges,
437  SyncScope::ID SSID, AtomicOrdering Ordering,
438  AtomicOrdering FailureOrdering) {
439  return new (Allocator)
440  MachineMemOperand(PtrInfo, f, s, base_alignment, AAInfo, Ranges,
441  SSID, Ordering, FailureOrdering);
442 }
443 
446  Align base_alignment, const AAMDNodes &AAInfo, const MDNode *Ranges,
447  SyncScope::ID SSID, AtomicOrdering Ordering,
448  AtomicOrdering FailureOrdering) {
449  return new (Allocator)
450  MachineMemOperand(PtrInfo, f, MemTy, base_alignment, AAInfo, Ranges, SSID,
451  Ordering, FailureOrdering);
452 }
453 
455  const MachineMemOperand *MMO, const MachinePointerInfo &PtrInfo, uint64_t Size) {
456  return new (Allocator)
457  MachineMemOperand(PtrInfo, MMO->getFlags(), Size, MMO->getBaseAlign(),
458  AAMDNodes(), nullptr, MMO->getSyncScopeID(),
459  MMO->getSuccessOrdering(), MMO->getFailureOrdering());
460 }
461 
463  const MachineMemOperand *MMO, const MachinePointerInfo &PtrInfo, LLT Ty) {
464  return new (Allocator)
465  MachineMemOperand(PtrInfo, MMO->getFlags(), Ty, MMO->getBaseAlign(),
466  AAMDNodes(), nullptr, MMO->getSyncScopeID(),
467  MMO->getSuccessOrdering(), MMO->getFailureOrdering());
468 }
469 
472  int64_t Offset, LLT Ty) {
473  const MachinePointerInfo &PtrInfo = MMO->getPointerInfo();
474 
475  // If there is no pointer value, the offset isn't tracked so we need to adjust
476  // the base alignment.
477  Align Alignment = PtrInfo.V.isNull()
479  : MMO->getBaseAlign();
480 
481  // Do not preserve ranges, since we don't necessarily know what the high bits
482  // are anymore.
483  return new (Allocator) MachineMemOperand(
484  PtrInfo.getWithOffset(Offset), MMO->getFlags(), Ty, Alignment,
485  MMO->getAAInfo(), nullptr, MMO->getSyncScopeID(),
486  MMO->getSuccessOrdering(), MMO->getFailureOrdering());
487 }
488 
491  const AAMDNodes &AAInfo) {
492  MachinePointerInfo MPI = MMO->getValue() ?
493  MachinePointerInfo(MMO->getValue(), MMO->getOffset()) :
495 
496  return new (Allocator) MachineMemOperand(
497  MPI, MMO->getFlags(), MMO->getSize(), MMO->getBaseAlign(), AAInfo,
498  MMO->getRanges(), MMO->getSyncScopeID(), MMO->getSuccessOrdering(),
499  MMO->getFailureOrdering());
500 }
501 
504  MachineMemOperand::Flags Flags) {
505  return new (Allocator) MachineMemOperand(
506  MMO->getPointerInfo(), Flags, MMO->getSize(), MMO->getBaseAlign(),
507  MMO->getAAInfo(), MMO->getRanges(), MMO->getSyncScopeID(),
508  MMO->getSuccessOrdering(), MMO->getFailureOrdering());
509 }
510 
511 MachineInstr::ExtraInfo *MachineFunction::createMIExtraInfo(
512  ArrayRef<MachineMemOperand *> MMOs, MCSymbol *PreInstrSymbol,
513  MCSymbol *PostInstrSymbol, MDNode *HeapAllocMarker) {
514  return MachineInstr::ExtraInfo::create(Allocator, MMOs, PreInstrSymbol,
515  PostInstrSymbol, HeapAllocMarker);
516 }
517 
519  char *Dest = Allocator.Allocate<char>(Name.size() + 1);
520  llvm::copy(Name, Dest);
521  Dest[Name.size()] = 0;
522  return Dest;
523 }
524 
526  unsigned NumRegs = getSubtarget().getRegisterInfo()->getNumRegs();
527  unsigned Size = MachineOperand::getRegMaskSize(NumRegs);
528  uint32_t *Mask = Allocator.Allocate<uint32_t>(Size);
529  memset(Mask, 0, Size * sizeof(Mask[0]));
530  return Mask;
531 }
532 
534  int* AllocMask = Allocator.Allocate<int>(Mask.size());
535  copy(Mask, AllocMask);
536  return {AllocMask, Mask.size()};
537 }
538 
539 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
541  print(dbgs());
542 }
543 #endif
544 
546  return getFunction().getName();
547 }
548 
549 void MachineFunction::print(raw_ostream &OS, const SlotIndexes *Indexes) const {
550  OS << "# Machine code for function " << getName() << ": ";
551  getProperties().print(OS);
552  OS << '\n';
553 
554  // Print Frame Information
555  FrameInfo->print(*this, OS);
556 
557  // Print JumpTable Information
558  if (JumpTableInfo)
559  JumpTableInfo->print(OS);
560 
561  // Print Constant Pool
562  ConstantPool->print(OS);
563 
565 
566  if (RegInfo && !RegInfo->livein_empty()) {
567  OS << "Function Live Ins: ";
569  I = RegInfo->livein_begin(), E = RegInfo->livein_end(); I != E; ++I) {
570  OS << printReg(I->first, TRI);
571  if (I->second)
572  OS << " in " << printReg(I->second, TRI);
573  if (std::next(I) != E)
574  OS << ", ";
575  }
576  OS << '\n';
577  }
578 
581  for (const auto &BB : *this) {
582  OS << '\n';
583  // If we print the whole function, print it at its most verbose level.
584  BB.print(OS, MST, Indexes, /*IsStandalone=*/true);
585  }
586 
587  OS << "\n# End machine code for function " << getName() << ".\n\n";
588 }
589 
590 /// True if this function needs frame moves for debug or exceptions.
592  return getMMI().hasDebugInfo() ||
595 }
596 
597 namespace llvm {
598 
599  template<>
602 
603  static std::string getGraphName(const MachineFunction *F) {
604  return ("CFG for '" + F->getName() + "' function").str();
605  }
606 
607  std::string getNodeLabel(const MachineBasicBlock *Node,
608  const MachineFunction *Graph) {
609  std::string OutStr;
610  {
611  raw_string_ostream OSS(OutStr);
612 
613  if (isSimple()) {
614  OSS << printMBBReference(*Node);
615  if (const BasicBlock *BB = Node->getBasicBlock())
616  OSS << ": " << BB->getName();
617  } else
618  Node->print(OSS);
619  }
620 
621  if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
622 
623  // Process string output to make it nicer...
624  for (unsigned i = 0; i != OutStr.length(); ++i)
625  if (OutStr[i] == '\n') { // Left justify
626  OutStr[i] = '\\';
627  OutStr.insert(OutStr.begin()+i+1, 'l');
628  }
629  return OutStr;
630  }
631  };
632 
633 } // end namespace llvm
634 
636 {
637 #ifndef NDEBUG
638  ViewGraph(this, "mf" + getName());
639 #else
640  errs() << "MachineFunction::viewCFG is only available in debug builds on "
641  << "systems with Graphviz or gv!\n";
642 #endif // NDEBUG
643 }
644 
646 {
647 #ifndef NDEBUG
648  ViewGraph(this, "mf" + getName(), true);
649 #else
650  errs() << "MachineFunction::viewCFGOnly is only available in debug builds on "
651  << "systems with Graphviz or gv!\n";
652 #endif // NDEBUG
653 }
654 
655 /// Add the specified physical register as a live-in value and
656 /// create a corresponding virtual register for it.
658  const TargetRegisterClass *RC) {
660  Register VReg = MRI.getLiveInVirtReg(PReg);
661  if (VReg) {
662  const TargetRegisterClass *VRegRC = MRI.getRegClass(VReg);
663  (void)VRegRC;
664  // A physical register can be added several times.
665  // Between two calls, the register class of the related virtual register
666  // may have been constrained to match some operation constraints.
667  // In that case, check that the current register class includes the
668  // physical register and is a sub class of the specified RC.
669  assert((VRegRC == RC || (VRegRC->contains(PReg) &&
670  RC->hasSubClassEq(VRegRC))) &&
671  "Register class mismatch!");
672  return VReg;
673  }
674  VReg = MRI.createVirtualRegister(RC);
675  MRI.addLiveIn(PReg, VReg);
676  return VReg;
677 }
678 
679 /// Return the MCSymbol for the specified non-empty jump table.
680 /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
681 /// normal 'L' label is returned.
683  bool isLinkerPrivate) const {
684  const DataLayout &DL = getDataLayout();
685  assert(JumpTableInfo && "No jump tables");
686  assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
687 
688  StringRef Prefix = isLinkerPrivate ? DL.getLinkerPrivateGlobalPrefix()
689  : DL.getPrivateGlobalPrefix();
692  << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
693  return Ctx.getOrCreateSymbol(Name);
694 }
695 
696 /// Return a function-local symbol to represent the PIC base.
698  const DataLayout &DL = getDataLayout();
699  return Ctx.getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
700  Twine(getFunctionNumber()) + "$pb");
701 }
702 
703 /// \name Exception Handling
704 /// \{
705 
708  unsigned N = LandingPads.size();
709  for (unsigned i = 0; i < N; ++i) {
710  LandingPadInfo &LP = LandingPads[i];
711  if (LP.LandingPadBlock == LandingPad)
712  return LP;
713  }
714 
715  LandingPads.push_back(LandingPadInfo(LandingPad));
716  return LandingPads[N];
717 }
718 
720  MCSymbol *BeginLabel, MCSymbol *EndLabel) {
721  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
722  LP.BeginLabels.push_back(BeginLabel);
723  LP.EndLabels.push_back(EndLabel);
724 }
725 
727  MCSymbol *LandingPadLabel = Ctx.createTempSymbol();
728  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
729  LP.LandingPadLabel = LandingPadLabel;
730 
731  const Instruction *FirstI = LandingPad->getBasicBlock()->getFirstNonPHI();
732  if (const auto *LPI = dyn_cast<LandingPadInst>(FirstI)) {
733  if (const auto *PF =
734  dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts()))
735  getMMI().addPersonality(PF);
736 
737  if (LPI->isCleanup())
738  addCleanup(LandingPad);
739 
740  // FIXME: New EH - Add the clauses in reverse order. This isn't 100%
741  // correct, but we need to do it this way because of how the DWARF EH
742  // emitter processes the clauses.
743  for (unsigned I = LPI->getNumClauses(); I != 0; --I) {
744  Value *Val = LPI->getClause(I - 1);
745  if (LPI->isCatch(I - 1)) {
746  addCatchTypeInfo(LandingPad,
747  dyn_cast<GlobalValue>(Val->stripPointerCasts()));
748  } else {
749  // Add filters in a list.
750  auto *CVal = cast<Constant>(Val);
752  for (const Use &U : CVal->operands())
753  FilterList.push_back(cast<GlobalValue>(U->stripPointerCasts()));
754 
755  addFilterTypeInfo(LandingPad, FilterList);
756  }
757  }
758 
759  } else if (const auto *CPI = dyn_cast<CatchPadInst>(FirstI)) {
760  for (unsigned I = CPI->getNumArgOperands(); I != 0; --I) {
761  Value *TypeInfo = CPI->getArgOperand(I - 1)->stripPointerCasts();
762  addCatchTypeInfo(LandingPad, dyn_cast<GlobalValue>(TypeInfo));
763  }
764 
765  } else {
766  assert(isa<CleanupPadInst>(FirstI) && "Invalid landingpad!");
767  }
768 
769  return LandingPadLabel;
770 }
771 
774  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
775  for (unsigned N = TyInfo.size(); N; --N)
776  LP.TypeIds.push_back(getTypeIDFor(TyInfo[N - 1]));
777 }
778 
781  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
782  std::vector<unsigned> IdsInFilter(TyInfo.size());
783  for (unsigned I = 0, E = TyInfo.size(); I != E; ++I)
784  IdsInFilter[I] = getTypeIDFor(TyInfo[I]);
785  LP.TypeIds.push_back(getFilterIDFor(IdsInFilter));
786 }
787 
789  bool TidyIfNoBeginLabels) {
790  for (unsigned i = 0; i != LandingPads.size(); ) {
791  LandingPadInfo &LandingPad = LandingPads[i];
792  if (LandingPad.LandingPadLabel &&
793  !LandingPad.LandingPadLabel->isDefined() &&
794  (!LPMap || (*LPMap)[LandingPad.LandingPadLabel] == 0))
795  LandingPad.LandingPadLabel = nullptr;
796 
797  // Special case: we *should* emit LPs with null LP MBB. This indicates
798  // "nounwind" case.
799  if (!LandingPad.LandingPadLabel && LandingPad.LandingPadBlock) {
800  LandingPads.erase(LandingPads.begin() + i);
801  continue;
802  }
803 
804  if (TidyIfNoBeginLabels) {
805  for (unsigned j = 0, e = LandingPads[i].BeginLabels.size(); j != e; ++j) {
806  MCSymbol *BeginLabel = LandingPad.BeginLabels[j];
807  MCSymbol *EndLabel = LandingPad.EndLabels[j];
808  if ((BeginLabel->isDefined() || (LPMap && (*LPMap)[BeginLabel] != 0)) &&
809  (EndLabel->isDefined() || (LPMap && (*LPMap)[EndLabel] != 0)))
810  continue;
811 
812  LandingPad.BeginLabels.erase(LandingPad.BeginLabels.begin() + j);
813  LandingPad.EndLabels.erase(LandingPad.EndLabels.begin() + j);
814  --j;
815  --e;
816  }
817 
818  // Remove landing pads with no try-ranges.
819  if (LandingPads[i].BeginLabels.empty()) {
820  LandingPads.erase(LandingPads.begin() + i);
821  continue;
822  }
823  }
824 
825  // If there is no landing pad, ensure that the list of typeids is empty.
826  // If the only typeid is a cleanup, this is the same as having no typeids.
827  if (!LandingPad.LandingPadBlock ||
828  (LandingPad.TypeIds.size() == 1 && !LandingPad.TypeIds[0]))
829  LandingPad.TypeIds.clear();
830  ++i;
831  }
832 }
833 
835  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
836  LP.TypeIds.push_back(0);
837 }
838 
840  const Function *Filter,
841  const BlockAddress *RecoverBA) {
842  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
843  SEHHandler Handler;
844  Handler.FilterOrFinally = Filter;
845  Handler.RecoverBA = RecoverBA;
846  LP.SEHHandlers.push_back(Handler);
847 }
848 
850  const Function *Cleanup) {
851  LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
852  SEHHandler Handler;
853  Handler.FilterOrFinally = Cleanup;
854  Handler.RecoverBA = nullptr;
855  LP.SEHHandlers.push_back(Handler);
856 }
857 
859  ArrayRef<unsigned> Sites) {
860  LPadToCallSiteMap[Sym].append(Sites.begin(), Sites.end());
861 }
862 
864  for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i)
865  if (TypeInfos[i] == TI) return i + 1;
866 
867  TypeInfos.push_back(TI);
868  return TypeInfos.size();
869 }
870 
871 int MachineFunction::getFilterIDFor(std::vector<unsigned> &TyIds) {
872  // If the new filter coincides with the tail of an existing filter, then
873  // re-use the existing filter. Folding filters more than this requires
874  // re-ordering filters and/or their elements - probably not worth it.
875  for (unsigned i : FilterEnds) {
876  unsigned j = TyIds.size();
877 
878  while (i && j)
879  if (FilterIds[--i] != TyIds[--j])
880  goto try_next;
881 
882  if (!j)
883  // The new filter coincides with range [i, end) of the existing filter.
884  return -(1 + i);
885 
886 try_next:;
887  }
888 
889  // Add the new filter.
890  int FilterID = -(1 + FilterIds.size());
891  FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
892  llvm::append_range(FilterIds, TyIds);
893  FilterEnds.push_back(FilterIds.size());
894  FilterIds.push_back(0); // terminator
895  return FilterID;
896 }
897 
899 MachineFunction::getCallSiteInfo(const MachineInstr *MI) {
900  assert(MI->isCandidateForCallSiteEntry() &&
901  "Call site info refers only to call (MI) candidates");
902 
903  if (!Target.Options.EmitCallSiteInfo)
904  return CallSitesInfo.end();
905  return CallSitesInfo.find(MI);
906 }
907 
908 /// Return the call machine instruction or find a call within bundle.
909 static const MachineInstr *getCallInstr(const MachineInstr *MI) {
910  if (!MI->isBundle())
911  return MI;
912 
913  for (auto &BMI : make_range(getBundleStart(MI->getIterator()),
914  getBundleEnd(MI->getIterator())))
915  if (BMI.isCandidateForCallSiteEntry())
916  return &BMI;
917 
918  llvm_unreachable("Unexpected bundle without a call site candidate");
919 }
920 
922  assert(MI->shouldUpdateCallSiteInfo() &&
923  "Call site info refers only to call (MI) candidates or "
924  "candidates inside bundles");
925 
926  const MachineInstr *CallMI = getCallInstr(MI);
927  CallSiteInfoMap::iterator CSIt = getCallSiteInfo(CallMI);
928  if (CSIt == CallSitesInfo.end())
929  return;
930  CallSitesInfo.erase(CSIt);
931 }
932 
934  const MachineInstr *New) {
936  "Call site info refers only to call (MI) candidates or "
937  "candidates inside bundles");
938 
939  if (!New->isCandidateForCallSiteEntry())
940  return eraseCallSiteInfo(Old);
941 
942  const MachineInstr *OldCallMI = getCallInstr(Old);
943  CallSiteInfoMap::iterator CSIt = getCallSiteInfo(OldCallMI);
944  if (CSIt == CallSitesInfo.end())
945  return;
946 
947  CallSiteInfo CSInfo = CSIt->second;
948  CallSitesInfo[New] = CSInfo;
949 }
950 
952  const MachineInstr *New) {
954  "Call site info refers only to call (MI) candidates or "
955  "candidates inside bundles");
956 
957  if (!New->isCandidateForCallSiteEntry())
958  return eraseCallSiteInfo(Old);
959 
960  const MachineInstr *OldCallMI = getCallInstr(Old);
961  CallSiteInfoMap::iterator CSIt = getCallSiteInfo(OldCallMI);
962  if (CSIt == CallSitesInfo.end())
963  return;
964 
965  CallSiteInfo CSInfo = std::move(CSIt->second);
966  CallSitesInfo.erase(CSIt);
967  CallSitesInfo[New] = CSInfo;
968 }
969 
972 }
973 
976  unsigned Subreg) {
977  // Catch any accidental self-loops.
978  assert(A.first != B.first);
979  // Don't allow any substitutions _from_ the memory operand number.
980  assert(A.second != DebugOperandMemNumber);
981 
982  DebugValueSubstitutions.push_back({A, B, Subreg});
983 }
984 
986  MachineInstr &New,
987  unsigned MaxOperand) {
988  // If the Old instruction wasn't tracked at all, there is no work to do.
989  unsigned OldInstrNum = Old.peekDebugInstrNum();
990  if (!OldInstrNum)
991  return;
992 
993  // Iterate over all operands looking for defs to create substitutions for.
994  // Avoid creating new instr numbers unless we create a new substitution.
995  // While this has no functional effect, it risks confusing someone reading
996  // MIR output.
997  // Examine all the operands, or the first N specified by the caller.
998  MaxOperand = std::min(MaxOperand, Old.getNumOperands());
999  for (unsigned int I = 0; I < MaxOperand; ++I) {
1000  const auto &OldMO = Old.getOperand(I);
1001  auto &NewMO = New.getOperand(I);
1002  (void)NewMO;
1003 
1004  if (!OldMO.isReg() || !OldMO.isDef())
1005  continue;
1006  assert(NewMO.isDef());
1007 
1008  unsigned NewInstrNum = New.getDebugInstrNum();
1009  makeDebugValueSubstitution(std::make_pair(OldInstrNum, I),
1010  std::make_pair(NewInstrNum, I));
1011  }
1012 }
1013 
1016  MachineRegisterInfo &MRI = getRegInfo();
1018  const TargetInstrInfo &TII = *getSubtarget().getInstrInfo();
1019 
1020  // Chase the value read by a copy-like instruction back to the instruction
1021  // that ultimately _defines_ that value. This may pass:
1022  // * Through multiple intermediate copies, including subregister moves /
1023  // copies,
1024  // * Copies from physical registers that must then be traced back to the
1025  // defining instruction,
1026  // * Or, physical registers may be live-in to (only) the entry block, which
1027  // requires a DBG_PHI to be created.
1028  // We can pursue this problem in that order: trace back through copies,
1029  // optionally through a physical register, to a defining instruction. We
1030  // should never move from physreg to vreg. As we're still in SSA form, no need
1031  // to worry about partial definitions of registers.
1032 
1033  // Helper lambda to interpret a copy-like instruction. Takes instruction,
1034  // returns the register read and any subregister identifying which part is
1035  // read.
1036  auto GetRegAndSubreg =
1037  [&](const MachineInstr &Cpy) -> std::pair<Register, unsigned> {
1038  Register NewReg, OldReg;
1039  unsigned SubReg;
1040  if (Cpy.isCopy()) {
1041  OldReg = Cpy.getOperand(0).getReg();
1042  NewReg = Cpy.getOperand(1).getReg();
1043  SubReg = Cpy.getOperand(1).getSubReg();
1044  } else if (Cpy.isSubregToReg()) {
1045  OldReg = Cpy.getOperand(0).getReg();
1046  NewReg = Cpy.getOperand(2).getReg();
1047  SubReg = Cpy.getOperand(3).getImm();
1048  } else {
1049  auto CopyDetails = *TII.isCopyInstr(Cpy);
1050  const MachineOperand &Src = *CopyDetails.Source;
1051  const MachineOperand &Dest = *CopyDetails.Destination;
1052  OldReg = Dest.getReg();
1053  NewReg = Src.getReg();
1054  SubReg = Src.getSubReg();
1055  }
1056 
1057  return {NewReg, SubReg};
1058  };
1059 
1060  // First seek either the defining instruction, or a copy from a physreg.
1061  // During search, the current state is the current copy instruction, and which
1062  // register we've read. Accumulate qualifying subregisters into SubregsSeen;
1063  // deal with those later.
1064  auto State = GetRegAndSubreg(MI);
1065  auto CurInst = MI.getIterator();
1066  SmallVector<unsigned, 4> SubregsSeen;
1067  while (true) {
1068  // If we've found a copy from a physreg, first portion of search is over.
1069  if (!State.first.isVirtual())
1070  break;
1071 
1072  // Record any subregister qualifier.
1073  if (State.second)
1074  SubregsSeen.push_back(State.second);
1075 
1076  assert(MRI.hasOneDef(State.first));
1077  MachineInstr &Inst = *MRI.def_begin(State.first)->getParent();
1078  CurInst = Inst.getIterator();
1079 
1080  // Any non-copy instruction is the defining instruction we're seeking.
1081  if (!Inst.isCopyLike() && !TII.isCopyInstr(Inst))
1082  break;
1083  State = GetRegAndSubreg(Inst);
1084  };
1085 
1086  // Helper lambda to apply additional subregister substitutions to a known
1087  // instruction/operand pair. Adds new (fake) substitutions so that we can
1088  // record the subregister. FIXME: this isn't very space efficient if multiple
1089  // values are tracked back through the same copies; cache something later.
1090  auto ApplySubregisters =
1092  for (unsigned Subreg : reverse(SubregsSeen)) {
1093  // Fetch a new instruction number, not attached to an actual instruction.
1094  unsigned NewInstrNumber = getNewDebugInstrNum();
1095  // Add a substitution from the "new" number to the known one, with a
1096  // qualifying subreg.
1097  makeDebugValueSubstitution({NewInstrNumber, 0}, P, Subreg);
1098  // Return the new number; to find the underlying value, consumers need to
1099  // deal with the qualifying subreg.
1100  P = {NewInstrNumber, 0};
1101  }
1102  return P;
1103  };
1104 
1105  // If we managed to find the defining instruction after COPYs, return an
1106  // instruction / operand pair after adding subregister qualifiers.
1107  if (State.first.isVirtual()) {
1108  // Virtual register def -- we can just look up where this happens.
1109  MachineInstr *Inst = MRI.def_begin(State.first)->getParent();
1110  for (auto &MO : Inst->operands()) {
1111  if (!MO.isReg() || !MO.isDef() || MO.getReg() != State.first)
1112  continue;
1113  return ApplySubregisters(
1114  {Inst->getDebugInstrNum(), Inst->getOperandNo(&MO)});
1115  }
1116 
1117  llvm_unreachable("Vreg def with no corresponding operand?");
1118  }
1119 
1120  // Our search ended in a copy from a physreg: walk back up the function
1121  // looking for whatever defines the physreg.
1122  assert(CurInst->isCopyLike() || TII.isCopyInstr(*CurInst));
1123  State = GetRegAndSubreg(*CurInst);
1124  Register RegToSeek = State.first;
1125 
1126  auto RMII = CurInst->getReverseIterator();
1127  auto PrevInstrs = make_range(RMII, CurInst->getParent()->instr_rend());
1128  for (auto &ToExamine : PrevInstrs) {
1129  for (auto &MO : ToExamine.operands()) {
1130  // Test for operand that defines something aliasing RegToSeek.
1131  if (!MO.isReg() || !MO.isDef() ||
1132  !TRI.regsOverlap(RegToSeek, MO.getReg()))
1133  continue;
1134 
1135  return ApplySubregisters(
1136  {ToExamine.getDebugInstrNum(), ToExamine.getOperandNo(&MO)});
1137  }
1138  }
1139 
1140  MachineBasicBlock &InsertBB = *CurInst->getParent();
1141 
1142  // We reached the start of the block before finding a defining instruction.
1143  // It could be from a constant register, otherwise it must be an argument.
1144  if (TRI.isConstantPhysReg(State.first)) {
1145  // We can produce a DBG_PHI that identifies the constant physreg. Doesn't
1146  // matter where we put it, as it's constant valued.
1147  assert(CurInst->isCopy());
1148  } else if (State.first == TRI.getFrameRegister(*this)) {
1149  // LLVM IR is allowed to read the framepointer by calling a
1150  // llvm.frameaddress.* intrinsic. We can support this by emitting a
1151  // DBG_PHI $fp. This isn't ideal, because it extends the behaviours /
1152  // position that DBG_PHIs appear at, limiting what can be done later.
1153  // TODO: see if there's a better way of expressing these variable
1154  // locations.
1155  ;
1156  } else {
1157  // Assert that this is the entry block, or an EH pad. If it isn't, then
1158  // there is some code construct we don't recognise that deals with physregs
1159  // across blocks.
1160  assert(!State.first.isVirtual());
1161  assert(&*InsertBB.getParent()->begin() == &InsertBB || InsertBB.isEHPad());
1162  }
1163 
1164  // Create DBG_PHI for specified physreg.
1165  auto Builder = BuildMI(InsertBB, InsertBB.getFirstNonPHI(), DebugLoc(),
1166  TII.get(TargetOpcode::DBG_PHI));
1167  Builder.addReg(State.first);
1168  unsigned NewNum = getNewDebugInstrNum();
1169  Builder.addImm(NewNum);
1170  return ApplySubregisters({NewNum, 0u});
1171 }
1172 
1174  auto *TII = getSubtarget().getInstrInfo();
1175 
1176  auto MakeUndefDbgValue = [&](MachineInstr &MI) {
1177  const MCInstrDesc &RefII = TII->get(TargetOpcode::DBG_VALUE);
1178  MI.setDesc(RefII);
1179  MI.getOperand(0).setReg(0);
1180  MI.getOperand(1).ChangeToRegister(0, false);
1181  };
1182 
1183  if (!useDebugInstrRef())
1184  return;
1185 
1186  for (auto &MBB : *this) {
1187  for (auto &MI : MBB) {
1188  if (!MI.isDebugRef() || !MI.getOperand(0).isReg())
1189  continue;
1190 
1191  Register Reg = MI.getOperand(0).getReg();
1192 
1193  // Some vregs can be deleted as redundant in the meantime. Mark those
1194  // as DBG_VALUE $noreg. Additionally, some normal instructions are
1195  // quickly deleted, leaving dangling references to vregs with no def.
1196  if (Reg == 0 || !RegInfo->hasOneDef(Reg)) {
1197  MakeUndefDbgValue(MI);
1198  continue;
1199  }
1200 
1201  assert(Reg.isVirtual());
1202  MachineInstr &DefMI = *RegInfo->def_instr_begin(Reg);
1203 
1204  // If we've found a copy-like instruction, follow it back to the
1205  // instruction that defines the source value, see salvageCopySSA docs
1206  // for why this is important.
1207  if (DefMI.isCopyLike() || TII->isCopyInstr(DefMI)) {
1208  auto Result = salvageCopySSA(DefMI);
1209  MI.getOperand(0).ChangeToImmediate(Result.first);
1210  MI.getOperand(1).setImm(Result.second);
1211  } else {
1212  // Otherwise, identify the operand number that the VReg refers to.
1213  unsigned OperandIdx = 0;
1214  for (const auto &MO : DefMI.operands()) {
1215  if (MO.isReg() && MO.isDef() && MO.getReg() == Reg)
1216  break;
1217  ++OperandIdx;
1218  }
1219  assert(OperandIdx < DefMI.getNumOperands());
1220 
1221  // Morph this instr ref to point at the given instruction and operand.
1222  unsigned ID = DefMI.getDebugInstrNum();
1223  MI.getOperand(0).ChangeToImmediate(ID);
1224  MI.getOperand(1).setImm(OperandIdx);
1225  }
1226  }
1227  }
1228 }
1229 
1231  // Disable instr-ref at -O0: it's very slow (in compile time). We can still
1232  // have optimized code inlined into this unoptimized code, however with
1233  // fewer and less aggressive optimizations happening, coverage and accuracy
1234  // should not suffer.
1235  if (getTarget().getOptLevel() == CodeGenOpt::None)
1236  return false;
1237 
1238  // Don't use instr-ref if this function is marked optnone.
1239  if (F.hasFnAttribute(Attribute::OptimizeNone))
1240  return false;
1241 
1242  if (getTarget().Options.ValueTrackingVariableLocations)
1243  return true;
1244 
1245  return false;
1246 }
1247 
1248 // Use one million as a high / reserved number.
1249 const unsigned MachineFunction::DebugOperandMemNumber = 1000000;
1250 
1251 /// \}
1252 
1253 //===----------------------------------------------------------------------===//
1254 // MachineJumpTableInfo implementation
1255 //===----------------------------------------------------------------------===//
1256 
1257 /// Return the size of each entry in the jump table.
1259  // The size of a jump table entry is 4 bytes unless the entry is just the
1260  // address of a block, in which case it is the pointer size.
1261  switch (getEntryKind()) {
1263  return TD.getPointerSize();
1265  return 8;
1269  return 4;
1271  return 0;
1272  }
1273  llvm_unreachable("Unknown jump table encoding!");
1274 }
1275 
1276 /// Return the alignment of each entry in the jump table.
1278  // The alignment of a jump table entry is the alignment of int32 unless the
1279  // entry is just the address of a block, in which case it is the pointer
1280  // alignment.
1281  switch (getEntryKind()) {
1283  return TD.getPointerABIAlignment(0).value();
1285  return TD.getABIIntegerTypeAlignment(64).value();
1289  return TD.getABIIntegerTypeAlignment(32).value();
1291  return 1;
1292  }
1293  llvm_unreachable("Unknown jump table encoding!");
1294 }
1295 
1296 /// Create a new jump table entry in the jump table info.
1298  const std::vector<MachineBasicBlock*> &DestBBs) {
1299  assert(!DestBBs.empty() && "Cannot create an empty jump table!");
1300  JumpTables.push_back(MachineJumpTableEntry(DestBBs));
1301  return JumpTables.size()-1;
1302 }
1303 
1304 /// If Old is the target of any jump tables, update the jump tables to branch
1305 /// to New instead.
1307  MachineBasicBlock *New) {
1308  assert(Old != New && "Not making a change?");
1309  bool MadeChange = false;
1310  for (size_t i = 0, e = JumpTables.size(); i != e; ++i)
1311  ReplaceMBBInJumpTable(i, Old, New);
1312  return MadeChange;
1313 }
1314 
1315 /// If MBB is present in any jump tables, remove it.
1317  bool MadeChange = false;
1318  for (MachineJumpTableEntry &JTE : JumpTables) {
1319  auto removeBeginItr = std::remove(JTE.MBBs.begin(), JTE.MBBs.end(), MBB);
1320  MadeChange |= (removeBeginItr != JTE.MBBs.end());
1321  JTE.MBBs.erase(removeBeginItr, JTE.MBBs.end());
1322  }
1323  return MadeChange;
1324 }
1325 
1326 /// If Old is a target of the jump tables, update the jump table to branch to
1327 /// New instead.
1329  MachineBasicBlock *Old,
1330  MachineBasicBlock *New) {
1331  assert(Old != New && "Not making a change?");
1332  bool MadeChange = false;
1333  MachineJumpTableEntry &JTE = JumpTables[Idx];
1334  for (MachineBasicBlock *&MBB : JTE.MBBs)
1335  if (MBB == Old) {
1336  MBB = New;
1337  MadeChange = true;
1338  }
1339  return MadeChange;
1340 }
1341 
1343  if (JumpTables.empty()) return;
1344 
1345  OS << "Jump Tables:\n";
1346 
1347  for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) {
1348  OS << printJumpTableEntryReference(i) << ':';
1349  for (const MachineBasicBlock *MBB : JumpTables[i].MBBs)
1350  OS << ' ' << printMBBReference(*MBB);
1351  if (i != e)
1352  OS << '\n';
1353  }
1354 
1355  OS << '\n';
1356 }
1357 
1358 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1360 #endif
1361 
1363  return Printable([Idx](raw_ostream &OS) { OS << "%jump-table." << Idx; });
1364 }
1365 
1366 //===----------------------------------------------------------------------===//
1367 // MachineConstantPool implementation
1368 //===----------------------------------------------------------------------===//
1369 
1370 void MachineConstantPoolValue::anchor() {}
1371 
1373  return DL.getTypeAllocSize(Ty);
1374 }
1375 
1378  return Val.MachineCPVal->getSizeInBytes(DL);
1379  return DL.getTypeAllocSize(Val.ConstVal->getType());
1380 }
1381 
1384  return true;
1385  return Val.ConstVal->needsDynamicRelocation();
1386 }
1387 
1390  if (needsRelocation())
1392  switch (getSizeInBytes(*DL)) {
1393  case 4:
1395  case 8:
1397  case 16:
1399  case 32:
1401  default:
1402  return SectionKind::getReadOnly();
1403  }
1404 }
1405 
1407  // A constant may be a member of both Constants and MachineCPVsSharingEntries,
1408  // so keep track of which we've deleted to avoid double deletions.
1410  for (const MachineConstantPoolEntry &C : Constants)
1411  if (C.isMachineConstantPoolEntry()) {
1412  Deleted.insert(C.Val.MachineCPVal);
1413  delete C.Val.MachineCPVal;
1414  }
1415  for (MachineConstantPoolValue *CPV : MachineCPVsSharingEntries) {
1416  if (Deleted.count(CPV) == 0)
1417  delete CPV;
1418  }
1419 }
1420 
1421 /// Test whether the given two constants can be allocated the same constant pool
1422 /// entry.
1423 static bool CanShareConstantPoolEntry(const Constant *A, const Constant *B,
1424  const DataLayout &DL) {
1425  // Handle the trivial case quickly.
1426  if (A == B) return true;
1427 
1428  // If they have the same type but weren't the same constant, quickly
1429  // reject them.
1430  if (A->getType() == B->getType()) return false;
1431 
1432  // We can't handle structs or arrays.
1433  if (isa<StructType>(A->getType()) || isa<ArrayType>(A->getType()) ||
1434  isa<StructType>(B->getType()) || isa<ArrayType>(B->getType()))
1435  return false;
1436 
1437  // For now, only support constants with the same size.
1438  uint64_t StoreSize = DL.getTypeStoreSize(A->getType());
1439  if (StoreSize != DL.getTypeStoreSize(B->getType()) || StoreSize > 128)
1440  return false;
1441 
1442  Type *IntTy = IntegerType::get(A->getContext(), StoreSize*8);
1443 
1444  // Try constant folding a bitcast of both instructions to an integer. If we
1445  // get two identical ConstantInt's, then we are good to share them. We use
1446  // the constant folding APIs to do this so that we get the benefit of
1447  // DataLayout.
1448  if (isa<PointerType>(A->getType()))
1449  A = ConstantFoldCastOperand(Instruction::PtrToInt,
1450  const_cast<Constant *>(A), IntTy, DL);
1451  else if (A->getType() != IntTy)
1452  A = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(A),
1453  IntTy, DL);
1454  if (isa<PointerType>(B->getType()))
1455  B = ConstantFoldCastOperand(Instruction::PtrToInt,
1456  const_cast<Constant *>(B), IntTy, DL);
1457  else if (B->getType() != IntTy)
1458  B = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(B),
1459  IntTy, DL);
1460 
1461  return A == B;
1462 }
1463 
1464 /// Create a new entry in the constant pool or return an existing one.
1465 /// User must specify the log2 of the minimum required alignment for the object.
1467  Align Alignment) {
1468  if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1469 
1470  // Check to see if we already have this constant.
1471  //
1472  // FIXME, this could be made much more efficient for large constant pools.
1473  for (unsigned i = 0, e = Constants.size(); i != e; ++i)
1474  if (!Constants[i].isMachineConstantPoolEntry() &&
1475  CanShareConstantPoolEntry(Constants[i].Val.ConstVal, C, DL)) {
1476  if (Constants[i].getAlign() < Alignment)
1477  Constants[i].Alignment = Alignment;
1478  return i;
1479  }
1480 
1481  Constants.push_back(MachineConstantPoolEntry(C, Alignment));
1482  return Constants.size()-1;
1483 }
1484 
1486  Align Alignment) {
1487  if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1488 
1489  // Check to see if we already have this constant.
1490  //
1491  // FIXME, this could be made much more efficient for large constant pools.
1492  int Idx = V->getExistingMachineCPValue(this, Alignment);
1493  if (Idx != -1) {
1494  MachineCPVsSharingEntries.insert(V);
1495  return (unsigned)Idx;
1496  }
1497 
1498  Constants.push_back(MachineConstantPoolEntry(V, Alignment));
1499  return Constants.size()-1;
1500 }
1501 
1503  if (Constants.empty()) return;
1504 
1505  OS << "Constant Pool:\n";
1506  for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
1507  OS << " cp#" << i << ": ";
1508  if (Constants[i].isMachineConstantPoolEntry())
1509  Constants[i].Val.MachineCPVal->print(OS);
1510  else
1511  Constants[i].Val.ConstVal->printAsOperand(OS, /*PrintType=*/false);
1512  OS << ", align=" << Constants[i].getAlign().value();
1513  OS << "\n";
1514  }
1515 }
1516 
1517 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1519 #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:607
llvm::MachineInstr::getDebugInstrNum
unsigned getDebugInstrNum()
Fetch the instruction number of this MachineInstr.
Definition: MachineInstr.cpp:2353
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:1466
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:1316
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:1297
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:463
llvm::MachineFunction::allocateRegMask
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
Definition: MachineFunction.cpp:525
llvm::MachineFunctionProperties::print
void print(raw_ostream &OS) const
Print the MachineFunctionProperties in human-readable form.
Definition: MachineFunction.cpp:113
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:161
llvm::MachineFunction::getContext
MCContext & getContext() const
Definition: MachineFunction.h:593
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:338
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:1230
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:1786
llvm::MachineFunction::end
iterator end()
Definition: MachineFunction.h:825
llvm::LandingPadInfo::LandingPadLabel
MCSymbol * LandingPadLabel
Definition: MachineFunction.h:234
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:434
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:233
llvm::MachineFunction::copyCallSiteInfo
void copyCallSiteInfo(const MachineInstr *Old, const MachineInstr *New)
Copy the call site info from Old to \ New.
Definition: MachineFunction.cpp:933
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:271
llvm::MachineFunction::getFunctionNumber
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
Definition: MachineFunction.h:616
llvm::MachineInstr::bundleWithPred
void bundleWithPred()
Bundle this instruction with its predecessor.
Definition: MachineInstr.cpp:742
llvm::MachineFunction::back
const MachineBasicBlock & back() const
Definition: MachineFunction.h:837
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:951
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::CreateMachineInstr
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, DebugLoc DL, bool NoImplicit=false)
CreateMachineInstr - Allocate a new MachineInstr.
Definition: MachineFunction.cpp:352
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:1651
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:858
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:134
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:839
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:851
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:682
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:222
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:805
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:1258
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:1306
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:1359
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:985
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:835
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition: MachineFunction.h:651
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:232
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:279
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:1014
llvm::MachineFunction::addCatchTypeInfo
void addCatchTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the catch typeinfo for a landing pad.
Definition: MachineFunction.cpp:772
MCContext.h
llvm::TargetLoweringBase::getMinFunctionAlignment
Align getMinFunctionAlignment() const
Return the minimum function alignment.
Definition: TargetLowering.h:1783
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:397
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:732
DenseSet.h
llvm::LandingPadInfo::TypeIds
std::vector< int > TypeIds
Definition: MachineFunction.h:235
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:970
llvm::MachineFunction::size
unsigned size() const
Definition: MachineFunction.h:833
llvm::MachineConstantPoolEntry::getSectionKind
SectionKind getSectionKind(const DataLayout *DL) const
Definition: MachineFunction.cpp:1389
llvm::MachineFunction::getTypeIDFor
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
Definition: MachineFunction.cpp:863
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:180
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:703
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:635
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:284
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:823
llvm::SlotIndexes
SlotIndexes pass.
Definition: SlotIndexes.h:314
llvm::MachineConstantPool::~MachineConstantPool
~MachineConstantPool()
Definition: MachineFunction.cpp:1406
llvm::MachineFunction::addFilterTypeInfo
void addFilterTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the filter typeinfo for a landing pad.
Definition: MachineFunction.cpp:779
llvm::printJumpTableEntryReference
Printable printJumpTableEntryReference(unsigned Idx)
Prints a jump table entry reference.
Definition: MachineFunction.cpp:1362
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:1423
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:788
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:719
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:909
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:645
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::DOTGraphTraits< const MachineFunction * >::getGraphName
static std::string getGraphName(const MachineFunction *F)
Definition: MachineFunction.cpp:603
llvm::MachineFunction::getMMI
MachineModuleInfo & getMMI() const
Definition: MachineFunction.h:592
llvm::MachineFunction::deallocateOperandArray
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
Dellocate an array of MachineOperands and recycle the memory.
Definition: MachineFunction.h:986
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:641
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:1372
llvm::LandingPadInfo::BeginLabels
SmallVector< MCSymbol *, 1 > BeginLabels
Definition: MachineFunction.h:231
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:511
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:849
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:362
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:540
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:418
llvm::MachineFunction::finalizeDebugInstrRefs
void finalizeDebugInstrRefs()
Finalise any partially emitted debug instructions.
Definition: MachineFunction.cpp:1173
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:545
llvm::TargetMachine::Options
TargetOptions Options
Definition: TargetMachine.h:121
llvm::MachineFunction::~MachineFunction
~MachineFunction()
Definition: MachineFunction.cpp:214
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:230
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:974
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:241
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:1382
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:657
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:425
llvm::MachineFunction::allocateShuffleMask
ArrayRef< int > allocateShuffleMask(ArrayRef< int > Mask)
Definition: MachineFunction.cpp:533
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:1797
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:1342
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:1328
llvm::MachineFunctionProperties::reset
MachineFunctionProperties & reset(Property P)
Definition: MachineFunction.h:185
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:456
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:367
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::MachineConstantPoolEntry::Val
union llvm::MachineConstantPoolEntry::@183 Val
The constant itself.
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:871
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:607
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:591
llvm::MachineInstr::isCopyLike
bool isCopyLike() const
Return true if the instruction behaves like a copy.
Definition: MachineInstr.h:1299
llvm::MachineFunction::getTarget
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Definition: MachineFunction.h:637
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:1311
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:549
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:141
isSimple
static bool isSimple(Instruction *I)
Definition: SLPVectorizer.cpp:593
llvm::Function::getPersonalityFn
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Definition: Function.cpp:1844
SectionKind.h
llvm::MachineFunction::addCleanup
void addCleanup(MachineBasicBlock *LandingPad)
Add a cleanup action for a landing pad.
Definition: MachineFunction.cpp:834
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:1502
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:697
llvm::SEHHandler
Definition: MachineFunction.h:220
llvm::MachineFunction::addFrameInst
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
Definition: MachineFunction.cpp:289
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:495
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:264
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:229
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:518
llvm::MachineJumpTableInfo::getEntryAlignment
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
Definition: MachineFunction.cpp:1277
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:556
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:726
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:1518
llvm::MachineFunction::empty
bool empty() const
Definition: MachineFunction.h:834
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:921
llvm::MachineFunction::VariableDbgInfos
VariableDbgInfoMapTy VariableDbgInfos
Definition: MachineFunction.h:451
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:225
llvm::DOTGraphTraits< const MachineFunction * >::DOTGraphTraits
DOTGraphTraits(bool isSimple=false)
Definition: MachineFunction.cpp:601
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:298
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:707
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:1376
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