LLVM  16.0.0git
Function.cpp
Go to the documentation of this file.
1 //===- Function.cpp - Implement the Global object classes -----------------===//
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 // This file implements the Function class for the IR library.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/IR/Function.h"
15 #include "llvm/ADT/ArrayRef.h"
16 #include "llvm/ADT/DenseSet.h"
17 #include "llvm/ADT/None.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/SmallString.h"
20 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/ADT/StringExtras.h"
22 #include "llvm/ADT/StringRef.h"
24 #include "llvm/IR/Argument.h"
25 #include "llvm/IR/Attributes.h"
26 #include "llvm/IR/BasicBlock.h"
27 #include "llvm/IR/Constant.h"
28 #include "llvm/IR/Constants.h"
29 #include "llvm/IR/DerivedTypes.h"
30 #include "llvm/IR/GlobalValue.h"
31 #include "llvm/IR/InstIterator.h"
32 #include "llvm/IR/Instruction.h"
33 #include "llvm/IR/IntrinsicInst.h"
34 #include "llvm/IR/Intrinsics.h"
35 #include "llvm/IR/IntrinsicsAArch64.h"
36 #include "llvm/IR/IntrinsicsAMDGPU.h"
37 #include "llvm/IR/IntrinsicsARM.h"
38 #include "llvm/IR/IntrinsicsBPF.h"
39 #include "llvm/IR/IntrinsicsDirectX.h"
40 #include "llvm/IR/IntrinsicsHexagon.h"
41 #include "llvm/IR/IntrinsicsMips.h"
42 #include "llvm/IR/IntrinsicsNVPTX.h"
43 #include "llvm/IR/IntrinsicsPowerPC.h"
44 #include "llvm/IR/IntrinsicsR600.h"
45 #include "llvm/IR/IntrinsicsRISCV.h"
46 #include "llvm/IR/IntrinsicsS390.h"
47 #include "llvm/IR/IntrinsicsVE.h"
48 #include "llvm/IR/IntrinsicsWebAssembly.h"
49 #include "llvm/IR/IntrinsicsX86.h"
50 #include "llvm/IR/IntrinsicsXCore.h"
51 #include "llvm/IR/LLVMContext.h"
52 #include "llvm/IR/MDBuilder.h"
53 #include "llvm/IR/Metadata.h"
54 #include "llvm/IR/Module.h"
55 #include "llvm/IR/Operator.h"
57 #include "llvm/IR/Type.h"
58 #include "llvm/IR/Use.h"
59 #include "llvm/IR/User.h"
60 #include "llvm/IR/Value.h"
62 #include "llvm/Support/Casting.h"
64 #include "llvm/Support/Compiler.h"
66 #include <cassert>
67 #include <cstddef>
68 #include <cstdint>
69 #include <cstring>
70 #include <string>
71 
72 using namespace llvm;
74 
75 // Explicit instantiations of SymbolTableListTraits since some of the methods
76 // are not in the public header file...
78 
80  "non-global-value-max-name-size", cl::Hidden, cl::init(1024),
81  cl::desc("Maximum size for the name of non-global values."));
82 
83 //===----------------------------------------------------------------------===//
84 // Argument Implementation
85 //===----------------------------------------------------------------------===//
86 
87 Argument::Argument(Type *Ty, const Twine &Name, Function *Par, unsigned ArgNo)
88  : Value(Ty, Value::ArgumentVal), Parent(Par), ArgNo(ArgNo) {
89  setName(Name);
90 }
91 
92 void Argument::setParent(Function *parent) {
93  Parent = parent;
94 }
95 
96 bool Argument::hasNonNullAttr(bool AllowUndefOrPoison) const {
97  if (!getType()->isPointerTy()) return false;
98  if (getParent()->hasParamAttribute(getArgNo(), Attribute::NonNull) &&
99  (AllowUndefOrPoison ||
100  getParent()->hasParamAttribute(getArgNo(), Attribute::NoUndef)))
101  return true;
102  else if (getDereferenceableBytes() > 0 &&
104  getType()->getPointerAddressSpace()))
105  return true;
106  return false;
107 }
108 
110  if (!getType()->isPointerTy()) return false;
111  return hasAttribute(Attribute::ByVal);
112 }
113 
115  if (!getType()->isPointerTy())
116  return false;
117  return hasAttribute(Attribute::ByRef);
118 }
119 
121  return getParent()->hasParamAttribute(getArgNo(), Attribute::SwiftSelf);
122 }
123 
125  return getParent()->hasParamAttribute(getArgNo(), Attribute::SwiftError);
126 }
127 
129  if (!getType()->isPointerTy()) return false;
130  return hasAttribute(Attribute::InAlloca);
131 }
132 
134  if (!getType()->isPointerTy())
135  return false;
136  return hasAttribute(Attribute::Preallocated);
137 }
138 
140  if (!getType()->isPointerTy()) return false;
142  return Attrs.hasParamAttr(getArgNo(), Attribute::ByVal) ||
143  Attrs.hasParamAttr(getArgNo(), Attribute::InAlloca) ||
144  Attrs.hasParamAttr(getArgNo(), Attribute::Preallocated);
145 }
146 
148  if (!getType()->isPointerTy())
149  return false;
151  return Attrs.hasParamAttr(getArgNo(), Attribute::ByVal) ||
152  Attrs.hasParamAttr(getArgNo(), Attribute::StructRet) ||
153  Attrs.hasParamAttr(getArgNo(), Attribute::InAlloca) ||
154  Attrs.hasParamAttr(getArgNo(), Attribute::Preallocated) ||
155  Attrs.hasParamAttr(getArgNo(), Attribute::ByRef);
156 }
157 
158 /// For a byval, sret, inalloca, or preallocated parameter, get the in-memory
159 /// parameter type.
161  // FIXME: All the type carrying attributes are mutually exclusive, so there
162  // should be a single query to get the stored type that handles any of them.
163  if (Type *ByValTy = ParamAttrs.getByValType())
164  return ByValTy;
165  if (Type *ByRefTy = ParamAttrs.getByRefType())
166  return ByRefTy;
167  if (Type *PreAllocTy = ParamAttrs.getPreallocatedType())
168  return PreAllocTy;
169  if (Type *InAllocaTy = ParamAttrs.getInAllocaType())
170  return InAllocaTy;
171  if (Type *SRetTy = ParamAttrs.getStructRetType())
172  return SRetTy;
173 
174  return nullptr;
175 }
176 
178  AttributeSet ParamAttrs =
180  if (Type *MemTy = getMemoryParamAllocType(ParamAttrs))
181  return DL.getTypeAllocSize(MemTy);
182  return 0;
183 }
184 
186  AttributeSet ParamAttrs =
188  return getMemoryParamAllocType(ParamAttrs);
189 }
190 
192  assert(getType()->isPointerTy() && "Only pointers have alignments");
193  return getParent()->getParamAlignment(getArgNo());
194 }
195 
197  assert(getType()->isPointerTy() && "Only pointers have alignments");
198  return getParent()->getParamAlign(getArgNo());
199 }
200 
203 }
204 
206  assert(getType()->isPointerTy() && "Only pointers have byval types");
207  return getParent()->getParamByValType(getArgNo());
208 }
209 
211  assert(getType()->isPointerTy() && "Only pointers have sret types");
213 }
214 
216  assert(getType()->isPointerTy() && "Only pointers have byref types");
217  return getParent()->getParamByRefType(getArgNo());
218 }
219 
221  assert(getType()->isPointerTy() && "Only pointers have inalloca types");
223 }
224 
226  assert(getType()->isPointerTy() &&
227  "Only pointers have dereferenceable bytes");
229 }
230 
232  assert(getType()->isPointerTy() &&
233  "Only pointers have dereferenceable bytes");
235 }
236 
237 bool Argument::hasNestAttr() const {
238  if (!getType()->isPointerTy()) return false;
239  return hasAttribute(Attribute::Nest);
240 }
241 
243  if (!getType()->isPointerTy()) return false;
244  return hasAttribute(Attribute::NoAlias);
245 }
246 
248  if (!getType()->isPointerTy()) return false;
249  return hasAttribute(Attribute::NoCapture);
250 }
251 
253  if (!getType()->isPointerTy()) return false;
254  return hasAttribute(Attribute::NoFree);
255 }
256 
258  if (!getType()->isPointerTy()) return false;
259  return hasAttribute(Attribute::StructRet);
260 }
261 
263  return hasAttribute(Attribute::InReg);
264 }
265 
267  return hasAttribute(Attribute::Returned);
268 }
269 
270 bool Argument::hasZExtAttr() const {
271  return hasAttribute(Attribute::ZExt);
272 }
273 
274 bool Argument::hasSExtAttr() const {
275  return hasAttribute(Attribute::SExt);
276 }
277 
280  return Attrs.hasParamAttr(getArgNo(), Attribute::ReadOnly) ||
281  Attrs.hasParamAttr(getArgNo(), Attribute::ReadNone);
282 }
283 
286  AL = AL.addParamAttributes(Parent->getContext(), getArgNo(), B);
288 }
289 
292 }
293 
295  getParent()->addParamAttr(getArgNo(), Attr);
296 }
297 
300 }
301 
304  AL = AL.removeParamAttributes(Parent->getContext(), getArgNo(), AM);
306 }
307 
310 }
311 
314 }
315 
316 //===----------------------------------------------------------------------===//
317 // Helper Methods in Function
318 //===----------------------------------------------------------------------===//
319 
321  return getType()->getContext();
322 }
323 
325  unsigned NumInstrs = 0;
326  for (const BasicBlock &BB : BasicBlocks)
327  NumInstrs += std::distance(BB.instructionsWithoutDebug().begin(),
328  BB.instructionsWithoutDebug().end());
329  return NumInstrs;
330 }
331 
333  const Twine &N, Module &M) {
334  return Create(Ty, Linkage, M.getDataLayout().getProgramAddressSpace(), N, &M);
335 }
336 
339  unsigned AddrSpace, const Twine &N,
340  Module *M) {
341  auto *F = new Function(Ty, Linkage, AddrSpace, N, M);
342  AttrBuilder B(F->getContext());
343  UWTableKind UWTable = M->getUwtable();
344  if (UWTable != UWTableKind::None)
345  B.addUWTableAttr(UWTable);
346  switch (M->getFramePointer()) {
348  // 0 ("none") is the default.
349  break;
351  B.addAttribute("frame-pointer", "non-leaf");
352  break;
354  B.addAttribute("frame-pointer", "all");
355  break;
356  }
357  if (M->getModuleFlag("function_return_thunk_extern"))
358  B.addAttribute(Attribute::FnRetThunkExtern);
359  F->addFnAttrs(B);
360  return F;
361 }
362 
364  getParent()->getFunctionList().remove(getIterator());
365 }
366 
368  getParent()->getFunctionList().erase(getIterator());
369 }
370 
371 //===----------------------------------------------------------------------===//
372 // Function Implementation
373 //===----------------------------------------------------------------------===//
374 
375 static unsigned computeAddrSpace(unsigned AddrSpace, Module *M) {
376  // If AS == -1 and we are passed a valid module pointer we place the function
377  // in the program address space. Otherwise we default to AS0.
378  if (AddrSpace == static_cast<unsigned>(-1))
379  return M ? M->getDataLayout().getProgramAddressSpace() : 0;
380  return AddrSpace;
381 }
382 
383 Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
384  const Twine &name, Module *ParentModule)
385  : GlobalObject(Ty, Value::FunctionVal,
386  OperandTraits<Function>::op_begin(this), 0, Linkage, name,
387  computeAddrSpace(AddrSpace, ParentModule)),
388  NumArgs(Ty->getNumParams()) {
389  assert(FunctionType::isValidReturnType(getReturnType()) &&
390  "invalid return type");
391  setGlobalObjectSubClassData(0);
392 
393  // We only need a symbol table for a function if the context keeps value names
394  if (!getContext().shouldDiscardValueNames())
395  SymTab = std::make_unique<ValueSymbolTable>(NonGlobalValueMaxNameSize);
396 
397  // If the function has arguments, mark them as lazily built.
398  if (Ty->getNumParams())
399  setValueSubclassData(1); // Set the "has lazy arguments" bit.
400 
401  if (ParentModule)
402  ParentModule->getFunctionList().push_back(this);
403 
404  HasLLVMReservedName = getName().startswith("llvm.");
405  // Ensure intrinsics have the right parameter attributes.
406  // Note, the IntID field will have been set in Value::setName if this function
407  // name is a valid intrinsic ID.
408  if (IntID)
409  setAttributes(Intrinsic::getAttributes(getContext(), IntID));
410 }
411 
412 Function::~Function() {
413  dropAllReferences(); // After this it is safe to delete instructions.
414 
415  // Delete all of the method arguments and unlink from symbol table...
416  if (Arguments)
417  clearArguments();
418 
419  // Remove the function from the on-the-side GC table.
420  clearGC();
421 }
422 
423 void Function::BuildLazyArguments() const {
424  // Create the arguments vector, all arguments start out unnamed.
425  auto *FT = getFunctionType();
426  if (NumArgs > 0) {
427  Arguments = std::allocator<Argument>().allocate(NumArgs);
428  for (unsigned i = 0, e = NumArgs; i != e; ++i) {
429  Type *ArgTy = FT->getParamType(i);
430  assert(!ArgTy->isVoidTy() && "Cannot have void typed arguments!");
431  new (Arguments + i) Argument(ArgTy, "", const_cast<Function *>(this), i);
432  }
433  }
434 
435  // Clear the lazy arguments bit.
436  unsigned SDC = getSubclassDataFromValue();
437  SDC &= ~(1 << 0);
438  const_cast<Function*>(this)->setValueSubclassData(SDC);
440 }
441 
443  return MutableArrayRef<Argument>(Args, Count);
444 }
445 
447  switch (getIntrinsicID()) {
448 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
449  case Intrinsic::INTRINSIC:
450 #include "llvm/IR/ConstrainedOps.def"
451  return true;
452 #undef INSTRUCTION
453  default:
454  return false;
455  }
456 }
457 
458 void Function::clearArguments() {
459  for (Argument &A : makeArgArray(Arguments, NumArgs)) {
460  A.setName("");
461  A.~Argument();
462  }
463  std::allocator<Argument>().deallocate(Arguments, NumArgs);
464  Arguments = nullptr;
465 }
466 
468  assert(isDeclaration() && "Expected no references to current arguments");
469 
470  // Drop the current arguments, if any, and set the lazy argument bit.
471  if (!hasLazyArguments()) {
472  assert(llvm::all_of(makeArgArray(Arguments, NumArgs),
473  [](const Argument &A) { return A.use_empty(); }) &&
474  "Expected arguments to be unused in declaration");
475  clearArguments();
476  setValueSubclassData(getSubclassDataFromValue() | (1 << 0));
477  }
478 
479  // Nothing to steal if Src has lazy arguments.
480  if (Src.hasLazyArguments())
481  return;
482 
483  // Steal arguments from Src, and fix the lazy argument bits.
484  assert(arg_size() == Src.arg_size());
485  Arguments = Src.Arguments;
486  Src.Arguments = nullptr;
487  for (Argument &A : makeArgArray(Arguments, NumArgs)) {
488  // FIXME: This does the work of transferNodesFromList inefficiently.
490  if (A.hasName())
491  Name = A.getName();
492  if (!Name.empty())
493  A.setName("");
494  A.setParent(this);
495  if (!Name.empty())
496  A.setName(Name);
497  }
498 
499  setValueSubclassData(getSubclassDataFromValue() & ~(1 << 0));
501  Src.setValueSubclassData(Src.getSubclassDataFromValue() | (1 << 0));
502 }
503 
504 // dropAllReferences() - This function causes all the subinstructions to "let
505 // go" of all references that they are maintaining. This allows one to
506 // 'delete' a whole class at a time, even though there may be circular
507 // references... first all references are dropped, and all use counts go to
508 // zero. Then everything is deleted for real. Note that no operations are
509 // valid on an object that has "dropped all references", except operator
510 // delete.
511 //
513  setIsMaterializable(false);
514 
515  for (BasicBlock &BB : *this)
516  BB.dropAllReferences();
517 
518  // Delete all basic blocks. They are now unused, except possibly by
519  // blockaddresses, but BasicBlock's destructor takes care of those.
520  while (!BasicBlocks.empty())
521  BasicBlocks.begin()->eraseFromParent();
522 
523  // Drop uses of any optional data (real or placeholder).
524  if (getNumOperands()) {
527  setValueSubclassData(getSubclassDataFromValue() & ~0xe);
528  }
529 
530  // Metadata is stored in a side-table.
531  clearMetadata();
532 }
533 
535  AttributeSets = AttributeSets.addAttributeAtIndex(getContext(), i, Attr);
536 }
537 
539  AttributeSets = AttributeSets.addFnAttribute(getContext(), Kind);
540 }
541 
543  AttributeSets = AttributeSets.addFnAttribute(getContext(), Kind, Val);
544 }
545 
547  AttributeSets = AttributeSets.addFnAttribute(getContext(), Attr);
548 }
549 
551  AttributeSets = AttributeSets.addFnAttributes(getContext(), Attrs);
552 }
553 
555  AttributeSets = AttributeSets.addRetAttribute(getContext(), Kind);
556 }
557 
559  AttributeSets = AttributeSets.addRetAttribute(getContext(), Attr);
560 }
561 
563  AttributeSets = AttributeSets.addRetAttributes(getContext(), Attrs);
564 }
565 
567  AttributeSets = AttributeSets.addParamAttribute(getContext(), ArgNo, Kind);
568 }
569 
570 void Function::addParamAttr(unsigned ArgNo, Attribute Attr) {
571  AttributeSets = AttributeSets.addParamAttribute(getContext(), ArgNo, Attr);
572 }
573 
574 void Function::addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs) {
575  AttributeSets = AttributeSets.addParamAttributes(getContext(), ArgNo, Attrs);
576 }
577 
579  AttributeSets = AttributeSets.removeAttributeAtIndex(getContext(), i, Kind);
580 }
581 
583  AttributeSets = AttributeSets.removeAttributeAtIndex(getContext(), i, Kind);
584 }
585 
587  AttributeSets = AttributeSets.removeFnAttribute(getContext(), Kind);
588 }
589 
591  AttributeSets = AttributeSets.removeFnAttribute(getContext(), Kind);
592 }
593 
595  AttributeSets = AttributeSets.removeFnAttributes(getContext(), AM);
596 }
597 
599  AttributeSets = AttributeSets.removeRetAttribute(getContext(), Kind);
600 }
601 
603  AttributeSets = AttributeSets.removeRetAttribute(getContext(), Kind);
604 }
605 
607  AttributeSets = AttributeSets.removeRetAttributes(getContext(), Attrs);
608 }
609 
611  AttributeSets = AttributeSets.removeParamAttribute(getContext(), ArgNo, Kind);
612 }
613 
614 void Function::removeParamAttr(unsigned ArgNo, StringRef Kind) {
615  AttributeSets = AttributeSets.removeParamAttribute(getContext(), ArgNo, Kind);
616 }
617 
618 void Function::removeParamAttrs(unsigned ArgNo, const AttributeMask &Attrs) {
619  AttributeSets =
620  AttributeSets.removeParamAttributes(getContext(), ArgNo, Attrs);
621 }
622 
623 void Function::addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes) {
624  AttributeSets =
625  AttributeSets.addDereferenceableParamAttr(getContext(), ArgNo, Bytes);
626 }
627 
629  return AttributeSets.hasFnAttr(Kind);
630 }
631 
633  return AttributeSets.hasFnAttr(Kind);
634 }
635 
637  return AttributeSets.hasRetAttr(Kind);
638 }
639 
640 bool Function::hasParamAttribute(unsigned ArgNo,
641  Attribute::AttrKind Kind) const {
642  return AttributeSets.hasParamAttr(ArgNo, Kind);
643 }
644 
646  Attribute::AttrKind Kind) const {
647  return AttributeSets.getAttributeAtIndex(i, Kind);
648 }
649 
651  return AttributeSets.getAttributeAtIndex(i, Kind);
652 }
653 
655  return AttributeSets.getFnAttr(Kind);
656 }
657 
659  return AttributeSets.getFnAttr(Kind);
660 }
661 
662 /// gets the specified attribute from the list of attributes.
664  Attribute::AttrKind Kind) const {
665  return AttributeSets.getParamAttr(ArgNo, Kind);
666 }
667 
669  uint64_t Bytes) {
670  AttributeSets = AttributeSets.addDereferenceableOrNullParamAttr(getContext(),
671  ArgNo, Bytes);
672 }
673 
675  if (&FPType == &APFloat::IEEEsingle()) {
676  Attribute Attr = getFnAttribute("denormal-fp-math-f32");
677  StringRef Val = Attr.getValueAsString();
678  if (!Val.empty())
679  return parseDenormalFPAttribute(Val);
680 
681  // If the f32 variant of the attribute isn't specified, try to use the
682  // generic one.
683  }
684 
685  Attribute Attr = getFnAttribute("denormal-fp-math");
687 }
688 
689 const std::string &Function::getGC() const {
690  assert(hasGC() && "Function has no collector");
691  return getContext().getGC(*this);
692 }
693 
694 void Function::setGC(std::string Str) {
695  setValueSubclassDataBit(14, !Str.empty());
696  getContext().setGC(*this, std::move(Str));
697 }
698 
700  if (!hasGC())
701  return;
702  getContext().deleteGC(*this);
703  setValueSubclassDataBit(14, false);
704 }
705 
707  return hasFnAttribute(Attribute::StackProtect) ||
708  hasFnAttribute(Attribute::StackProtectStrong) ||
709  hasFnAttribute(Attribute::StackProtectReq);
710 }
711 
712 /// Copy all additional attributes (those not needed to create a Function) from
713 /// the Function Src to this one.
716  setCallingConv(Src->getCallingConv());
717  setAttributes(Src->getAttributes());
718  if (Src->hasGC())
719  setGC(Src->getGC());
720  else
721  clearGC();
722  if (Src->hasPersonalityFn())
723  setPersonalityFn(Src->getPersonalityFn());
724  if (Src->hasPrefixData())
725  setPrefixData(Src->getPrefixData());
726  if (Src->hasPrologueData())
727  setPrologueData(Src->getPrologueData());
728 }
729 
730 /// Table of string intrinsic names indexed by enum value.
731 static const char * const IntrinsicNameTable[] = {
732  "not_intrinsic",
733 #define GET_INTRINSIC_NAME_TABLE
734 #include "llvm/IR/IntrinsicImpl.inc"
735 #undef GET_INTRINSIC_NAME_TABLE
736 };
737 
738 /// Table of per-target intrinsic name tables.
739 #define GET_INTRINSIC_TARGET_DATA
740 #include "llvm/IR/IntrinsicImpl.inc"
741 #undef GET_INTRINSIC_TARGET_DATA
742 
744  return IID > TargetInfos[0].Count;
745 }
746 
748  return isTargetIntrinsic(IntID);
749 }
750 
751 /// Find the segment of \c IntrinsicNameTable for intrinsics with the same
752 /// target as \c Name, or the generic table if \c Name is not target specific.
753 ///
754 /// Returns the relevant slice of \c IntrinsicNameTable
756  assert(Name.startswith("llvm."));
757 
758  ArrayRef<IntrinsicTargetInfo> Targets(TargetInfos);
759  // Drop "llvm." and take the first dotted component. That will be the target
760  // if this is target specific.
761  StringRef Target = Name.drop_front(5).split('.').first;
762  auto It = partition_point(
763  Targets, [=](const IntrinsicTargetInfo &TI) { return TI.Name < Target; });
764  // We've either found the target or just fall back to the generic set, which
765  // is always first.
766  const auto &TI = It != Targets.end() && It->Name == Target ? *It : Targets[0];
767  return makeArrayRef(&IntrinsicNameTable[1] + TI.Offset, TI.Count);
768 }
769 
770 /// This does the actual lookup of an intrinsic ID which
771 /// matches the given function name.
774  int Idx = Intrinsic::lookupLLVMIntrinsicByName(NameTable, Name);
775  if (Idx == -1)
777 
778  // Intrinsic IDs correspond to the location in IntrinsicNameTable, but we have
779  // an index into a sub-table.
780  int Adjust = NameTable.data() - IntrinsicNameTable;
781  Intrinsic::ID ID = static_cast<Intrinsic::ID>(Idx + Adjust);
782 
783  // If the intrinsic is not overloaded, require an exact match. If it is
784  // overloaded, require either exact or prefix match.
785  const auto MatchSize = strlen(NameTable[Idx]);
786  assert(Name.size() >= MatchSize && "Expected either exact or prefix match");
787  bool IsExactMatch = Name.size() == MatchSize;
788  return IsExactMatch || Intrinsic::isOverloaded(ID) ? ID
790 }
791 
793  StringRef Name = getName();
794  if (!Name.startswith("llvm.")) {
795  HasLLVMReservedName = false;
797  return;
798  }
799  HasLLVMReservedName = true;
801 }
802 
803 /// Returns a stable mangling for the type specified for use in the name
804 /// mangling scheme used by 'any' types in intrinsic signatures. The mangling
805 /// of named types is simply their name. Manglings for unnamed types consist
806 /// of a prefix ('p' for pointers, 'a' for arrays, 'f_' for functions)
807 /// combined with the mangling of their component types. A vararg function
808 /// type will have a suffix of 'vararg'. Since function types can contain
809 /// other function types, we close a function type mangling with suffix 'f'
810 /// which can't be confused with it's prefix. This ensures we don't have
811 /// collisions between two unrelated function types. Otherwise, you might
812 /// parse ffXX as f(fXX) or f(fX)X. (X is a placeholder for any other type.)
813 /// The HasUnnamedType boolean is set if an unnamed type was encountered,
814 /// indicating that extra care must be taken to ensure a unique name.
815 static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType) {
816  std::string Result;
817  if (PointerType *PTyp = dyn_cast<PointerType>(Ty)) {
818  Result += "p" + utostr(PTyp->getAddressSpace());
819  // Opaque pointer doesn't have pointee type information, so we just mangle
820  // address space for opaque pointer.
821  if (!PTyp->isOpaque())
822  Result += getMangledTypeStr(PTyp->getNonOpaquePointerElementType(),
823  HasUnnamedType);
824  } else if (ArrayType *ATyp = dyn_cast<ArrayType>(Ty)) {
825  Result += "a" + utostr(ATyp->getNumElements()) +
826  getMangledTypeStr(ATyp->getElementType(), HasUnnamedType);
827  } else if (StructType *STyp = dyn_cast<StructType>(Ty)) {
828  if (!STyp->isLiteral()) {
829  Result += "s_";
830  if (STyp->hasName())
831  Result += STyp->getName();
832  else
833  HasUnnamedType = true;
834  } else {
835  Result += "sl_";
836  for (auto *Elem : STyp->elements())
837  Result += getMangledTypeStr(Elem, HasUnnamedType);
838  }
839  // Ensure nested structs are distinguishable.
840  Result += "s";
841  } else if (FunctionType *FT = dyn_cast<FunctionType>(Ty)) {
842  Result += "f_" + getMangledTypeStr(FT->getReturnType(), HasUnnamedType);
843  for (size_t i = 0; i < FT->getNumParams(); i++)
844  Result += getMangledTypeStr(FT->getParamType(i), HasUnnamedType);
845  if (FT->isVarArg())
846  Result += "vararg";
847  // Ensure nested function types are distinguishable.
848  Result += "f";
849  } else if (VectorType *VTy = dyn_cast<VectorType>(Ty)) {
850  ElementCount EC = VTy->getElementCount();
851  if (EC.isScalable())
852  Result += "nx";
853  Result += "v" + utostr(EC.getKnownMinValue()) +
854  getMangledTypeStr(VTy->getElementType(), HasUnnamedType);
855  } else if (Ty) {
856  switch (Ty->getTypeID()) {
857  default: llvm_unreachable("Unhandled type");
858  case Type::VoidTyID: Result += "isVoid"; break;
859  case Type::MetadataTyID: Result += "Metadata"; break;
860  case Type::HalfTyID: Result += "f16"; break;
861  case Type::BFloatTyID: Result += "bf16"; break;
862  case Type::FloatTyID: Result += "f32"; break;
863  case Type::DoubleTyID: Result += "f64"; break;
864  case Type::X86_FP80TyID: Result += "f80"; break;
865  case Type::FP128TyID: Result += "f128"; break;
866  case Type::PPC_FP128TyID: Result += "ppcf128"; break;
867  case Type::X86_MMXTyID: Result += "x86mmx"; break;
868  case Type::X86_AMXTyID: Result += "x86amx"; break;
869  case Type::IntegerTyID:
870  Result += "i" + utostr(cast<IntegerType>(Ty)->getBitWidth());
871  break;
872  }
873  }
874  return Result;
875 }
876 
878  assert(id < num_intrinsics && "Invalid intrinsic ID!");
879  return IntrinsicNameTable[id];
880 }
881 
883  assert(id < num_intrinsics && "Invalid intrinsic ID!");
885  "This version of getName does not support overloading");
886  return getBaseName(id);
887 }
888 
890  Module *M, FunctionType *FT,
891  bool EarlyModuleCheck) {
892 
893  assert(Id < Intrinsic::num_intrinsics && "Invalid intrinsic ID!");
894  assert((Tys.empty() || Intrinsic::isOverloaded(Id)) &&
895  "This version of getName is for overloaded intrinsics only");
896  (void)EarlyModuleCheck;
897  assert((!EarlyModuleCheck || M ||
898  !any_of(Tys, [](Type *T) { return isa<PointerType>(T); })) &&
899  "Intrinsic overloading on pointer types need to provide a Module");
900  bool HasUnnamedType = false;
901  std::string Result(Intrinsic::getBaseName(Id));
902  for (Type *Ty : Tys)
903  Result += "." + getMangledTypeStr(Ty, HasUnnamedType);
904  if (HasUnnamedType) {
905  assert(M && "unnamed types need a module");
906  if (!FT)
907  FT = Intrinsic::getType(M->getContext(), Id, Tys);
908  else
909  assert((FT == Intrinsic::getType(M->getContext(), Id, Tys)) &&
910  "Provided FunctionType must match arguments");
911  return M->getUniqueIntrinsicName(Result, Id, FT);
912  }
913  return Result;
914 }
915 
917  FunctionType *FT) {
918  assert(M && "We need to have a Module");
919  return getIntrinsicNameImpl(Id, Tys, M, FT, true);
920 }
921 
923  return getIntrinsicNameImpl(Id, Tys, nullptr, nullptr, false);
924 }
925 
926 /// IIT_Info - These are enumerators that describe the entries returned by the
927 /// getIntrinsicInfoTableEntries function.
928 ///
929 /// NOTE: This must be kept in synch with the copy in TblGen/IntrinsicEmitter!
930 enum IIT_Info {
931  // Common values should be encoded with 0-15.
932  IIT_Done = 0,
933  IIT_I1 = 1,
934  IIT_I8 = 2,
935  IIT_I16 = 3,
936  IIT_I32 = 4,
937  IIT_I64 = 5,
938  IIT_F16 = 6,
939  IIT_F32 = 7,
940  IIT_F64 = 8,
941  IIT_V2 = 9,
942  IIT_V4 = 10,
943  IIT_V8 = 11,
944  IIT_V16 = 12,
945  IIT_V32 = 13,
946  IIT_PTR = 14,
947  IIT_ARG = 15,
948 
949  // Values from 16+ are only encodable with the inefficient encoding.
950  IIT_V64 = 16,
951  IIT_MMX = 17,
952  IIT_TOKEN = 18,
962  IIT_V1 = 28,
969  IIT_I128 = 35,
970  IIT_V512 = 36,
971  IIT_V1024 = 37,
975  IIT_F128 = 41,
981  IIT_V128 = 47,
982  IIT_BF16 = 48,
984  IIT_V256 = 50,
985  IIT_AMX = 51,
987  IIT_V3 = 53,
991  IIT_I2 = 57,
992  IIT_I4 = 58,
993 };
994 
995 static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos,
996  IIT_Info LastInfo,
998  using namespace Intrinsic;
999 
1000  bool IsScalableVector = (LastInfo == IIT_SCALABLE_VEC);
1001 
1002  IIT_Info Info = IIT_Info(Infos[NextElt++]);
1003  unsigned StructElts = 2;
1004 
1005  switch (Info) {
1006  case IIT_Done:
1007  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Void, 0));
1008  return;
1009  case IIT_VARARG:
1010  OutputTable.push_back(IITDescriptor::get(IITDescriptor::VarArg, 0));
1011  return;
1012  case IIT_MMX:
1013  OutputTable.push_back(IITDescriptor::get(IITDescriptor::MMX, 0));
1014  return;
1015  case IIT_AMX:
1016  OutputTable.push_back(IITDescriptor::get(IITDescriptor::AMX, 0));
1017  return;
1018  case IIT_TOKEN:
1019  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Token, 0));
1020  return;
1021  case IIT_METADATA:
1022  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Metadata, 0));
1023  return;
1024  case IIT_F16:
1025  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Half, 0));
1026  return;
1027  case IIT_BF16:
1028  OutputTable.push_back(IITDescriptor::get(IITDescriptor::BFloat, 0));
1029  return;
1030  case IIT_F32:
1031  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Float, 0));
1032  return;
1033  case IIT_F64:
1034  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Double, 0));
1035  return;
1036  case IIT_F128:
1037  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Quad, 0));
1038  return;
1039  case IIT_PPCF128:
1040  OutputTable.push_back(IITDescriptor::get(IITDescriptor::PPCQuad, 0));
1041  return;
1042  case IIT_I1:
1043  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 1));
1044  return;
1045  case IIT_I2:
1046  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 2));
1047  return;
1048  case IIT_I4:
1049  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 4));
1050  return;
1051  case IIT_I8:
1052  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 8));
1053  return;
1054  case IIT_I16:
1055  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer,16));
1056  return;
1057  case IIT_I32:
1058  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 32));
1059  return;
1060  case IIT_I64:
1061  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 64));
1062  return;
1063  case IIT_I128:
1064  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 128));
1065  return;
1066  case IIT_V1:
1067  OutputTable.push_back(IITDescriptor::getVector(1, IsScalableVector));
1068  DecodeIITType(NextElt, Infos, Info, OutputTable);
1069  return;
1070  case IIT_V2:
1071  OutputTable.push_back(IITDescriptor::getVector(2, IsScalableVector));
1072  DecodeIITType(NextElt, Infos, Info, OutputTable);
1073  return;
1074  case IIT_V3:
1075  OutputTable.push_back(IITDescriptor::getVector(3, IsScalableVector));
1076  DecodeIITType(NextElt, Infos, Info, OutputTable);
1077  return;
1078  case IIT_V4:
1079  OutputTable.push_back(IITDescriptor::getVector(4, IsScalableVector));
1080  DecodeIITType(NextElt, Infos, Info, OutputTable);
1081  return;
1082  case IIT_V8:
1083  OutputTable.push_back(IITDescriptor::getVector(8, IsScalableVector));
1084  DecodeIITType(NextElt, Infos, Info, OutputTable);
1085  return;
1086  case IIT_V16:
1087  OutputTable.push_back(IITDescriptor::getVector(16, IsScalableVector));
1088  DecodeIITType(NextElt, Infos, Info, OutputTable);
1089  return;
1090  case IIT_V32:
1091  OutputTable.push_back(IITDescriptor::getVector(32, IsScalableVector));
1092  DecodeIITType(NextElt, Infos, Info, OutputTable);
1093  return;
1094  case IIT_V64:
1095  OutputTable.push_back(IITDescriptor::getVector(64, IsScalableVector));
1096  DecodeIITType(NextElt, Infos, Info, OutputTable);
1097  return;
1098  case IIT_V128:
1099  OutputTable.push_back(IITDescriptor::getVector(128, IsScalableVector));
1100  DecodeIITType(NextElt, Infos, Info, OutputTable);
1101  return;
1102  case IIT_V256:
1103  OutputTable.push_back(IITDescriptor::getVector(256, IsScalableVector));
1104  DecodeIITType(NextElt, Infos, Info, OutputTable);
1105  return;
1106  case IIT_V512:
1107  OutputTable.push_back(IITDescriptor::getVector(512, IsScalableVector));
1108  DecodeIITType(NextElt, Infos, Info, OutputTable);
1109  return;
1110  case IIT_V1024:
1111  OutputTable.push_back(IITDescriptor::getVector(1024, IsScalableVector));
1112  DecodeIITType(NextElt, Infos, Info, OutputTable);
1113  return;
1114  case IIT_EXTERNREF:
1115  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer, 10));
1116  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
1117  return;
1118  case IIT_FUNCREF:
1119  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer, 20));
1120  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 8));
1121  return;
1122  case IIT_PTR:
1123  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer, 0));
1124  DecodeIITType(NextElt, Infos, Info, OutputTable);
1125  return;
1126  case IIT_ANYPTR: { // [ANYPTR addrspace, subtype]
1127  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer,
1128  Infos[NextElt++]));
1129  DecodeIITType(NextElt, Infos, Info, OutputTable);
1130  return;
1131  }
1132  case IIT_ARG: {
1133  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1134  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Argument, ArgInfo));
1135  return;
1136  }
1137  case IIT_EXTEND_ARG: {
1138  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1139  OutputTable.push_back(IITDescriptor::get(IITDescriptor::ExtendArgument,
1140  ArgInfo));
1141  return;
1142  }
1143  case IIT_TRUNC_ARG: {
1144  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1145  OutputTable.push_back(IITDescriptor::get(IITDescriptor::TruncArgument,
1146  ArgInfo));
1147  return;
1148  }
1149  case IIT_HALF_VEC_ARG: {
1150  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1151  OutputTable.push_back(IITDescriptor::get(IITDescriptor::HalfVecArgument,
1152  ArgInfo));
1153  return;
1154  }
1155  case IIT_SAME_VEC_WIDTH_ARG: {
1156  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1158  ArgInfo));
1159  return;
1160  }
1161  case IIT_PTR_TO_ARG: {
1162  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1163  OutputTable.push_back(IITDescriptor::get(IITDescriptor::PtrToArgument,
1164  ArgInfo));
1165  return;
1166  }
1167  case IIT_PTR_TO_ELT: {
1168  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1169  OutputTable.push_back(IITDescriptor::get(IITDescriptor::PtrToElt, ArgInfo));
1170  return;
1171  }
1172  case IIT_ANYPTR_TO_ELT: {
1173  unsigned short ArgNo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1174  unsigned short RefNo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1175  OutputTable.push_back(
1177  return;
1178  }
1180  unsigned short ArgNo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1181  unsigned short RefNo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1182  OutputTable.push_back(
1184  return;
1185  }
1186  case IIT_EMPTYSTRUCT:
1187  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
1188  return;
1189  case IIT_STRUCT9: ++StructElts; [[fallthrough]];
1190  case IIT_STRUCT8: ++StructElts; [[fallthrough]];
1191  case IIT_STRUCT7: ++StructElts; [[fallthrough]];
1192  case IIT_STRUCT6: ++StructElts; [[fallthrough]];
1193  case IIT_STRUCT5: ++StructElts; [[fallthrough]];
1194  case IIT_STRUCT4: ++StructElts; [[fallthrough]];
1195  case IIT_STRUCT3: ++StructElts; [[fallthrough]];
1196  case IIT_STRUCT2: {
1197  OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct,StructElts));
1198 
1199  for (unsigned i = 0; i != StructElts; ++i)
1200  DecodeIITType(NextElt, Infos, Info, OutputTable);
1201  return;
1202  }
1203  case IIT_SUBDIVIDE2_ARG: {
1204  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1206  ArgInfo));
1207  return;
1208  }
1209  case IIT_SUBDIVIDE4_ARG: {
1210  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1212  ArgInfo));
1213  return;
1214  }
1215  case IIT_VEC_ELEMENT: {
1216  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1218  ArgInfo));
1219  return;
1220  }
1221  case IIT_SCALABLE_VEC: {
1222  DecodeIITType(NextElt, Infos, Info, OutputTable);
1223  return;
1224  }
1226  unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1228  ArgInfo));
1229  return;
1230  }
1231  }
1232  llvm_unreachable("unhandled");
1233 }
1234 
1235 #define GET_INTRINSIC_GENERATOR_GLOBAL
1236 #include "llvm/IR/IntrinsicImpl.inc"
1237 #undef GET_INTRINSIC_GENERATOR_GLOBAL
1238 
1241  // Check to see if the intrinsic's type was expressible by the table.
1242  unsigned TableVal = IIT_Table[id-1];
1243 
1244  // Decode the TableVal into an array of IITValues.
1246  ArrayRef<unsigned char> IITEntries;
1247  unsigned NextElt = 0;
1248  if ((TableVal >> 31) != 0) {
1249  // This is an offset into the IIT_LongEncodingTable.
1250  IITEntries = IIT_LongEncodingTable;
1251 
1252  // Strip sentinel bit.
1253  NextElt = (TableVal << 1) >> 1;
1254  } else {
1255  // Decode the TableVal into an array of IITValues. If the entry was encoded
1256  // into a single word in the table itself, decode it now.
1257  do {
1258  IITValues.push_back(TableVal & 0xF);
1259  TableVal >>= 4;
1260  } while (TableVal);
1261 
1262  IITEntries = IITValues;
1263  NextElt = 0;
1264  }
1265 
1266  // Okay, decode the table into the output vector of IITDescriptors.
1267  DecodeIITType(NextElt, IITEntries, IIT_Done, T);
1268  while (NextElt != IITEntries.size() && IITEntries[NextElt] != 0)
1269  DecodeIITType(NextElt, IITEntries, IIT_Done, T);
1270 }
1271 
1274  using namespace Intrinsic;
1275 
1276  IITDescriptor D = Infos.front();
1277  Infos = Infos.slice(1);
1278 
1279  switch (D.Kind) {
1292 
1294  return IntegerType::get(Context, D.Integer_Width);
1295  case IITDescriptor::Vector:
1296  return VectorType::get(DecodeFixedType(Infos, Tys, Context),
1297  D.Vector_Width);
1299  return PointerType::get(DecodeFixedType(Infos, Tys, Context),
1300  D.Pointer_AddressSpace);
1301  case IITDescriptor::Struct: {
1303  for (unsigned i = 0, e = D.Struct_NumElements; i != e; ++i)
1304  Elts.push_back(DecodeFixedType(Infos, Tys, Context));
1305  return StructType::get(Context, Elts);
1306  }
1308  return Tys[D.getArgumentNumber()];
1310  Type *Ty = Tys[D.getArgumentNumber()];
1311  if (VectorType *VTy = dyn_cast<VectorType>(Ty))
1313 
1314  return IntegerType::get(Context, 2 * cast<IntegerType>(Ty)->getBitWidth());
1315  }
1317  Type *Ty = Tys[D.getArgumentNumber()];
1318  if (VectorType *VTy = dyn_cast<VectorType>(Ty))
1320 
1321  IntegerType *ITy = cast<IntegerType>(Ty);
1322  assert(ITy->getBitWidth() % 2 == 0);
1323  return IntegerType::get(Context, ITy->getBitWidth() / 2);
1324  }
1327  Type *Ty = Tys[D.getArgumentNumber()];
1328  VectorType *VTy = dyn_cast<VectorType>(Ty);
1329  assert(VTy && "Expected an argument of Vector Type");
1330  int SubDivs = D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
1331  return VectorType::getSubdividedVectorType(VTy, SubDivs);
1332  }
1334  return VectorType::getHalfElementsVectorType(cast<VectorType>(
1335  Tys[D.getArgumentNumber()]));
1337  Type *EltTy = DecodeFixedType(Infos, Tys, Context);
1338  Type *Ty = Tys[D.getArgumentNumber()];
1339  if (auto *VTy = dyn_cast<VectorType>(Ty))
1340  return VectorType::get(EltTy, VTy->getElementCount());
1341  return EltTy;
1342  }
1344  Type *Ty = Tys[D.getArgumentNumber()];
1345  return PointerType::getUnqual(Ty);
1346  }
1347  case IITDescriptor::PtrToElt: {
1348  Type *Ty = Tys[D.getArgumentNumber()];
1349  VectorType *VTy = dyn_cast<VectorType>(Ty);
1350  if (!VTy)
1351  llvm_unreachable("Expected an argument of Vector Type");
1352  Type *EltTy = VTy->getElementType();
1353  return PointerType::getUnqual(EltTy);
1354  }
1356  Type *Ty = Tys[D.getArgumentNumber()];
1357  if (VectorType *VTy = dyn_cast<VectorType>(Ty))
1358  return VTy->getElementType();
1359  llvm_unreachable("Expected an argument of Vector Type");
1360  }
1362  Type *Ty = Tys[D.getArgumentNumber()];
1363  VectorType *VTy = dyn_cast<VectorType>(Ty);
1364  assert(VTy && "Expected an argument of Vector Type");
1365  return VectorType::getInteger(VTy);
1366  }
1368  // Return the overloaded type (which determines the pointers address space)
1369  return Tys[D.getOverloadArgNumber()];
1371  // Return the overloaded type (which determines the pointers address space)
1372  return Tys[D.getOverloadArgNumber()];
1373  }
1374  llvm_unreachable("unhandled");
1375 }
1376 
1378  ID id, ArrayRef<Type*> Tys) {
1380  getIntrinsicInfoTableEntries(id, Table);
1381 
1383  Type *ResultTy = DecodeFixedType(TableRef, Tys, Context);
1384 
1385  SmallVector<Type*, 8> ArgTys;
1386  while (!TableRef.empty())
1387  ArgTys.push_back(DecodeFixedType(TableRef, Tys, Context));
1388 
1389  // DecodeFixedType returns Void for IITDescriptor::Void and IITDescriptor::VarArg
1390  // If we see void type as the type of the last argument, it is vararg intrinsic
1391  if (!ArgTys.empty() && ArgTys.back()->isVoidTy()) {
1392  ArgTys.pop_back();
1393  return FunctionType::get(ResultTy, ArgTys, true);
1394  }
1395  return FunctionType::get(ResultTy, ArgTys, false);
1396 }
1397 
1399 #define GET_INTRINSIC_OVERLOAD_TABLE
1400 #include "llvm/IR/IntrinsicImpl.inc"
1401 #undef GET_INTRINSIC_OVERLOAD_TABLE
1402 }
1403 
1405  switch (id) {
1406  default:
1407  return true;
1408 
1409  case Intrinsic::experimental_gc_statepoint:
1410  case Intrinsic::experimental_patchpoint_void:
1411  case Intrinsic::experimental_patchpoint_i64:
1412  return false;
1413  }
1414 }
1415 
1416 /// This defines the "Intrinsic::getAttributes(ID id)" method.
1417 #define GET_INTRINSIC_ATTRIBUTES
1418 #include "llvm/IR/IntrinsicImpl.inc"
1419 #undef GET_INTRINSIC_ATTRIBUTES
1420 
1422  // There can never be multiple globals with the same name of different types,
1423  // because intrinsics must be a specific type.
1424  auto *FT = getType(M->getContext(), id, Tys);
1425  return cast<Function>(
1426  M->getOrInsertFunction(
1427  Tys.empty() ? getName(id) : getName(id, Tys, M, FT), FT)
1428  .getCallee());
1429 }
1430 
1431 // This defines the "Intrinsic::getIntrinsicForClangBuiltin()" method.
1432 #define GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
1433 #include "llvm/IR/IntrinsicImpl.inc"
1434 #undef GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
1435 
1436 // This defines the "Intrinsic::getIntrinsicForMSBuiltin()" method.
1437 #define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
1438 #include "llvm/IR/IntrinsicImpl.inc"
1439 #undef GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
1440 
1442  std::pair<Type *, ArrayRef<Intrinsic::IITDescriptor>>;
1443 
1446  SmallVectorImpl<Type *> &ArgTys,
1448  bool IsDeferredCheck) {
1449  using namespace Intrinsic;
1450 
1451  // If we ran out of descriptors, there are too many arguments.
1452  if (Infos.empty()) return true;
1453 
1454  // Do this before slicing off the 'front' part
1455  auto InfosRef = Infos;
1456  auto DeferCheck = [&DeferredChecks, &InfosRef](Type *T) {
1457  DeferredChecks.emplace_back(T, InfosRef);
1458  return false;
1459  };
1460 
1461  IITDescriptor D = Infos.front();
1462  Infos = Infos.slice(1);
1463 
1464  switch (D.Kind) {
1465  case IITDescriptor::Void: return !Ty->isVoidTy();
1466  case IITDescriptor::VarArg: return true;
1467  case IITDescriptor::MMX: return !Ty->isX86_MMXTy();
1468  case IITDescriptor::AMX: return !Ty->isX86_AMXTy();
1469  case IITDescriptor::Token: return !Ty->isTokenTy();
1470  case IITDescriptor::Metadata: return !Ty->isMetadataTy();
1471  case IITDescriptor::Half: return !Ty->isHalfTy();
1472  case IITDescriptor::BFloat: return !Ty->isBFloatTy();
1473  case IITDescriptor::Float: return !Ty->isFloatTy();
1474  case IITDescriptor::Double: return !Ty->isDoubleTy();
1475  case IITDescriptor::Quad: return !Ty->isFP128Ty();
1476  case IITDescriptor::PPCQuad: return !Ty->isPPC_FP128Ty();
1477  case IITDescriptor::Integer: return !Ty->isIntegerTy(D.Integer_Width);
1478  case IITDescriptor::Vector: {
1479  VectorType *VT = dyn_cast<VectorType>(Ty);
1480  return !VT || VT->getElementCount() != D.Vector_Width ||
1481  matchIntrinsicType(VT->getElementType(), Infos, ArgTys,
1482  DeferredChecks, IsDeferredCheck);
1483  }
1484  case IITDescriptor::Pointer: {
1485  PointerType *PT = dyn_cast<PointerType>(Ty);
1486  if (!PT || PT->getAddressSpace() != D.Pointer_AddressSpace)
1487  return true;
1488  if (!PT->isOpaque()) {
1489  /* Manually consume a pointer to empty struct descriptor, which is
1490  * used for externref. We don't want to enforce that the struct is
1491  * anonymous in this case. (This renders externref intrinsics
1492  * non-unique, but this will go away with opaque pointers anyway.) */
1493  if (Infos.front().Kind == IITDescriptor::Struct &&
1494  Infos.front().Struct_NumElements == 0) {
1495  Infos = Infos.slice(1);
1496  return false;
1497  }
1499  ArgTys, DeferredChecks, IsDeferredCheck);
1500  }
1501  // Consume IIT descriptors relating to the pointer element type.
1502  // FIXME: Intrinsic type matching of nested single value types or even
1503  // aggregates doesn't work properly with opaque pointers but hopefully
1504  // doesn't happen in practice.
1505  while (Infos.front().Kind == IITDescriptor::Pointer ||
1506  Infos.front().Kind == IITDescriptor::Vector)
1507  Infos = Infos.slice(1);
1508  assert((Infos.front().Kind != IITDescriptor::Argument ||
1510  "Unsupported polymorphic pointer type with opaque pointer");
1511  Infos = Infos.slice(1);
1512  return false;
1513  }
1514 
1515  case IITDescriptor::Struct: {
1516  StructType *ST = dyn_cast<StructType>(Ty);
1517  if (!ST || !ST->isLiteral() || ST->isPacked() ||
1518  ST->getNumElements() != D.Struct_NumElements)
1519  return true;
1520 
1521  for (unsigned i = 0, e = D.Struct_NumElements; i != e; ++i)
1522  if (matchIntrinsicType(ST->getElementType(i), Infos, ArgTys,
1523  DeferredChecks, IsDeferredCheck))
1524  return true;
1525  return false;
1526  }
1527 
1529  // If this is the second occurrence of an argument,
1530  // verify that the later instance matches the previous instance.
1531  if (D.getArgumentNumber() < ArgTys.size())
1532  return Ty != ArgTys[D.getArgumentNumber()];
1533 
1534  if (D.getArgumentNumber() > ArgTys.size() ||
1535  D.getArgumentKind() == IITDescriptor::AK_MatchType)
1536  return IsDeferredCheck || DeferCheck(Ty);
1537 
1538  assert(D.getArgumentNumber() == ArgTys.size() && !IsDeferredCheck &&
1539  "Table consistency error");
1540  ArgTys.push_back(Ty);
1541 
1542  switch (D.getArgumentKind()) {
1543  case IITDescriptor::AK_Any: return false; // Success
1545  case IITDescriptor::AK_AnyFloat: return !Ty->isFPOrFPVectorTy();
1546  case IITDescriptor::AK_AnyVector: return !isa<VectorType>(Ty);
1547  case IITDescriptor::AK_AnyPointer: return !isa<PointerType>(Ty);
1548  default: break;
1549  }
1550  llvm_unreachable("all argument kinds not covered");
1551 
1553  // If this is a forward reference, defer the check for later.
1554  if (D.getArgumentNumber() >= ArgTys.size())
1555  return IsDeferredCheck || DeferCheck(Ty);
1556 
1557  Type *NewTy = ArgTys[D.getArgumentNumber()];
1558  if (VectorType *VTy = dyn_cast<VectorType>(NewTy))
1560  else if (IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
1561  NewTy = IntegerType::get(ITy->getContext(), 2 * ITy->getBitWidth());
1562  else
1563  return true;
1564 
1565  return Ty != NewTy;
1566  }
1568  // If this is a forward reference, defer the check for later.
1569  if (D.getArgumentNumber() >= ArgTys.size())
1570  return IsDeferredCheck || DeferCheck(Ty);
1571 
1572  Type *NewTy = ArgTys[D.getArgumentNumber()];
1573  if (VectorType *VTy = dyn_cast<VectorType>(NewTy))
1575  else if (IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
1576  NewTy = IntegerType::get(ITy->getContext(), ITy->getBitWidth() / 2);
1577  else
1578  return true;
1579 
1580  return Ty != NewTy;
1581  }
1583  // If this is a forward reference, defer the check for later.
1584  if (D.getArgumentNumber() >= ArgTys.size())
1585  return IsDeferredCheck || DeferCheck(Ty);
1586  return !isa<VectorType>(ArgTys[D.getArgumentNumber()]) ||
1588  cast<VectorType>(ArgTys[D.getArgumentNumber()])) != Ty;
1590  if (D.getArgumentNumber() >= ArgTys.size()) {
1591  // Defer check and subsequent check for the vector element type.
1592  Infos = Infos.slice(1);
1593  return IsDeferredCheck || DeferCheck(Ty);
1594  }
1595  auto *ReferenceType = dyn_cast<VectorType>(ArgTys[D.getArgumentNumber()]);
1596  auto *ThisArgType = dyn_cast<VectorType>(Ty);
1597  // Both must be vectors of the same number of elements or neither.
1598  if ((ReferenceType != nullptr) != (ThisArgType != nullptr))
1599  return true;
1600  Type *EltTy = Ty;
1601  if (ThisArgType) {
1602  if (ReferenceType->getElementCount() !=
1603  ThisArgType->getElementCount())
1604  return true;
1605  EltTy = ThisArgType->getElementType();
1606  }
1607  return matchIntrinsicType(EltTy, Infos, ArgTys, DeferredChecks,
1608  IsDeferredCheck);
1609  }
1611  if (D.getArgumentNumber() >= ArgTys.size())
1612  return IsDeferredCheck || DeferCheck(Ty);
1613  Type * ReferenceType = ArgTys[D.getArgumentNumber()];
1614  PointerType *ThisArgType = dyn_cast<PointerType>(Ty);
1615  return (!ThisArgType ||
1617  }
1618  case IITDescriptor::PtrToElt: {
1619  if (D.getArgumentNumber() >= ArgTys.size())
1620  return IsDeferredCheck || DeferCheck(Ty);
1622  dyn_cast<VectorType> (ArgTys[D.getArgumentNumber()]);
1623  PointerType *ThisArgType = dyn_cast<PointerType>(Ty);
1624 
1625  if (!ThisArgType || !ReferenceType)
1626  return true;
1627  return !ThisArgType->isOpaqueOrPointeeTypeMatches(
1628  ReferenceType->getElementType());
1629  }
1631  unsigned RefArgNumber = D.getRefArgNumber();
1632  if (RefArgNumber >= ArgTys.size()) {
1633  if (IsDeferredCheck)
1634  return true;
1635  // If forward referencing, already add the pointer type and
1636  // defer the checks for later.
1637  ArgTys.push_back(Ty);
1638  return DeferCheck(Ty);
1639  }
1640 
1641  if (!IsDeferredCheck) {
1642  assert(D.getOverloadArgNumber() == ArgTys.size() &&
1643  "Table consistency error");
1644  ArgTys.push_back(Ty);
1645  }
1646 
1647  auto *ReferenceType = dyn_cast<VectorType>(ArgTys[RefArgNumber]);
1648  auto *ThisArgType = dyn_cast<PointerType>(Ty);
1649  if (!ThisArgType || !ReferenceType)
1650  return true;
1651  return !ThisArgType->isOpaqueOrPointeeTypeMatches(
1652  ReferenceType->getElementType());
1653  }
1655  unsigned RefArgNumber = D.getRefArgNumber();
1656  if (RefArgNumber >= ArgTys.size()) {
1657  if (IsDeferredCheck)
1658  return true;
1659  // If forward referencing, already add the pointer-vector type and
1660  // defer the checks for later.
1661  ArgTys.push_back(Ty);
1662  return DeferCheck(Ty);
1663  }
1664 
1665  if (!IsDeferredCheck){
1666  assert(D.getOverloadArgNumber() == ArgTys.size() &&
1667  "Table consistency error");
1668  ArgTys.push_back(Ty);
1669  }
1670 
1671  // Verify the overloaded type "matches" the Ref type.
1672  // i.e. Ty is a vector with the same width as Ref.
1673  // Composed of pointers to the same element type as Ref.
1674  auto *ReferenceType = dyn_cast<VectorType>(ArgTys[RefArgNumber]);
1675  auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
1676  if (!ThisArgVecTy || !ReferenceType ||
1677  (ReferenceType->getElementCount() != ThisArgVecTy->getElementCount()))
1678  return true;
1679  PointerType *ThisArgEltTy =
1680  dyn_cast<PointerType>(ThisArgVecTy->getElementType());
1681  if (!ThisArgEltTy)
1682  return true;
1683  return !ThisArgEltTy->isOpaqueOrPointeeTypeMatches(
1684  ReferenceType->getElementType());
1685  }
1687  if (D.getArgumentNumber() >= ArgTys.size())
1688  return IsDeferredCheck ? true : DeferCheck(Ty);
1689  auto *ReferenceType = dyn_cast<VectorType>(ArgTys[D.getArgumentNumber()]);
1690  return !ReferenceType || Ty != ReferenceType->getElementType();
1691  }
1694  // If this is a forward reference, defer the check for later.
1695  if (D.getArgumentNumber() >= ArgTys.size())
1696  return IsDeferredCheck || DeferCheck(Ty);
1697 
1698  Type *NewTy = ArgTys[D.getArgumentNumber()];
1699  if (auto *VTy = dyn_cast<VectorType>(NewTy)) {
1700  int SubDivs = D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
1701  NewTy = VectorType::getSubdividedVectorType(VTy, SubDivs);
1702  return Ty != NewTy;
1703  }
1704  return true;
1705  }
1707  if (D.getArgumentNumber() >= ArgTys.size())
1708  return IsDeferredCheck || DeferCheck(Ty);
1709  auto *ReferenceType = dyn_cast<VectorType>(ArgTys[D.getArgumentNumber()]);
1710  auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
1711  if (!ThisArgVecTy || !ReferenceType)
1712  return true;
1713  return ThisArgVecTy != VectorType::getInteger(ReferenceType);
1714  }
1715  }
1716  llvm_unreachable("unhandled");
1717 }
1718 
1722  SmallVectorImpl<Type *> &ArgTys) {
1724  if (matchIntrinsicType(FTy->getReturnType(), Infos, ArgTys, DeferredChecks,
1725  false))
1727 
1728  unsigned NumDeferredReturnChecks = DeferredChecks.size();
1729 
1730  for (auto *Ty : FTy->params())
1731  if (matchIntrinsicType(Ty, Infos, ArgTys, DeferredChecks, false))
1733 
1734  for (unsigned I = 0, E = DeferredChecks.size(); I != E; ++I) {
1735  DeferredIntrinsicMatchPair &Check = DeferredChecks[I];
1736  if (matchIntrinsicType(Check.first, Check.second, ArgTys, DeferredChecks,
1737  true))
1738  return I < NumDeferredReturnChecks ? MatchIntrinsicTypes_NoMatchRet
1740  }
1741 
1743 }
1744 
1745 bool
1748  // If there are no descriptors left, then it can't be a vararg.
1749  if (Infos.empty())
1750  return isVarArg;
1751 
1752  // There should be only one descriptor remaining at this point.
1753  if (Infos.size() != 1)
1754  return true;
1755 
1756  // Check and verify the descriptor.
1757  IITDescriptor D = Infos.front();
1758  Infos = Infos.slice(1);
1759  if (D.Kind == IITDescriptor::VarArg)
1760  return !isVarArg;
1761 
1762  return true;
1763 }
1764 
1766  SmallVectorImpl<Type *> &ArgTys) {
1767  Intrinsic::ID ID = F->getIntrinsicID();
1768  if (!ID)
1769  return false;
1770 
1774 
1775  if (Intrinsic::matchIntrinsicSignature(F->getFunctionType(), TableRef,
1776  ArgTys) !=
1778  return false;
1779  }
1780  if (Intrinsic::matchIntrinsicVarArg(F->getFunctionType()->isVarArg(),
1781  TableRef))
1782  return false;
1783  return true;
1784 }
1785 
1787  SmallVector<Type *, 4> ArgTys;
1788  if (!getIntrinsicSignature(F, ArgTys))
1789  return None;
1790 
1791  Intrinsic::ID ID = F->getIntrinsicID();
1792  StringRef Name = F->getName();
1793  std::string WantedName =
1794  Intrinsic::getName(ID, ArgTys, F->getParent(), F->getFunctionType());
1795  if (Name == WantedName)
1796  return None;
1797 
1798  Function *NewDecl = [&] {
1799  if (auto *ExistingGV = F->getParent()->getNamedValue(WantedName)) {
1800  if (auto *ExistingF = dyn_cast<Function>(ExistingGV))
1801  if (ExistingF->getFunctionType() == F->getFunctionType())
1802  return ExistingF;
1803 
1804  // The name already exists, but is not a function or has the wrong
1805  // prototype. Make place for the new one by renaming the old version.
1806  // Either this old version will be removed later on or the module is
1807  // invalid and we'll get an error.
1808  ExistingGV->setName(WantedName + ".renamed");
1809  }
1810  return Intrinsic::getDeclaration(F->getParent(), ID, ArgTys);
1811  }();
1812 
1813  NewDecl->setCallingConv(F->getCallingConv());
1814  assert(NewDecl->getFunctionType() == F->getFunctionType() &&
1815  "Shouldn't change the signature");
1816  return NewDecl;
1817 }
1818 
1819 /// hasAddressTaken - returns true if there are any uses of this function
1820 /// other than direct calls or invokes to it. Optionally ignores callback
1821 /// uses, assume like pointer annotation calls, and references in llvm.used
1822 /// and llvm.compiler.used variables.
1823 bool Function::hasAddressTaken(const User **PutOffender,
1824  bool IgnoreCallbackUses,
1825  bool IgnoreAssumeLikeCalls, bool IgnoreLLVMUsed,
1826  bool IgnoreARCAttachedCall) const {
1827  for (const Use &U : uses()) {
1828  const User *FU = U.getUser();
1829  if (isa<BlockAddress>(FU))
1830  continue;
1831 
1832  if (IgnoreCallbackUses) {
1833  AbstractCallSite ACS(&U);
1834  if (ACS && ACS.isCallbackCall())
1835  continue;
1836  }
1837 
1838  const auto *Call = dyn_cast<CallBase>(FU);
1839  if (!Call) {
1840  if (IgnoreAssumeLikeCalls) {
1841  if (const auto *FI = dyn_cast<Instruction>(FU)) {
1842  if (FI->isCast() && !FI->user_empty() &&
1843  llvm::all_of(FU->users(), [](const User *U) {
1844  if (const auto *I = dyn_cast<IntrinsicInst>(U))
1845  return I->isAssumeLikeIntrinsic();
1846  return false;
1847  }))
1848  continue;
1849  }
1850  }
1851  if (IgnoreLLVMUsed && !FU->user_empty()) {
1852  const User *FUU = FU;
1853  if (isa<BitCastOperator>(FU) && FU->hasOneUse() &&
1854  !FU->user_begin()->user_empty())
1855  FUU = *FU->user_begin();
1856  if (llvm::all_of(FUU->users(), [](const User *U) {
1857  if (const auto *GV = dyn_cast<GlobalVariable>(U))
1858  return GV->hasName() &&
1859  (GV->getName().equals("llvm.compiler.used") ||
1860  GV->getName().equals("llvm.used"));
1861  return false;
1862  }))
1863  continue;
1864  }
1865  if (PutOffender)
1866  *PutOffender = FU;
1867  return true;
1868  }
1869  if (!Call->isCallee(&U) || Call->getFunctionType() != getFunctionType()) {
1870  if (IgnoreARCAttachedCall &&
1871  Call->isOperandBundleOfType(LLVMContext::OB_clang_arc_attachedcall,
1872  U.getOperandNo()))
1873  continue;
1874 
1875  if (PutOffender)
1876  *PutOffender = FU;
1877  return true;
1878  }
1879  }
1880  return false;
1881 }
1882 
1884  // Check the linkage
1885  if (!hasLinkOnceLinkage() && !hasLocalLinkage() &&
1887  return false;
1888 
1889  // Check if the function is used by anything other than a blockaddress.
1890  for (const User *U : users())
1891  if (!isa<BlockAddress>(U))
1892  return false;
1893 
1894  return true;
1895 }
1896 
1897 /// callsFunctionThatReturnsTwice - Return true if the function has a call to
1898 /// setjmp or other function that gcc recognizes as "returning twice".
1900  for (const Instruction &I : instructions(this))
1901  if (const auto *Call = dyn_cast<CallBase>(&I))
1902  if (Call->hasFnAttr(Attribute::ReturnsTwice))
1903  return true;
1904 
1905  return false;
1906 }
1907 
1910  return cast<Constant>(Op<0>());
1911 }
1912 
1914  setHungoffOperand<0>(Fn);
1915  setValueSubclassDataBit(3, Fn != nullptr);
1916 }
1917 
1920  return cast<Constant>(Op<1>());
1921 }
1922 
1924  setHungoffOperand<1>(PrefixData);
1925  setValueSubclassDataBit(1, PrefixData != nullptr);
1926 }
1927 
1930  return cast<Constant>(Op<2>());
1931 }
1932 
1934  setHungoffOperand<2>(PrologueData);
1935  setValueSubclassDataBit(2, PrologueData != nullptr);
1936 }
1937 
1938 void Function::allocHungoffUselist() {
1939  // If we've already allocated a uselist, stop here.
1940  if (getNumOperands())
1941  return;
1942 
1943  allocHungoffUses(3, /*IsPhi=*/ false);
1945 
1946  // Initialize the uselist with placeholder operands to allow traversal.
1948  Op<0>().set(CPN);
1949  Op<1>().set(CPN);
1950  Op<2>().set(CPN);
1951 }
1952 
1953 template <int Idx>
1954 void Function::setHungoffOperand(Constant *C) {
1955  if (C) {
1956  allocHungoffUselist();
1957  Op<Idx>().set(C);
1958  } else if (getNumOperands()) {
1959  Op<Idx>().set(
1961  }
1962 }
1963 
1964 void Function::setValueSubclassDataBit(unsigned Bit, bool On) {
1965  assert(Bit < 16 && "SubclassData contains only 16 bits");
1966  if (On)
1967  setValueSubclassData(getSubclassDataFromValue() | (1 << Bit));
1968  else
1969  setValueSubclassData(getSubclassDataFromValue() & ~(1 << Bit));
1970 }
1971 
1973  const DenseSet<GlobalValue::GUID> *S) {
1974 #if !defined(NDEBUG)
1975  auto PrevCount = getEntryCount();
1976  assert(!PrevCount || PrevCount->getType() == Count.getType());
1977 #endif
1978 
1979  auto ImportGUIDs = getImportGUIDs();
1980  if (S == nullptr && ImportGUIDs.size())
1981  S = &ImportGUIDs;
1982 
1983  MDBuilder MDB(getContext());
1984  setMetadata(
1985  LLVMContext::MD_prof,
1986  MDB.createFunctionEntryCount(Count.getCount(), Count.isSynthetic(), S));
1987 }
1988 
1990  const DenseSet<GlobalValue::GUID> *Imports) {
1991  setEntryCount(ProfileCount(Count, Type), Imports);
1992 }
1993 
1995  MDNode *MD = getMetadata(LLVMContext::MD_prof);
1996  if (MD && MD->getOperand(0))
1997  if (MDString *MDS = dyn_cast<MDString>(MD->getOperand(0))) {
1998  if (MDS->getString().equals("function_entry_count")) {
1999  ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(1));
2000  uint64_t Count = CI->getValue().getZExtValue();
2001  // A value of -1 is used for SamplePGO when there were no samples.
2002  // Treat this the same as unknown.
2003  if (Count == (uint64_t)-1)
2004  return None;
2005  return ProfileCount(Count, PCT_Real);
2006  } else if (AllowSynthetic &&
2007  MDS->getString().equals("synthetic_function_entry_count")) {
2008  ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(1));
2009  uint64_t Count = CI->getValue().getZExtValue();
2010  return ProfileCount(Count, PCT_Synthetic);
2011  }
2012  }
2013  return None;
2014 }
2015 
2018  if (MDNode *MD = getMetadata(LLVMContext::MD_prof))
2019  if (MDString *MDS = dyn_cast<MDString>(MD->getOperand(0)))
2020  if (MDS->getString().equals("function_entry_count"))
2021  for (unsigned i = 2; i < MD->getNumOperands(); i++)
2022  R.insert(mdconst::extract<ConstantInt>(MD->getOperand(i))
2023  ->getValue()
2024  .getZExtValue());
2025  return R;
2026 }
2027 
2029  MDBuilder MDB(getContext());
2030  setMetadata(LLVMContext::MD_section_prefix,
2032 }
2033 
2035  if (MDNode *MD = getMetadata(LLVMContext::MD_section_prefix)) {
2036  assert(cast<MDString>(MD->getOperand(0))
2037  ->getString()
2038  .equals("function_section_prefix") &&
2039  "Metadata not match");
2040  return cast<MDString>(MD->getOperand(1))->getString();
2041  }
2042  return None;
2043 }
2044 
2046  return hasFnAttribute(Attribute::NullPointerIsValid);
2047 }
2048 
2049 bool llvm::NullPointerIsDefined(const Function *F, unsigned AS) {
2050  if (F && F->nullPointerIsDefined())
2051  return true;
2052 
2053  if (AS != 0)
2054  return true;
2055 
2056  return false;
2057 }
llvm::Function::getParamAttribute
Attribute getParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
gets the specified attribute from the list of attributes.
Definition: Function.cpp:663
llvm::AttributeList::removeAttributeAtIndex
AttributeList removeAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
Definition: Attributes.cpp:1292
llvm::Intrinsic::getBaseName
StringRef getBaseName(ID id)
Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm....
Definition: Function.cpp:877
i
i
Definition: README.txt:29
llvm::Intrinsic::IITDescriptor::AK_AnyVector
@ AK_AnyVector
Definition: Intrinsics.h:161
llvm::Intrinsic::IITDescriptor::Subdivide4Argument
@ Subdivide4Argument
Definition: Intrinsics.h:141
IIT_STRUCT2
@ IIT_STRUCT2
Definition: Function.cpp:955
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition: Argument.h:28
IIT_AMX
@ IIT_AMX
Definition: Function.cpp:985
llvm::Intrinsic::remangleIntrinsicFunction
llvm::Optional< Function * > remangleIntrinsicFunction(Function *F)
Definition: Function.cpp:1786
llvm::Argument::hasStructRetAttr
bool hasStructRetAttr() const
Return true if this argument has the sret attribute.
Definition: Function.cpp:257
IIT_SUBDIVIDE4_ARG
@ IIT_SUBDIVIDE4_ARG
Definition: Function.cpp:979
llvm::Type::FloatTyID
@ FloatTyID
32-bit floating point type
Definition: Type.h:58
Attrs
Function Attrs
Definition: README_ALTIVEC.txt:215
IIT_V128
@ IIT_V128
Definition: Function.cpp:981
IIT_F32
@ IIT_F32
Definition: Function.cpp:939
llvm::Intrinsic::isOverloaded
bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
Definition: Function.cpp:1398
getName
static StringRef getName(Value *V)
Definition: ProvenanceAnalysisEvaluator.cpp:42
llvm::VectorType::getSubdividedVectorType
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
Definition: DerivedTypes.h:483
llvm::Argument::hasInAllocaAttr
bool hasInAllocaAttr() const
Return true if this argument has the inalloca attribute.
Definition: Function.cpp:128
llvm::Type::DoubleTyID
@ DoubleTyID
64-bit floating point type
Definition: Type.h:59
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::Argument::hasPassPointeeByValueCopyAttr
bool hasPassPointeeByValueCopyAttr() const
Return true if this argument has the byval, inalloca, or preallocated attribute.
Definition: Function.cpp:139
llvm::Intrinsic::MatchIntrinsicTypes_NoMatchArg
@ MatchIntrinsicTypes_NoMatchArg
Definition: Intrinsics.h:222
llvm::AttributeList::addDereferenceableParamAttr
AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
Definition: Attributes.cpp:1351
llvm::Intrinsic::IITDescriptor::VecOfBitcastsToInt
@ VecOfBitcastsToInt
Definition: Intrinsics.h:142
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::AArch64CC::AL
@ AL
Definition: AArch64BaseInfo.h:269
IIT_EXTEND_ARG
@ IIT_EXTEND_ARG
Definition: Function.cpp:959
llvm::StructType::get
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Definition: Type.cpp:406
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
llvm::Value::hasOneUse
bool hasOneUse() const
Return true if there is exactly one use of this value.
Definition: Value.h:434
llvm::Intrinsic::IITDescriptor::Kind
enum llvm::Intrinsic::IITDescriptor::IITDescriptorKind Kind
llvm::Intrinsic::getDeclaration
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Definition: Function.cpp:1421
Metadata.h
llvm::Type::isX86_MMXTy
bool isX86_MMXTy() const
Return true if this is X86 MMX.
Definition: Type.h:178
llvm::Function::setSectionPrefix
void setSectionPrefix(StringRef Prefix)
Set the section prefix for this function.
Definition: Function.cpp:2028
llvm::Function::clearGC
void clearGC()
Definition: Function.cpp:699
llvm::Type::getFP128Ty
static Type * getFP128Ty(LLVMContext &C)
Definition: Type.cpp:231
IntrinsicInst.h
llvm::Function::getPrefixData
Constant * getPrefixData() const
Get the prefix data associated with this function.
Definition: Function.cpp:1918
llvm::ElementCount
Definition: TypeSize.h:404
llvm::Intrinsic::IITDescriptor::BFloat
@ BFloat
Definition: Intrinsics.h:123
llvm::APFloatBase::IEEEsingle
static const fltSemantics & IEEEsingle() LLVM_READNONE
Definition: APFloat.cpp:170
llvm::Argument::removeAttrs
void removeAttrs(const AttributeMask &AM)
Definition: Function.cpp:302
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:160
IIT_ANYPTR_TO_ELT
@ IIT_ANYPTR_TO_ELT
Definition: Function.cpp:990
InstIterator.h
ReferenceType
Definition: ItaniumDemangle.h:637
llvm::Function::removeFnAttrs
void removeFnAttrs(const AttributeMask &Attrs)
Definition: Function.cpp:594
T
llvm::Function
Definition: Function.h:60
IIT_EXTERNREF
@ IIT_EXTERNREF
Definition: Function.cpp:988
llvm::Attribute
Definition: Attributes.h:65
llvm::Type::VoidTyID
@ VoidTyID
type with no size
Definition: Type.h:63
StringRef.h
llvm::Value::getSubclassDataFromValue
unsigned short getSubclassDataFromValue() const
Definition: Value.h:852
DecodeFixedType
static Type * DecodeFixedType(ArrayRef< Intrinsic::IITDescriptor > &Infos, ArrayRef< Type * > Tys, LLVMContext &Context)
Definition: Function.cpp:1272
llvm::Function::getParamDereferenceableBytes
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Extract the number of dereferenceable bytes for a parameter.
Definition: Function.h:476
llvm::Intrinsic::IITDescriptor::VarArg
@ VarArg
Definition: Intrinsics.h:118
llvm::PointerType::get
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
Definition: Type.cpp:727
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:145
llvm::AttributeList::addFnAttributes
AttributeList addFnAttributes(LLVMContext &C, const AttrBuilder &B) const
Add function attribute to the list.
Definition: Attributes.h:534
llvm::Function::eraseFromParent
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition: Function.cpp:367
llvm::ConstantInt::getValue
const APInt & getValue() const
Return the constant as an APInt value reference.
Definition: Constants.h:133
llvm::Argument::hasPointeeInMemoryValueAttr
bool hasPointeeInMemoryValueAttr() const
Return true if this argument has the byval, sret, inalloca, preallocated, or byref attribute.
Definition: Function.cpp:147
llvm::SmallVector< unsigned char, 8 >
llvm::Intrinsic::IITDescriptor::Quad
@ Quad
Definition: Intrinsics.h:126
llvm::UWTableKind::None
@ None
No unwind table requested.
llvm::Function::getParamByValType
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a parameter.
Definition: Function.h:450
llvm::User::dropAllReferences
void dropAllReferences()
Drop all references to operands.
Definition: User.h:299
llvm::Function::hasParamAttribute
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
Definition: Function.cpp:640
ErrorHandling.h
IIT_I4
@ IIT_I4
Definition: Function.cpp:992
makeArgArray
static MutableArrayRef< Argument > makeArgArray(Argument *Args, size_t Count)
Definition: Function.cpp:442
llvm::Intrinsic::getName
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Definition: Function.cpp:882
llvm::Intrinsic::IITDescriptor::MMX
@ MMX
Definition: Intrinsics.h:119
llvm::PointerType::getAddressSpace
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:682
llvm::Type::X86_AMXTyID
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
Definition: Type.h:67
llvm::FunctionType::get
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Definition: Type.cpp:361
llvm::Intrinsic::IITDescriptor::AnyPtrToElt
@ AnyPtrToElt
Definition: Intrinsics.h:145
IIT_I1
@ IIT_I1
Definition: Function.cpp:933
llvm::Type::getTypeID
TypeID getTypeID() const
Return the type id for the type.
Definition: Type.h:136
llvm::Argument::getParamInAllocaType
Type * getParamInAllocaType() const
If this is an inalloca argument, return its type.
Definition: Function.cpp:220
IIT_V8
@ IIT_V8
Definition: Function.cpp:943
llvm::Type::isFPOrFPVectorTy
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Definition: Type.h:184
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
llvm::Intrinsic::IITDescriptor::Metadata
@ Metadata
Definition: Intrinsics.h:121
llvm::Intrinsic::IITDescriptor::PtrToArgument
@ PtrToArgument
Definition: Intrinsics.h:136
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1877
llvm::Function::getContext
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition: Function.cpp:320
llvm::Function::arg_size
size_t arg_size() const
Definition: Function.h:774
llvm::Argument::getParamAlignment
uint64_t getParamAlignment() const
If this is a byval or inalloca argument, return its alignment.
Definition: Function.cpp:191
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Function::addRetAttr
void addRetAttr(Attribute::AttrKind Kind)
Add return value attributes to this function.
Definition: Function.cpp:554
llvm::AttributeList::removeParamAttributes
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:682
llvm::Intrinsic::lookupLLVMIntrinsicByName
int lookupLLVMIntrinsicByName(ArrayRef< const char * > NameTable, StringRef Name)
Looks up Name in NameTable via binary search.
Definition: IntrinsicInst.cpp:175
Module.h
llvm::AttributeList
Definition: Attributes.h:425
llvm::AttributeMask
Definition: Attributes.h:969
llvm::Type::getTokenTy
static Type * getTokenTy(LLVMContext &C)
Definition: Type.cpp:229
llvm::Argument::getArgNo
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
Definition: Argument.h:46
llvm::Argument::hasInRegAttr
bool hasInRegAttr() const
Return true if this argument has the inreg attribute.
Definition: Function.cpp:262
llvm::Function::addParamAttrs
void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs)
adds the attributes to the list of attributes for the given arg.
Definition: Function.cpp:574
llvm::Optional
Definition: APInt.h:33
llvm::Argument::getParent
const Function * getParent() const
Definition: Argument.h:40
llvm::Intrinsic::getAttributes
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
Operator.h
llvm::VectorType::getElementType
Type * getElementType() const
Definition: DerivedTypes.h:422
llvm::Value::user_begin
user_iterator user_begin()
Definition: Value.h:397
llvm::Intrinsic::IITDescriptor::ExtendArgument
@ ExtendArgument
Definition: Intrinsics.h:132
getBitWidth
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
Definition: ValueTracking.cpp:98
llvm::Function::hasStackProtectorFnAttr
bool hasStackProtectorFnAttr() const
Returns true if the function has ssp, sspstrong, or sspreq fn attrs.
Definition: Function.cpp:706
llvm::FunctionType::getNumParams
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Definition: DerivedTypes.h:139
llvm::Function::ProfileCount::isSynthetic
bool isSynthetic() const
Definition: Function.h:263
llvm::Function::hasRetAttribute
bool hasRetAttribute(Attribute::AttrKind Kind) const
check if an attribute is in the list of attributes for the return value.
Definition: Function.cpp:636
llvm::Intrinsic::not_intrinsic
@ not_intrinsic
Definition: Intrinsics.h:45
llvm::Intrinsic::IITDescriptor::Pointer
@ Pointer
Definition: Intrinsics.h:129
STLExtras.h
llvm::AbstractCallSite
AbstractCallSite.
Definition: AbstractCallSite.h:50
llvm::Intrinsic::IITDescriptor::AK_Any
@ AK_Any
Definition: Intrinsics.h:158
llvm::Function::isDefTriviallyDead
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
Definition: Function.cpp:1883
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
llvm::ArrayType
Class to represent array types.
Definition: DerivedTypes.h:357
IIT_V1
@ IIT_V1
Definition: Function.cpp:962
llvm::Argument::hasSwiftSelfAttr
bool hasSwiftSelfAttr() const
Return true if this argument has the swiftself attribute.
Definition: Function.cpp:120
llvm::Intrinsic::IITDescriptor::Void
@ Void
Definition: Intrinsics.h:117
IIT_METADATA
@ IIT_METADATA
Definition: Function.cpp:953
llvm::Type::getNonOpaquePointerElementType
Type * getNonOpaquePointerElementType() const
Only use this method in code that is not reachable with opaque pointers, or part of deprecated method...
Definition: Type.h:387
llvm::Type::isMetadataTy
bool isMetadataTy() const
Return true if this is 'metadata'.
Definition: Type.h:190
Use.h
llvm::Intrinsic::IITDescriptor::AK_MatchType
@ AK_MatchType
Definition: Intrinsics.h:163
llvm::Intrinsic::getIntrinsicSignature
bool getIntrinsicSignature(Function *F, SmallVectorImpl< Type * > &ArgTys)
Gets the type arguments of an intrinsic call by matching type contraints specified by the ....
Definition: Function.cpp:1765
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:159
llvm::ArrayRef::data
const T * data() const
Definition: ArrayRef.h:161
llvm::AttributeList::removeFnAttributes
AttributeList removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:632
llvm::Function::addAttributeAtIndex
void addAttributeAtIndex(unsigned i, Attribute Attr)
adds the attribute to the list of attributes.
Definition: Function.cpp:534
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::Intrinsic::IITDescriptor::Float
@ Float
Definition: Intrinsics.h:124
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::Function::addFnAttrs
void addFnAttrs(const AttrBuilder &Attrs)
Add function attributes to this function.
Definition: Function.cpp:550
llvm::Intrinsic::MatchIntrinsicTypes_NoMatchRet
@ MatchIntrinsicTypes_NoMatchRet
Definition: Intrinsics.h:221
llvm::parseDenormalFPAttribute
DenormalMode parseDenormalFPAttribute(StringRef Str)
Returns the denormal mode to use for inputs and outputs.
Definition: FloatingPointMode.h:176
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::Intrinsic::IITDescriptor::AK_AnyPointer
@ AK_AnyPointer
Definition: Intrinsics.h:162
llvm::Function::setGC
void setGC(std::string Str)
Definition: Function.cpp:694
Instruction.h
CommandLine.h
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition: Constants.h:79
llvm::PointerType::isOpaqueOrPointeeTypeMatches
bool isOpaqueOrPointeeTypeMatches(Type *Ty)
Return true if either this is an opaque pointer type or if this pointee type matches Ty.
Definition: DerivedTypes.h:688
llvm::Type::getMetadataTy
static Type * getMetadataTy(LLVMContext &C)
Definition: Type.cpp:228
llvm::Intrinsic::getType
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
Definition: Function.cpp:1377
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1590
llvm::UWTableKind
UWTableKind
Definition: CodeGen.h:100
llvm::Type::MetadataTyID
@ MetadataTyID
Metadata.
Definition: Type.h:65
llvm::VectorType::getTruncatedElementVectorType
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
Definition: DerivedTypes.h:458
llvm::Type::getX86_AMXTy
static Type * getX86_AMXTy(LLVMContext &C)
Definition: Type.cpp:234
GlobalValue.h
llvm::OperandTraits
Compile-time customization of User operands.
Definition: User.h:42
llvm::AttributeList::addParamAttributes
AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
Definition: Attributes.h:584
getMemoryParamAllocType
static Type * getMemoryParamAllocType(AttributeSet ParamAttrs)
For a byval, sret, inalloca, or preallocated parameter, get the in-memory parameter type.
Definition: Function.cpp:160
llvm::Function::PCT_Synthetic
@ PCT_Synthetic
Definition: Function.h:248
llvm::GlobalValue::isDeclaration
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:271
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:28
llvm::StringRef::startswith
bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:256
llvm::Argument::hasZExtAttr
bool hasZExtAttr() const
Return true if this argument has the zext attribute.
Definition: Function.cpp:270
llvm::Argument::getParamStackAlign
MaybeAlign getParamStackAlign() const
Definition: Function.cpp:201
Constants.h
llvm::Function::stealArgumentListFrom
void stealArgumentListFrom(Function &Src)
Steal arguments from another function.
Definition: Function.cpp:467
llvm::Intrinsic::IITDescriptor::Struct_NumElements
unsigned Struct_NumElements
Definition: Intrinsics.h:152
IIT_BF16
@ IIT_BF16
Definition: Function.cpp:982
IIT_VEC_OF_BITCASTS_TO_INT
@ IIT_VEC_OF_BITCASTS_TO_INT
Definition: Function.cpp:980
SmallString.h
llvm::Type::getPPC_FP128Ty
static Type * getPPC_FP128Ty(LLVMContext &C)
Definition: Type.cpp:232
llvm::AttributeList::removeFnAttribute
AttributeList removeFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:618
llvm::Intrinsic::IITDescriptor::Double
@ Double
Definition: Intrinsics.h:125
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::User
Definition: User.h:44
llvm::Intrinsic::IITDescriptor::SameVecWidthArgument
@ SameVecWidthArgument
Definition: Intrinsics.h:135
DecodeIITType
static void DecodeIITType(unsigned &NextElt, ArrayRef< unsigned char > Infos, IIT_Info LastInfo, SmallVectorImpl< Intrinsic::IITDescriptor > &OutputTable)
Definition: Function.cpp:995
Intrinsics.h
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::Type::getDoubleTy
static Type * getDoubleTy(LLVMContext &C)
Definition: Type.cpp:227
llvm::GlobalObject
Definition: GlobalObject.h:27
llvm::Intrinsic::IITDescriptor::HalfVecArgument
@ HalfVecArgument
Definition: Intrinsics.h:134
llvm::Argument::hasSwiftErrorAttr
bool hasSwiftErrorAttr() const
Return true if this argument has the swifterror attribute.
Definition: Function.cpp:124
IIT_V16
@ IIT_V16
Definition: Function.cpp:944
llvm::VectorType::getInteger
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
Definition: DerivedTypes.h:440
IIT_Info
IIT_Info
IIT_Info - These are enumerators that describe the entries returned by the getIntrinsicInfoTableEntri...
Definition: Function.cpp:930
llvm::Argument::hasNoCaptureAttr
bool hasNoCaptureAttr() const
Return true if this argument has the nocapture attribute.
Definition: Function.cpp:247
IIT_STRUCT9
@ IIT_STRUCT9
Definition: Function.cpp:983
SymbolTableListTraitsImpl.h
Check
#define Check(C,...)
Definition: Lint.cpp:170
llvm::Function::removeRetAttrs
void removeRetAttrs(const AttributeMask &Attrs)
removes the attributes from the return value list of attributes.
Definition: Function.cpp:606
llvm::Value::uses
iterator_range< use_iterator > uses()
Definition: Value.h:376
DenseSet.h
llvm::VectorType::getElementCount
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Definition: DerivedTypes.h:627
llvm::Function::removeRetAttr
void removeRetAttr(Attribute::AttrKind Kind)
removes the attribute from the return value list of attributes.
Definition: Function.cpp:598
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::Function::getFnAttribute
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Definition: Function.cpp:654
llvm::IntegerType
Class to represent integer types.
Definition: DerivedTypes.h:40
llvm::Argument::getDereferenceableBytes
uint64_t getDereferenceableBytes() const
If this argument has the dereferenceable attribute, return the number of bytes known to be dereferenc...
Definition: Function.cpp:225
IIT_Done
@ IIT_Done
Definition: Function.cpp:932
llvm::Type::isTokenTy
bool isTokenTy() const
Return true if this is 'token'.
Definition: Type.h:193
llvm::Instruction
Definition: Instruction.h:42
llvm::AttributeList::hasFnAttr
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
Definition: Attributes.cpp:1405
llvm::LLVMContext::getGC
const std::string & getGC(const Function &Fn)
Return the GC for a function.
Definition: LLVMContext.cpp:328
MDBuilder.h
llvm::APInt::getZExtValue
uint64_t getZExtValue() const
Get zero extended value.
Definition: APInt.h:1466
llvm::Function::copyAttributesFrom
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
Definition: Function.cpp:714
llvm::Function::removeParamAttr
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
Definition: Function.cpp:610
llvm::Value::setName
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:375
llvm::Function::hasPersonalityFn
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition: Function.h:778
llvm::AttributeSet::getInAllocaType
Type * getInAllocaType() const
Definition: Attributes.cpp:738
llvm::FunctionType::params
ArrayRef< Type * > params() const
Definition: DerivedTypes.h:130
llvm::Argument::getAttribute
Attribute getAttribute(Attribute::AttrKind Kind) const
Definition: Function.cpp:312
IIT_V1024
@ IIT_V1024
Definition: Function.cpp:971
IIT_V64
@ IIT_V64
Definition: Function.cpp:950
llvm::Function::PCT_Real
@ PCT_Real
Definition: Function.h:248
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::Intrinsic::IITDescriptor::PPCQuad
@ PPCQuad
Definition: Intrinsics.h:144
llvm::Argument::hasNestAttr
bool hasNestAttr() const
Return true if this argument has the nest attribute.
Definition: Function.cpp:237
llvm::AttributeList::addDereferenceableOrNullParamAttr
AttributeList addDereferenceableOrNullParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given arg index.
Definition: Attributes.cpp:1360
llvm::Type::getInt1PtrTy
static PointerType * getInt1PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:287
llvm::Function::getSectionPrefix
Optional< StringRef > getSectionPrefix() const
Get the section prefix for this function.
Definition: Function.cpp:2034
llvm::PointerType::isOpaque
bool isOpaque() const
Definition: DerivedTypes.h:673
getMangledTypeStr
static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType)
Returns a stable mangling for the type specified for use in the name mangling scheme used by 'any' ty...
Definition: Function.cpp:815
llvm::Type::BFloatTyID
@ BFloatTyID
16-bit floating point type (7-bit significand)
Definition: Type.h:57
llvm::ArrayRef::slice
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Definition: ArrayRef.h:194
llvm::Attribute::getValueAsString
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:304
llvm::None
const NoneType None
Definition: None.h:24
llvm::GlobalValue::IntID
Intrinsic::ID IntID
The intrinsic ID for this subclass (which must be a Function).
Definition: GlobalValue.h:169
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::Function::getParamInAllocaType
Type * getParamInAllocaType(unsigned ArgNo) const
Extract the inalloca type for a parameter.
Definition: Function.h:460
llvm::AttributeList::addParamAttribute
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
Definition: Attributes.h:563
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
Type.h
llvm::Argument::hasByRefAttr
bool hasByRefAttr() const
Return true if this argument has the byref attribute.
Definition: Function.cpp:114
IIT_PPCF128
@ IIT_PPCF128
Definition: Function.cpp:986
llvm::Function::hasPrologueData
bool hasPrologueData() const
Check whether this function has prologue data.
Definition: Function.h:796
llvm::SmallString< 128 >
llvm::Intrinsic::IITDescriptor::TruncArgument
@ TruncArgument
Definition: Intrinsics.h:133
ValueSymbolTable.h
llvm::AttributeList::removeRetAttributes
AttributeList removeRetAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:659
llvm::Function::getAttributes
AttributeList getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:314
llvm::Argument::getDereferenceableOrNullBytes
uint64_t getDereferenceableOrNullBytes() const
If this argument has the dereferenceable_or_null attribute, return the number of bytes known to be de...
Definition: Function.cpp:231
llvm::Argument::getParamStructRetType
Type * getParamStructRetType() const
If this is an sret argument, return its type.
Definition: Function.cpp:210
llvm::Function::getGC
const std::string & getGC() const
Definition: Function.cpp:689
llvm::Type::isIntegerTy
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:196
llvm::MDNode::getOperand
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:1292
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
llvm::Intrinsic::MatchIntrinsicTypes_Match
@ MatchIntrinsicTypes_Match
Definition: Intrinsics.h:220
llvm::Argument::hasAttribute
bool hasAttribute(Attribute::AttrKind Kind) const
Check if an argument has a given attribute.
Definition: Function.cpp:308
llvm::VectorType
Base class of all SIMD vector types.
Definition: DerivedTypes.h:389
getIntrinsicNameImpl
static std::string getIntrinsicNameImpl(Intrinsic::ID Id, ArrayRef< Type * > Tys, Module *M, FunctionType *FT, bool EarlyModuleCheck)
Definition: Function.cpp:889
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
IIT_F128
@ IIT_F128
Definition: Function.cpp:975
llvm::Intrinsic::IITDescriptor::get
static IITDescriptor get(IITDescriptorKind K, unsigned Field)
Definition: Intrinsics.h:196
llvm::Function::hasFnAttribute
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.cpp:628
BasicBlock.h
llvm::cl::opt
Definition: CommandLine.h:1399
llvm::GlobalValue::hasAvailableExternallyLinkage
bool hasAvailableExternallyLinkage() const
Definition: GlobalValue.h:501
llvm::ProfileCount
Function::ProfileCount ProfileCount
Definition: SampleProfileLoaderBaseImpl.h:47
llvm::Function::getEntryCount
Optional< ProfileCount > getEntryCount(bool AllowSynthetic=false) const
Get the entry count for this function.
Definition: Function.cpp:1994
llvm::instructions
inst_range instructions(Function *F)
Definition: InstIterator.h:133
llvm::Function::getAttributeAtIndex
Attribute getAttributeAtIndex(unsigned i, Attribute::AttrKind Kind) const
gets the attribute from the list of attributes.
Definition: Function.cpp:645
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::PointerType::getUnqual
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Definition: DerivedTypes.h:651
llvm::SymbolTableListTraits
Definition: GlobalAlias.h:26
uint64_t
llvm::Intrinsic::matchIntrinsicVarArg
bool matchIntrinsicVarArg(bool isVarArg, ArrayRef< IITDescriptor > &Infos)
Verify if the intrinsic has variable arguments.
Definition: Function.cpp:1746
llvm::Function::hasPrefixData
bool hasPrefixData() const
Check whether this function has prefix data.
Definition: Function.h:787
llvm::Intrinsic::IITDescriptor::Half
@ Half
Definition: Intrinsics.h:122
llvm::Function::dropAllReferences
void dropAllReferences()
dropAllReferences() - This method causes all the subinstructions to "let go" of all references that t...
Definition: Function.cpp:512
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::User::allocHungoffUses
void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
Definition: User.cpp:50
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:644
llvm::Type::X86_MMXTyID
@ X86_MMXTyID
MMX vectors (64 bits, X86 specific)
Definition: Type.h:66
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
llvm::AttributeList::addRetAttribute
AttributeList addRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a return value attribute to the list.
Definition: Attributes.h:541
llvm::Function::hasGC
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
Definition: Function.h:306
llvm::ConstantPointerNull::get
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
Definition: Constants.cpp:1694
llvm::Intrinsic::getIntrinsicInfoTableEntries
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
Definition: Function.cpp:1239
IIT_F16
@ IIT_F16
Definition: Function.cpp:938
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
IIT_FUNCREF
@ IIT_FUNCREF
Definition: Function.cpp:989
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
ProfileCount
Function::ProfileCount ProfileCount
Definition: Function.cpp:73
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:54
IIT_STRUCT4
@ IIT_STRUCT4
Definition: Function.cpp:957
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::AttrBuilder
Definition: Attributes.h:1030
StringExtras.h
IIT_I8
@ IIT_I8
Definition: Function.cpp:934
llvm::Function::addDereferenceableOrNullParamAttr
void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes for the given arg.
Definition: Function.cpp:668
llvm::Intrinsic::IITDescriptor::AK_AnyInteger
@ AK_AnyInteger
Definition: Intrinsics.h:159
llvm::DenormalMode
Represent subnormal handling kind for floating point instruction inputs and outputs.
Definition: FloatingPointMode.h:69
llvm::Attribute::AttrKind
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:84
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:439
llvm::LLVMContext::setGC
void setGC(const Function &Fn, std::string GCName)
Define the GC for a function.
Definition: LLVMContext.cpp:318
llvm::Argument::hasNoFreeAttr
bool hasNoFreeAttr() const
Return true if this argument has the nofree attribute.
Definition: Function.cpp:252
llvm::Intrinsic::IITDescriptor::VecOfAnyPtrsToElt
@ VecOfAnyPtrsToElt
Definition: Intrinsics.h:138
llvm::PointerType
Class to represent pointers.
Definition: DerivedTypes.h:632
ArrayRef.h
llvm::Argument::hasPreallocatedAttr
bool hasPreallocatedAttr() const
Return true if this argument has the preallocated attribute.
Definition: Function.cpp:133
llvm::Type::isHalfTy
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition: Type.h:142
llvm::GlobalValue::Linkage
unsigned Linkage
Definition: GlobalValue.h:94
llvm::Intrinsic::isLeaf
bool isLeaf(ID id)
Returns true if the intrinsic is a leaf, i.e.
Definition: Function.cpp:1404
llvm::Argument::removeAttr
void removeAttr(Attribute::AttrKind Kind)
Remove attributes from an argument.
Definition: Function.cpp:298
llvm::Function::Create
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition: Function.h:137
llvm::Function::ProfileCountType
ProfileCountType
Definition: Function.h:248
llvm::FramePointerKind::All
@ All
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::GlobalValue::hasLocalLinkage
bool hasLocalLinkage() const
Definition: GlobalValue.h:517
llvm::Function::lookupIntrinsicID
static Intrinsic::ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
Definition: Function.cpp:772
IIT_V4
@ IIT_V4
Definition: Function.cpp:942
llvm::Argument::Argument
Argument(Type *Ty, const Twine &Name="", Function *F=nullptr, unsigned ArgNo=0)
Argument constructor.
Definition: Function.cpp:87
NonGlobalValueMaxNameSize
static cl::opt< unsigned > NonGlobalValueMaxNameSize("non-global-value-max-name-size", cl::Hidden, cl::init(1024), cl::desc("Maximum size for the name of non-global values."))
llvm::Value::user_empty
bool user_empty() const
Definition: Value.h:385
llvm::Type::isVoidTy
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:139
llvm::Function::setPersonalityFn
void setPersonalityFn(Constant *Fn)
Definition: Function.cpp:1913
llvm::Intrinsic::IITDescriptor::AMX
@ AMX
Definition: Intrinsics.h:143
DeferredIntrinsicMatchPair
std::pair< Type *, ArrayRef< Intrinsic::IITDescriptor > > DeferredIntrinsicMatchPair
Definition: Function.cpp:1442
IIT_I2
@ IIT_I2
Definition: Function.cpp:991
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::MDNode
Metadata node.
Definition: Metadata.h:944
IIT_ARG
@ IIT_ARG
Definition: Function.cpp:947
IIT_V256
@ IIT_V256
Definition: Function.cpp:984
llvm::Value::clearMetadata
void clearMetadata()
Erase all metadata attached to this Value.
Definition: Metadata.cpp:1383
IIT_VARARG
@ IIT_VARARG
Definition: Function.cpp:963
IIT_I16
@ IIT_I16
Definition: Function.cpp:935
llvm::AbstractCallSite::isCallbackCall
bool isCallbackCall() const
Return true if this ACS represents a callback call.
Definition: AbstractCallSite.h:125
llvm::Intrinsic::IITDescriptor::Argument
@ Argument
Definition: Intrinsics.h:131
IIT_PTR_TO_ELT
@ IIT_PTR_TO_ELT
Definition: Function.cpp:967
getType
static M68kRelType getType(unsigned Kind, MCSymbolRefExpr::VariantKind &Modifier, bool &IsPCRel)
Definition: M68kELFObjectWriter.cpp:48
llvm::Intrinsic::IITDescriptor::Subdivide2Argument
@ Subdivide2Argument
Definition: Intrinsics.h:140
llvm::Type::FP128TyID
@ FP128TyID
128-bit floating point type (112-bit significand)
Definition: Type.h:61
llvm::Function::getIntrinsicID
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Definition: Function.h:205
llvm::Function::createWithDefaultAttr
static Function * createWithDefaultAttr(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Creates a function with some attributes recorded in llvm.module.flags applied.
Definition: Function.cpp:337
llvm::Function::setEntryCount
void setEntryCount(ProfileCount Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
Definition: Function.cpp:1972
llvm::ArrayRef< const char * >
None.h
llvm::any_of
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1597
llvm::StructType
Class to represent struct types.
Definition: DerivedTypes.h:213
llvm::Type::PPC_FP128TyID
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
Definition: Type.h:62
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::Function::setCallingConv
void setCallingConv(CallingConv::ID CC)
Definition: Function.h:242
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::Argument::getParamByRefType
Type * getParamByRefType() const
If this is a byref argument, return its type.
Definition: Function.cpp:215
Compiler.h
llvm::Function::getParamAlign
MaybeAlign getParamAlign(unsigned ArgNo) const
Definition: Function.h:441
llvm::ilist_node_impl< ilist_detail::compute_node_options< Function, Options... >::type >::getIterator
self_iterator getIterator()
Definition: ilist_node.h:82
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::Value::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1289
llvm::Argument::getPassPointeeByValueCopySize
uint64_t getPassPointeeByValueCopySize(const DataLayout &DL) const
If this argument satisfies has hasPassPointeeByValueAttr, return the in-memory ABI size copied to the...
Definition: Function.cpp:177
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::Function::ProfileCount::getType
ProfileCountType getType() const
Definition: Function.h:262
IIT_STRUCT6
@ IIT_STRUCT6
Definition: Function.cpp:972
llvm::Module::getFunctionList
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
Definition: Module.h:559
llvm::VectorType::getHalfElementsVectorType
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
Definition: DerivedTypes.h:493
llvm::Function::hasAddressTaken
bool hasAddressTaken(const User **=nullptr, bool IgnoreCallbackUses=false, bool IgnoreAssumeLikeCalls=true, bool IngoreLLVMUsed=false, bool IgnoreARCAttachedCall=false) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
Definition: Function.cpp:1823
llvm::Function::callsFunctionThatReturnsTwice
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
Definition: Function.cpp:1899
llvm::Value::setMetadata
void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
Definition: Metadata.cpp:1326
llvm::Intrinsic::IITDescriptor::PtrToElt
@ PtrToElt
Definition: Intrinsics.h:137
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:308
llvm::Type::getContext
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
llvm::ArgInfo
Helper struct shared between Function Specialization and SCCP Solver.
Definition: SCCPSolver.h:47
IIT_ANYPTR
@ IIT_ANYPTR
Definition: Function.cpp:961
findTargetSubtable
static ArrayRef< const char * > findTargetSubtable(StringRef Name)
Find the segment of IntrinsicNameTable for intrinsics with the same target as Name,...
Definition: Function.cpp:755
IIT_V3
@ IIT_V3
Definition: Function.cpp:987
llvm::Function::setIsMaterializable
void setIsMaterializable(bool V)
Definition: Function.h:193
llvm::ArrayRef::front
const T & front() const
front - Get the first element.
Definition: ArrayRef.h:167
llvm::Intrinsic::IITDescriptor::VecElementArgument
@ VecElementArgument
Definition: Intrinsics.h:139
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:674
llvm::Function::ProfileCount::getCount
uint64_t getCount() const
Definition: Function.h:261
IIT_I32
@ IIT_I32
Definition: Function.cpp:936
llvm::MDBuilder::createFunctionSectionPrefix
MDNode * createFunctionSectionPrefix(StringRef Prefix)
Return metadata containing the section prefix for a function.
Definition: MDBuilder.cpp:78
Argument.h
llvm::Intrinsic::IITDescriptor::AK_AnyFloat
@ AK_AnyFloat
Definition: Intrinsics.h:160
IIT_STRUCT7
@ IIT_STRUCT7
Definition: Function.cpp:973
llvm::Type::IntegerTyID
@ IntegerTyID
Arbitrary bit width integers.
Definition: Type.h:71
llvm::Argument::addAttrs
void addAttrs(AttrBuilder &B)
Add attributes to an argument.
Definition: Function.cpp:284
llvm::VectorType::getExtendedElementVectorType
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
Definition: DerivedTypes.h:449
Attributes.h
llvm::Function::hasLazyArguments
bool hasLazyArguments() const
hasLazyArguments/CheckLazyArguments - The argument list of a function is built on demand,...
Definition: Function.h:106
name
static const char * name
Definition: SVEIntrinsicOpts.cpp:74
llvm::partition_point
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
Definition: STLExtras.h:1765
llvm::Function::getParamAlignment
uint64_t getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Definition: Function.h:435
IIT_SUBDIVIDE2_ARG
@ IIT_SUBDIVIDE2_ARG
Definition: Function.cpp:978
llvm::Function::addParamAttr
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
adds the attribute to the list of attributes for the given arg.
Definition: Function.cpp:566
Constant.h
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
IIT_VEC_OF_ANYPTRS_TO_ELT
@ IIT_VEC_OF_ANYPTRS_TO_ELT
Definition: Function.cpp:968
llvm::AttributeSet::getPreallocatedType
Type * getPreallocatedType() const
Definition: Attributes.cpp:734
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
llvm::Function::removeAttributeAtIndex
void removeAttributeAtIndex(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
Definition: Function.cpp:578
llvm::Type::isFloatTy
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition: Type.h:153
llvm::AttributeList::addFnAttribute
AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
Definition: Attributes.h:512
llvm::AttributeSet::getByRefType
Type * getByRefType() const
Definition: Attributes.cpp:722
llvm::Type::getHalfTy
static Type * getHalfTy(LLVMContext &C)
Definition: Type.cpp:224
IIT_HALF_VEC_ARG
@ IIT_HALF_VEC_ARG
Definition: Function.cpp:964
llvm::AttributeSet::getByValType
Type * getByValType() const
Definition: Attributes.cpp:726
llvm::Type::isIntOrIntVectorTy
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition: Type.h:202
llvm::Function::getParamDereferenceableOrNullBytes
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Extract the number of dereferenceable_or_null bytes for a parameter.
Definition: Function.h:483
llvm::Argument::hasNonNullAttr
bool hasNonNullAttr(bool AllowUndefOrPoison=true) const
Return true if this argument has the nonnull attribute.
Definition: Function.cpp:96
Casting.h
llvm::Argument::hasByValAttr
bool hasByValAttr() const
Return true if this argument has the byval attribute.
Definition: Function.cpp:109
IIT_I64
@ IIT_I64
Definition: Function.cpp:937
llvm::fltSemantics
Definition: APFloat.cpp:54
llvm::Argument::getParamByValType
Type * getParamByValType() const
If this is a byval argument, return its type.
Definition: Function.cpp:205
Function.h
IIT_TRUNC_ARG
@ IIT_TRUNC_ARG
Definition: Function.cpp:960
llvm::FramePointerKind::NonLeaf
@ NonLeaf
IIT_I128
@ IIT_I128
Definition: Function.cpp:969
llvm::Function::addDereferenceableParamAttr
void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes for the given arg.
Definition: Function.cpp:623
IIT_PTR
@ IIT_PTR
Definition: Function.cpp:946
IntrinsicNameTable
static const char *const IntrinsicNameTable[]
Table of string intrinsic names indexed by enum value.
Definition: Function.cpp:731
llvm::Type::isDoubleTy
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition: Type.h:156
llvm::Function::isTargetIntrinsic
bool isTargetIntrinsic() const
isTargetIntrinsic - Returns true if this function is an intrinsic and the intrinsic is specific to a ...
Definition: Function.cpp:747
IIT_MMX
@ IIT_MMX
Definition: Function.cpp:951
llvm::Type::isPPC_FP128Ty
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
Definition: Type.h:165
llvm::Function::getFunctionType
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition: Function.h:175
llvm::AttributeList::getAttributeAtIndex
Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
Definition: Attributes.cpp:1418
llvm::Function::addRetAttrs
void addRetAttrs(const AttrBuilder &Attrs)
Add return value attributes to this function.
Definition: Function.cpp:562
IIT_V32
@ IIT_V32
Definition: Function.cpp:945
llvm::Function::isConstrainedFPIntrinsic
bool isConstrainedFPIntrinsic() const
Returns true if the function is one of the "Constrained Floating-Point Intrinsics".
Definition: Function.cpp:446
llvm::Type::getBFloatTy
static Type * getBFloatTy(LLVMContext &C)
Definition: Type.cpp:225
llvm::Function::getParamStackAlign
MaybeAlign getParamStackAlign(unsigned ArgNo) const
Definition: Function.h:445
llvm::Function::getPersonalityFn
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Definition: Function.cpp:1908
llvm::AttributeList::removeRetAttribute
AttributeList removeRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:645
llvm::Function::getInstructionCount
unsigned getInstructionCount() const
Returns the number of non-debug IR instructions in this function.
Definition: Function.cpp:324
llvm::Intrinsic::getNameNoUnnamedTypes
std::string getNameNoUnnamedTypes(ID Id, ArrayRef< Type * > Tys)
Return the LLVM name for an intrinsic.
Definition: Function.cpp:922
IIT_PTR_TO_ARG
@ IIT_PTR_TO_ARG
Definition: Function.cpp:966
computeAddrSpace
static unsigned computeAddrSpace(unsigned AddrSpace, Module *M)
Definition: Function.cpp:375
llvm::LLVMContext::deleteGC
void deleteGC(const Function &Fn)
Remove the GC for a function.
Definition: LLVMContext.cpp:332
llvm::Function::getParamByRefType
Type * getParamByRefType(unsigned ArgNo) const
Extract the byref type for a parameter.
Definition: Function.h:465
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:475
llvm::MDBuilder
Definition: MDBuilder.h:36
llvm::Function::removeParamAttrs
void removeParamAttrs(unsigned ArgNo, const AttributeMask &Attrs)
removes the attribute from the list of attributes.
Definition: Function.cpp:618
llvm::GlobalValue::HasLLVMReservedName
unsigned HasLLVMReservedName
True if the function's name starts with "llvm.".
Definition: GlobalValue.h:105
llvm::Intrinsic::IITDescriptor::Struct
@ Struct
Definition: Intrinsics.h:130
IIT_EMPTYSTRUCT
@ IIT_EMPTYSTRUCT
Definition: Function.cpp:954
llvm::Type::getVoidTy
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:222
llvm::Function::nullPointerIsDefined
bool nullPointerIsDefined() const
Check if null pointer dereferencing is considered undefined behavior for the function.
Definition: Function.cpp:2045
llvm::User::getNumOperands
unsigned getNumOperands() const
Definition: User.h:191
llvm::AttributeSet
Definition: Attributes.h:290
llvm::Argument::getPointeeInMemoryValueType
Type * getPointeeInMemoryValueType() const
If hasPointeeInMemoryValueAttr returns true, the in-memory ABI type is returned.
Definition: Function.cpp:185
matchIntrinsicType
static bool matchIntrinsicType(Type *Ty, ArrayRef< Intrinsic::IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys, SmallVectorImpl< DeferredIntrinsicMatchPair > &DeferredChecks, bool IsDeferredCheck)
Definition: Function.cpp:1444
SmallVector.h
llvm::Function::setPrefixData
void setPrefixData(Constant *PrefixData)
Definition: Function.cpp:1923
llvm::Intrinsic::IITDescriptor::Token
@ Token
Definition: Intrinsics.h:120
llvm::Type::isBFloatTy
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
Definition: Type.h:145
User.h
llvm::Intrinsic::IITDescriptor::Vector
@ Vector
Definition: Intrinsics.h:128
N
#define N
llvm::AttributeList::hasRetAttr
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:772
llvm::Function::removeFnAttr
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
Definition: Function.cpp:586
llvm::AttributeList::addRetAttributes
AttributeList addRetAttributes(LLVMContext &C, const AttrBuilder &B) const
Add a return value attribute to the list.
Definition: Attributes.h:555
llvm::Argument::hasNoAliasAttr
bool hasNoAliasAttr() const
Return true if this argument has the noalias attribute.
Definition: Function.cpp:242
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:164
llvm::IntegerType::getBitWidth
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Definition: DerivedTypes.h:72
llvm::Intrinsic::matchIntrinsicSignature
MatchIntrinsicTypesResult matchIntrinsicSignature(FunctionType *FTy, ArrayRef< IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys)
Match the specified function type with the type constraints specified by the .td file.
Definition: Function.cpp:1720
llvm::tgtok::Bit
@ Bit
Definition: TGLexer.h:50
llvm::Function::addFnAttr
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
Definition: Function.cpp:538
llvm::GlobalObject::copyAttributesFrom
void copyAttributesFrom(const GlobalObject *Src)
Definition: Globals.cpp:136
llvm::Intrinsic::IITDescriptor::getVector
static IITDescriptor getVector(unsigned Width, bool IsScalable)
Definition: Intrinsics.h:208
llvm::Argument::getParamAlign
MaybeAlign getParamAlign() const
If this is a byval or inalloca argument, return its alignment.
Definition: Function.cpp:196
IIT_TOKEN
@ IIT_TOKEN
Definition: Function.cpp:952
llvm::GlobalValue::hasLinkOnceLinkage
bool hasLinkOnceLinkage() const
Definition: GlobalValue.h:504
llvm::Function::removeFromParent
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
Definition: Function.cpp:363
llvm::AttributeList::addAttributeAtIndex
AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
Definition: Attributes.cpp:1220
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
llvm::AttributeSet::getStructRetType
Type * getStructRetType() const
Definition: Attributes.cpp:730
llvm::GlobalValue::getType
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:284
DerivedTypes.h
llvm::Function::setPrologueData
void setPrologueData(Constant *PrologueData)
Definition: Function.cpp:1933
llvm::LLVMContext::OB_clang_arc_attachedcall
@ OB_clang_arc_attachedcall
Definition: LLVMContext.h:95
llvm::Function::recalculateIntrinsicID
void recalculateIntrinsicID()
Recalculate the ID for this function if it is an Intrinsic defined in llvm/Intrinsics....
Definition: Function.cpp:792
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::Function::getPrologueData
Constant * getPrologueData() const
Get the prologue data associated with this function.
Definition: Function.cpp:1928
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::Intrinsic::IITDescriptor::Integer
@ Integer
Definition: Intrinsics.h:127
LLVMContext.h
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
llvm::FramePointerKind::None
@ None
llvm::Function::ProfileCount
Class to represent profile counts.
Definition: Function.h:253
llvm::cl::desc
Definition: CommandLine.h:412
AbstractCallSite.h
llvm::Intrinsic::IITDescriptor
This is a type descriptor which explains the type requirements of an intrinsic.
Definition: Intrinsics.h:115
IIT_V512
@ IIT_V512
Definition: Function.cpp:970
llvm::NullPointerIsDefined
bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
Definition: Function.cpp:2049
llvm::Type::getX86_MMXTy
static Type * getX86_MMXTy(LLVMContext &C)
Definition: Type.cpp:233
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:241
IIT_SAME_VEC_WIDTH_ARG
@ IIT_SAME_VEC_WIDTH_ARG
Definition: Function.cpp:965
IIT_STRUCT5
@ IIT_STRUCT5
Definition: Function.cpp:958
llvm::AttributeList::hasParamAttr
bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:757
SymbolTableListTraits.h
llvm::Intrinsic::MatchIntrinsicTypesResult
MatchIntrinsicTypesResult
Definition: Intrinsics.h:219
llvm::AttributeList::getParamAttrs
AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
Definition: Attributes.cpp:1380
llvm::Argument::onlyReadsMemory
bool onlyReadsMemory() const
Return true if this argument has the readonly or readnone attribute.
Definition: Function.cpp:278
llvm::MDString
A single uniqued string.
Definition: Metadata.h:612
llvm::MDBuilder::createFunctionEntryCount
MDNode * createFunctionEntryCount(uint64_t Count, bool Synthetic, const DenseSet< GlobalValue::GUID > *Imports)
Return metadata containing the entry Count for a function, a boolean \Synthetic indicating whether th...
Definition: MDBuilder.cpp:59
llvm::AttributeList::getFnAttr
Attribute getFnAttr(Attribute::AttrKind Kind) const
Return the attribute object that exists for the function.
Definition: Attributes.h:816
IIT_STRUCT3
@ IIT_STRUCT3
Definition: Function.cpp:956
Value.h
IIT_V2
@ IIT_V2
Definition: Function.cpp:941
llvm::Function::getParamStructRetType
Type * getParamStructRetType(unsigned ArgNo) const
Extract the sret type for a parameter.
Definition: Function.h:455
llvm::Function::setAttributes
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
Definition: Function.h:317
llvm::Argument::hasSExtAttr
bool hasSExtAttr() const
Return true if this argument has the sext attribute.
Definition: Function.cpp:274
IIT_STRUCT8
@ IIT_STRUCT8
Definition: Function.cpp:974
llvm::FunctionType::getReturnType
Type * getReturnType() const
Definition: DerivedTypes.h:124
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::Type::isFP128Ty
bool isFP128Ty() const
Return true if this is 'fp128'.
Definition: Type.h:162
llvm::User::setNumHungOffUseOperands
void setNumHungOffUseOperands(unsigned NumOps)
Subclasses with hung off uses need to manage the operand count themselves.
Definition: User.h:215
llvm::VectorType::get
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:668
llvm::Type::HalfTyID
@ HalfTyID
16-bit floating point type
Definition: Type.h:56
llvm::Value::users
iterator_range< user_iterator > users()
Definition: Value.h:421
llvm::Type::X86_FP80TyID
@ X86_FP80TyID
80-bit floating point type (X87)
Definition: Type.h:60
IIT_VEC_ELEMENT
@ IIT_VEC_ELEMENT
Definition: Function.cpp:976
llvm::AttributeList::getParamAttr
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
Definition: Attributes.h:806
llvm::Type::getFloatTy
static Type * getFloatTy(LLVMContext &C)
Definition: Type.cpp:226
llvm::ArrayRef::end
iterator end() const
Definition: ArrayRef.h:153
llvm::Intrinsic::IITDescriptor::getArgumentKind
ArgKind getArgumentKind() const
Definition: Intrinsics.h:175
llvm::Type::isX86_AMXTy
bool isX86_AMXTy() const
Return true if this is X86 AMX.
Definition: Type.h:181
IIT_F64
@ IIT_F64
Definition: Function.cpp:940
llvm::Argument::hasReturnedAttr
bool hasReturnedAttr() const
Return true if this argument has the returned attribute.
Definition: Function.cpp:266
IIT_SCALABLE_VEC
@ IIT_SCALABLE_VEC
Definition: Function.cpp:977
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:103
llvm::Argument::addAttr
void addAttr(Attribute::AttrKind Kind)
Definition: Function.cpp:290
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:924
llvm::Function::getImportGUIDs
DenseSet< GlobalValue::GUID > getImportGUIDs() const
Returns the set of GUIDs that needs to be imported to the function for sample PGO,...
Definition: Function.cpp:2016
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::AttributeList::removeParamAttribute
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:667