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