67 cl::desc(
"Maximum size for the name of non-global values."));
70 validateBlockNumbers();
73 for (
auto &BB : *
this)
74 BB.Number = NextBlockNum++;
78void Function::validateBlockNumbers()
const {
81 for (
const auto &BB : *
this) {
82 unsigned Num = BB.getNumber();
83 assert(Num < NextBlockNum &&
"out of range block number");
84 assert(!Numbers[Num] &&
"duplicate block numbers");
91 for (
auto &BB : *
this) {
92 BB.convertToNewDbgValues();
97 for (
auto &BB : *
this) {
98 BB.convertFromNewDbgValues();
107 : Value(Ty, Value::ArgumentVal), Parent(Par), ArgNo(ArgNo) {
111void Argument::setParent(
Function *parent) {
117 if (
getParent()->hasParamAttribute(getArgNo(), Attribute::NonNull) &&
118 (AllowUndefOrPoison ||
119 getParent()->hasParamAttribute(getArgNo(), Attribute::NoUndef)))
121 else if (getDereferenceableBytes() > 0 &&
130 return hasAttribute(Attribute::ByVal);
135 return getParent()->getDeadOnReturnInfo(getArgNo());
141 return hasAttribute(Attribute::ByRef);
145 return getParent()->hasParamAttribute(getArgNo(), Attribute::SwiftSelf);
149 return getParent()->hasParamAttribute(getArgNo(), Attribute::SwiftError);
154 return hasAttribute(Attribute::InAlloca);
160 return hasAttribute(Attribute::Preallocated);
166 return Attrs.hasParamAttr(getArgNo(), Attribute::ByVal) ||
167 Attrs.hasParamAttr(getArgNo(), Attribute::InAlloca) ||
168 Attrs.hasParamAttr(getArgNo(), Attribute::Preallocated);
175 return Attrs.hasParamAttr(getArgNo(), Attribute::ByVal) ||
176 Attrs.hasParamAttr(getArgNo(), Attribute::StructRet) ||
177 Attrs.hasParamAttr(getArgNo(), Attribute::InAlloca) ||
178 Attrs.hasParamAttr(getArgNo(), Attribute::Preallocated) ||
179 Attrs.hasParamAttr(getArgNo(), Attribute::ByRef);
203 getParent()->getAttributes().getParamAttrs(getArgNo());
205 return DL.getTypeAllocSize(MemTy);
211 getParent()->getAttributes().getParamAttrs(getArgNo());
217 return getParent()->getParamAlign(getArgNo());
221 return getParent()->getParamStackAlign(getArgNo());
226 return getParent()->getParamByValType(getArgNo());
231 return getParent()->getParamStructRetType(getArgNo());
236 return getParent()->getParamByRefType(getArgNo());
241 return getParent()->getParamInAllocaType(getArgNo());
246 "Only pointers have dereferenceable bytes");
247 return getParent()->getParamDereferenceableBytes(getArgNo());
252 "Only pointers have dereferenceable bytes");
253 return getParent()->getParamDereferenceableOrNullBytes(getArgNo());
257 return getParent()->getParamNoFPClass(getArgNo());
261 const Attribute RangeAttr = getAttribute(llvm::Attribute::Range);
262 if (RangeAttr.isValid())
263 return RangeAttr.getRange();
269 return hasAttribute(Attribute::Nest);
274 return hasAttribute(Attribute::NoAlias);
284 return hasAttribute(Attribute::NoFree);
289 return hasAttribute(Attribute::StructRet);
293 return hasAttribute(Attribute::InReg);
297 return hasAttribute(Attribute::Returned);
301 return hasAttribute(Attribute::ZExt);
305 return hasAttribute(Attribute::SExt);
310 return Attrs.hasParamAttr(getArgNo(), Attribute::ReadOnly) ||
311 Attrs.hasParamAttr(getArgNo(), Attribute::ReadNone);
316 AL =
AL.addParamAttributes(Parent->getContext(), getArgNo(),
B);
321 getParent()->addParamAttr(getArgNo(), Kind);
325 getParent()->addParamAttr(getArgNo(), Attr);
329 getParent()->removeParamAttr(getArgNo(), Kind);
334 AL =
AL.removeParamAttributes(Parent->getContext(), getArgNo(), AM);
339 return getParent()->hasParamAttribute(getArgNo(), Kind);
343 return getParent()->hasParamAttribute(getArgNo(), Kind);
347 return getParent()->getParamAttribute(getArgNo(), Kind);
351 return getParent()->getAttributes().getParamAttrs(getArgNo());
359 return getType()->getContext();
367 unsigned NumInstrs = 0;
369 NumInstrs += std::distance(BB.instructionsWithoutDebug().begin(),
370 BB.instructionsWithoutDebug().end());
376 return Create(Ty,
Linkage, M.getDataLayout().getProgramAddressSpace(),
N, &M);
381 unsigned AddrSpace,
const Twine &
N,
384 AttrBuilder
B(
F->getContext());
387 B.addUWTableAttr(UWTable);
388 switch (M->getFramePointer()) {
393 B.addAttribute(
"frame-pointer",
"reserved");
396 B.addAttribute(
"frame-pointer",
"non-leaf");
399 B.addAttribute(
"frame-pointer",
"non-leaf-no-reserve");
402 B.addAttribute(
"frame-pointer",
"all");
405 if (M->getModuleFlag(
"function_return_thunk_extern"))
406 B.addAttribute(Attribute::FnRetThunkExtern);
407 StringRef DefaultCPU =
F->getContext().getDefaultTargetCPU();
408 if (!DefaultCPU.
empty())
409 B.addAttribute(
"target-cpu", DefaultCPU);
410 StringRef DefaultFeatures =
F->getContext().getDefaultTargetFeatures();
411 if (!DefaultFeatures.
empty())
412 B.addAttribute(
"target-features", DefaultFeatures);
415 auto isModuleAttributeSet = [&](
const StringRef &ModAttr) ->
bool {
418 return Attr && !Attr->isZero();
421 auto AddAttributeIfSet = [&](
const StringRef &ModAttr) {
422 if (isModuleAttributeSet(ModAttr))
423 B.addAttribute(ModAttr);
427 if (isModuleAttributeSet(
"sign-return-address"))
428 SignType =
"non-leaf";
429 if (isModuleAttributeSet(
"sign-return-address-all"))
431 if (SignType !=
"none") {
432 B.addAttribute(
"sign-return-address", SignType);
433 B.addAttribute(
"sign-return-address-key",
434 isModuleAttributeSet(
"sign-return-address-with-bkey")
438 AddAttributeIfSet(
"branch-target-enforcement");
439 AddAttributeIfSet(
"branch-protection-pauth-lr");
440 AddAttributeIfSet(
"guarded-control-stack");
447 getParent()->getFunctionList().remove(getIterator());
451 getParent()->getFunctionList().erase(getIterator());
457#ifdef EXPENSIVE_CHECKS
459 auto FromFEnd = FromF->
end();
460 for (
auto It = FromBeginIt; It != FromEndIt; ++It)
461 assert(It != FromFEnd &&
"FromBeginIt not before FromEndIt!");
463 BasicBlocks.splice(ToIt, FromF->BasicBlocks, FromBeginIt, FromEndIt);
468 return BasicBlocks.erase(FromIt, ToIt);
478 if (AddrSpace ==
static_cast<unsigned>(-1))
479 return M ? M->getDataLayout().getProgramAddressSpace() : 0;
487 NumArgs(Ty->getNumParams()) {
489 "invalid return type");
490 setGlobalObjectSubClassData(0);
497 if (Ty->getNumParams())
498 setValueSubclassData(1);
504 HasLLVMReservedName =
getName().starts_with(
"llvm.");
520 validateBlockNumbers();
532void Function::BuildLazyArguments()
const {
534 auto *FT = getFunctionType();
536 Arguments = std::allocator<Argument>().allocate(NumArgs);
537 for (
unsigned i = 0, e = NumArgs; i !=
e; ++i) {
538 Type *ArgTy = FT->getParamType(i);
539 assert(!ArgTy->isVoidTy() &&
"Cannot have void typed arguments!");
545 unsigned SDC = getSubclassDataFromValue();
547 const_cast<Function*
>(
this)->setValueSubclassData(SDC);
548 assert(!hasLazyArguments());
559void Function::clearArguments() {
564 std::allocator<Argument>().deallocate(
Arguments, NumArgs);
569 assert(isDeclaration() &&
"Expected no references to current arguments");
572 if (!hasLazyArguments()) {
574 [](
const Argument &
A) {
return A.use_empty(); }) &&
575 "Expected arguments to be unused in declaration");
577 setValueSubclassData(getSubclassDataFromValue() | (1 << 0));
581 if (Src.hasLazyArguments())
585 assert(arg_size() == Src.arg_size());
587 Src.Arguments =
nullptr;
600 setValueSubclassData(getSubclassDataFromValue() & ~(1 << 0));
601 assert(!hasLazyArguments());
602 Src.setValueSubclassData(Src.getSubclassDataFromValue() | (1 << 0));
605void Function::deleteBodyImpl(
bool ShouldDrop) {
606 setIsMaterializable(
false);
613 while (!BasicBlocks.empty())
614 BasicBlocks.begin()->eraseFromParent();
616 if (getNumOperands()) {
620 setNumHungOffUseOperands(0);
628 setValueSubclassData(getSubclassDataFromValue() & ~0xe);
636 AttributeSets = AttributeSets.addAttributeAtIndex(
getContext(), i, Attr);
640 AttributeSets = AttributeSets.addFnAttribute(
getContext(), Kind);
644 AttributeSets = AttributeSets.addFnAttribute(
getContext(), Kind, Val);
648 AttributeSets = AttributeSets.addFnAttribute(
getContext(), Attr);
652 AttributeSets = AttributeSets.addFnAttributes(
getContext(), Attrs);
656 AttributeSets = AttributeSets.addRetAttribute(
getContext(), Kind);
660 AttributeSets = AttributeSets.addRetAttribute(
getContext(), Attr);
664 AttributeSets = AttributeSets.addRetAttributes(
getContext(), Attrs);
668 AttributeSets = AttributeSets.addParamAttribute(
getContext(), ArgNo, Kind);
672 AttributeSets = AttributeSets.addParamAttribute(
getContext(), ArgNo, Attr);
676 AttributeSets = AttributeSets.addParamAttributes(
getContext(), ArgNo, Attrs);
680 AttributeSets = AttributeSets.removeAttributeAtIndex(
getContext(), i, Kind);
684 AttributeSets = AttributeSets.removeAttributeAtIndex(
getContext(), i, Kind);
688 AttributeSets = AttributeSets.removeFnAttribute(
getContext(), Kind);
692 AttributeSets = AttributeSets.removeFnAttribute(
getContext(), Kind);
696 AttributeSets = AttributeSets.removeFnAttributes(
getContext(), AM);
700 AttributeSets = AttributeSets.removeRetAttribute(
getContext(), Kind);
704 AttributeSets = AttributeSets.removeRetAttribute(
getContext(), Kind);
708 AttributeSets = AttributeSets.removeRetAttributes(
getContext(), Attrs);
712 AttributeSets = AttributeSets.removeParamAttribute(
getContext(), ArgNo, Kind);
716 AttributeSets = AttributeSets.removeParamAttribute(
getContext(), ArgNo, Kind);
721 AttributeSets.removeParamAttributes(
getContext(), ArgNo, Attrs);
726 AttributeSets.addDereferenceableParamAttr(
getContext(), ArgNo, Bytes);
730 return AttributeSets.hasFnAttr(Kind);
734 return AttributeSets.hasFnAttr(Kind);
738 return AttributeSets.hasRetAttr(Kind);
743 return AttributeSets.hasParamAttr(ArgNo, Kind);
747 return AttributeSets.hasParamAttr(ArgNo, Kind);
752 return AttributeSets.getAttributeAtIndex(i, Kind);
756 return AttributeSets.getAttributeAtIndex(i, Kind);
761 return AttributeSets.hasAttributeAtIndex(Idx, Kind);
765 return AttributeSets.getFnAttr(Kind);
769 return AttributeSets.getFnAttr(Kind);
773 return AttributeSets.getRetAttr(Kind);
778 Attribute
A = getFnAttribute(Name);
780 if (
A.isStringAttribute()) {
782 if (Str.getAsInteger(0, Result))
783 getContext().emitError(
"cannot parse integer attribute " + Name);
792 return AttributeSets.getParamAttr(ArgNo, Kind);
797 AttributeSets = AttributeSets.addDereferenceableOrNullParamAttr(
getContext(),
802 AttributeSets = AttributeSets.addRangeRetAttr(
getContext(), CR);
814 return getDenormalModeRaw();
818 Attribute Attr = getFnAttribute(
"denormal-fp-math");
824 Attribute Attr = getFnAttribute(
"denormal-fp-math-f32");
825 if (Attr.isValid()) {
834 assert(hasGC() &&
"Function has no collector");
839 setValueSubclassDataBit(14, !Str.empty());
847 setValueSubclassDataBit(14,
false);
851 return hasFnAttribute(Attribute::StackProtect) ||
852 hasFnAttribute(Attribute::StackProtectStrong) ||
853 hasFnAttribute(Attribute::StackProtectReq);
860 setCallingConv(Src->getCallingConv());
861 setAttributes(Src->getAttributes());
866 if (Src->hasPersonalityFn())
867 setPersonalityFn(Src->getPersonalityFn());
868 if (Src->hasPrefixData())
869 setPrefixData(Src->getPrefixData());
870 if (Src->hasPrologueData())
871 setPrologueData(Src->getPrologueData());
883 return getMemoryEffects().doesNotAccessMemory();
891 return getMemoryEffects().onlyReadsMemory();
899 return getMemoryEffects().onlyWritesMemory();
908 return getMemoryEffects().onlyAccessesArgPointees();
917 return getMemoryEffects().onlyAccessesInaccessibleMem();
926 return getMemoryEffects().onlyAccessesInaccessibleOrArgMem();
938 LibFuncCache = UnknownLibFunc;
940 if (!
Name.starts_with(
"llvm.")) {
941 HasLLVMReservedName =
false;
945 HasLLVMReservedName =
true;
954 bool IgnoreCallbackUses,
955 bool IgnoreAssumeLikeCalls,
bool IgnoreLLVMUsed,
956 bool IgnoreARCAttachedCall,
957 bool IgnoreCastedDirectCall)
const {
958 for (
const Use &U : uses()) {
959 const User *FU = U.getUser();
960 if (IgnoreCallbackUses) {
962 if (ACS && ACS.isCallbackCall())
968 if (IgnoreAssumeLikeCalls &&
971 if (const auto *I = dyn_cast<IntrinsicInst>(U))
972 return I->isAssumeLikeIntrinsic();
979 const User *FUU = FU;
984 if (const auto *GV = dyn_cast<GlobalVariable>(U))
985 return GV->hasName() &&
986 (GV->getName() ==
"llvm.compiler.used" ||
987 GV->getName() ==
"llvm.used");
997 if (IgnoreAssumeLikeCalls) {
999 if (
I->isAssumeLikeIntrinsic())
1003 if (!
Call->isCallee(&U) || (!IgnoreCastedDirectCall &&
1004 Call->getFunctionType() != getFunctionType())) {
1005 if (IgnoreARCAttachedCall &&
1020 if (!hasLinkOnceLinkage() && !hasLocalLinkage() &&
1021 !hasAvailableExternallyLinkage())
1032 if (
Call->hasFnAttr(Attribute::ReturnsTwice))
1039 assert(hasPersonalityFn() && getNumOperands());
1044 setHungoffOperand<0>(Fn);
1045 setValueSubclassDataBit(3, Fn !=
nullptr);
1049 assert(hasPrefixData() && getNumOperands());
1054 setHungoffOperand<1>(PrefixData);
1055 setValueSubclassDataBit(1, PrefixData !=
nullptr);
1059 assert(hasPrologueData() && getNumOperands());
1064 setHungoffOperand<2>(PrologueData);
1065 setValueSubclassDataBit(2, PrologueData !=
nullptr);
1068void Function::allocHungoffUselist() {
1070 if (getNumOperands())
1073 allocHungoffUses(3,
false);
1074 setNumHungOffUseOperands(3);
1084void Function::setHungoffOperand(
Constant *
C) {
1086 allocHungoffUselist();
1088 }
else if (getNumOperands()) {
1093void Function::setValueSubclassDataBit(
unsigned Bit,
bool On) {
1094 assert(Bit < 16 &&
"SubclassData contains only 16 bits");
1096 setValueSubclassData(getSubclassDataFromValue() | (1 << Bit));
1098 setValueSubclassData(getSubclassDataFromValue() & ~(1 << Bit));
1104 auto PrevCount = getEntryCount();
1105 assert(!PrevCount || PrevCount->getType() ==
Count.getType());
1108 auto ImportGUIDs = getImportGUIDs();
1109 if (S ==
nullptr && ImportGUIDs.size())
1114 LLVMContext::MD_prof,
1115 MDB.createFunctionEntryCount(
Count.getCount(),
Count.isSynthetic(), S));
1124 MDNode *MD = getMetadata(LLVMContext::MD_prof);
1133 return std::nullopt;
1135 }
else if (AllowSynthetic &&
1143 return std::nullopt;
1148 if (
MDNode *MD = getMetadata(LLVMContext::MD_prof))
1159 return hasFnAttribute(Attribute::NullPointerIsValid);
1163 Attribute Attr = getFnAttribute(Attribute::VScaleRange);
1164 if (!Attr.isValid())
1167 unsigned VScale = Attr.getVScaleRangeMin();
1168 if (VScale && VScale == Attr.getVScaleRangeMax())
1175 if (
F &&
F->nullPointerIsDefined())
static unsigned getIntrinsicID(const SDNode *N)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Lower Kernel Arguments
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Expand Atomic instructions
This file contains the simple types necessary to represent the attributes associated with functions a...
static const Function * getParent(const Value *V)
This file implements the BitVector class.
static bool setMemoryEffects(Function &F, MemoryEffects ME)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_EXPORT_TEMPLATE
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseSet and SmallDenseSet classes.
Module.h This file contains the declarations for the Module class.
This defines the Use class.
Machine Check Debug Module
This file contains the declarations for profiling metadata utility functions.
static StringRef getName(Value *V)
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
static Type * getMemoryParamAllocType(AttributeSet ParamAttrs)
For a byval, sret, inalloca, or preallocated parameter, get the in-memory parameter type.
static cl::opt< int > NonGlobalValueMaxNameSize("non-global-value-max-name-size", cl::Hidden, cl::init(1024), cl::desc("Maximum size for the name of non-global values."))
static MutableArrayRef< Argument > makeArgArray(Argument *Args, size_t Count)
static unsigned computeAddrSpace(unsigned AddrSpace, Module *M)
This file defines the SmallString class.
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
static const fltSemantics & IEEEsingle()
uint64_t getZExtValue() const
Get zero extended value.
This class represents an incoming formal argument to a Function.
LLVM_ABI Type * getParamByRefType() const
If this is a byref argument, return its type.
LLVM_ABI DeadOnReturnInfo getDeadOnReturnInfo() const
Returns information on the memory marked dead_on_return for the argument.
LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const
LLVM_ABI bool hasNoAliasAttr() const
Return true if this argument has the noalias attribute.
LLVM_ABI bool hasNonNullAttr(bool AllowUndefOrPoison=true) const
Return true if this argument has the nonnull attribute.
LLVM_ABI bool hasByRefAttr() const
Return true if this argument has the byref attribute.
LLVM_ABI uint64_t getDereferenceableOrNullBytes() const
If this argument has the dereferenceable_or_null attribute, return the number of bytes known to be de...
LLVM_ABI void addAttr(Attribute::AttrKind Kind)
LLVM_ABI Argument(Type *Ty, const Twine &Name="", Function *F=nullptr, unsigned ArgNo=0)
Argument constructor.
LLVM_ABI bool onlyReadsMemory() const
Return true if this argument has the readonly or readnone attribute.
LLVM_ABI bool hasPointeeInMemoryValueAttr() const
Return true if this argument has the byval, sret, inalloca, preallocated, or byref attribute.
LLVM_ABI bool hasAttribute(Attribute::AttrKind Kind) const
Check if an argument has a given attribute.
LLVM_ABI bool hasReturnedAttr() const
Return true if this argument has the returned attribute.
LLVM_ABI Type * getParamStructRetType() const
If this is an sret argument, return its type.
LLVM_ABI bool hasInRegAttr() const
Return true if this argument has the inreg attribute.
LLVM_ABI bool hasByValAttr() const
Return true if this argument has the byval attribute.
LLVM_ABI bool hasPreallocatedAttr() const
Return true if this argument has the preallocated attribute.
LLVM_ABI bool hasSExtAttr() const
Return true if this argument has the sext attribute.
LLVM_ABI void removeAttr(Attribute::AttrKind Kind)
Remove attributes from an argument.
LLVM_ABI uint64_t getPassPointeeByValueCopySize(const DataLayout &DL) const
If this argument satisfies has hasPassPointeeByValueAttr, return the in-memory ABI size copied to the...
LLVM_ABI void removeAttrs(const AttributeMask &AM)
LLVM_ABI Type * getPointeeInMemoryValueType() const
If hasPointeeInMemoryValueAttr returns true, the in-memory ABI type is returned.
LLVM_ABI bool hasInAllocaAttr() const
Return true if this argument has the inalloca attribute.
LLVM_ABI bool hasSwiftErrorAttr() const
Return true if this argument has the swifterror attribute.
LLVM_ABI FPClassTest getNoFPClass() const
If this argument has nofpclass attribute, return the mask representing disallowed floating-point valu...
LLVM_ABI void addAttrs(AttrBuilder &B)
Add attributes to an argument.
LLVM_ABI bool hasNoFreeAttr() const
Return true if this argument has the nofree attribute.
LLVM_ABI bool hasSwiftSelfAttr() const
Return true if this argument has the swiftself attribute.
LLVM_ABI Type * getParamInAllocaType() const
If this is an inalloca argument, return its type.
LLVM_ABI bool hasZExtAttr() const
Return true if this argument has the zext attribute.
LLVM_ABI Type * getParamByValType() const
If this is a byval argument, return its type.
LLVM_ABI bool hasNestAttr() const
Return true if this argument has the nest attribute.
LLVM_ABI MaybeAlign getParamAlign() const
If this is a byval or inalloca argument, return its alignment.
LLVM_ABI std::optional< ConstantRange > getRange() const
If this argument has a range attribute, return the value range of the argument.
LLVM_ABI bool hasStructRetAttr() const
Return true if this argument has the sret attribute.
LLVM_ABI AttributeSet getAttributes() const
LLVM_ABI bool hasPassPointeeByValueCopyAttr() const
Return true if this argument has the byval, inalloca, or preallocated attribute.
LLVM_ABI MaybeAlign getParamStackAlign() const
LLVM_ABI bool hasNoCaptureAttr() const
Return true if this argument has the nocapture attribute.
LLVM_ABI uint64_t getDereferenceableBytes() const
If this argument has the dereferenceable attribute, return the number of bytes known to be dereferenc...
This class stores enough information to efficiently remove some attributes from an existing AttrBuild...
This class holds the attributes for a particular argument, parameter, function, or return value.
LLVM_ABI Type * getInAllocaType() const
LLVM_ABI Type * getByValType() const
LLVM_ABI Type * getStructRetType() const
LLVM_ABI Type * getPreallocatedType() const
LLVM_ABI Type * getByRefType() const
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
static LLVM_ABI Attribute getWithMemoryEffects(LLVMContext &Context, MemoryEffects ME)
LLVM Basic Block Representation.
LLVM_ABI void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...
This is the shared class of boolean and integer constants.
const APInt & getValue() const
Return the constant as an APInt value reference.
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
This class represents a range of values.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Implements a dense probed hash-table based set.
static LLVM_ABI bool isValidReturnType(Type *RetTy)
Return true if the specified type is valid as a return type.
Class to represent profile counts.
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
unsigned getVScaleValue() const
Return the value for vscale based on the vscale_range attribute or 0 when unknown.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs)
adds the attributes to the list of attributes for the given arg.
void removeRetAttr(Attribute::AttrKind Kind)
removes the attribute from the return value list of attributes.
void addRetAttrs(const AttrBuilder &Attrs)
Add return value attributes to this function.
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
void splice(Function::iterator ToIt, Function *FromF)
Transfer all blocks from FromF to this function at ToIt.
BasicBlockListType::iterator iterator
bool hasAddressTaken(const User **=nullptr, bool IgnoreCallbackUses=false, bool IgnoreAssumeLikeCalls=true, bool IngoreLLVMUsed=false, bool IgnoreARCAttachedCall=false, bool IgnoreCastedDirectCall=false) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
bool nullPointerIsDefined() const
Check if null pointer dereferencing is considered undefined behavior for the function.
Attribute getParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
gets the specified attribute from the list of attributes.
void setPrefixData(Constant *PrefixData)
bool hasStackProtectorFnAttr() const
Returns true if the function has ssp, sspstrong, or sspreq fn attrs.
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
const DataLayout & getDataLayout() const
Get the data layout of the module this function belongs to.
void addFnAttrs(const AttrBuilder &Attrs)
Add function attributes to this function.
void renumberBlocks()
Renumber basic blocks into a dense value range starting from 0.
void setDoesNotAccessMemory()
void setGC(std::string Str)
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
uint64_t getFnAttributeAsParsedInteger(StringRef Kind, uint64_t Default=0) const
For a string attribute Kind, parse attribute as an integer.
bool isConstrainedFPIntrinsic() const
Returns true if the function is one of the "Constrained Floating-PointIntrinsics".
void setOnlyAccessesArgMemory()
MemoryEffects getMemoryEffects() const
void setOnlyAccessesInaccessibleMemory()
void removeParamAttrs(unsigned ArgNo, const AttributeMask &Attrs)
removes the attribute from the list of attributes.
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
bool hasAttributeAtIndex(unsigned Idx, Attribute::AttrKind Kind) const
Check if attribute of the given kind is set at the given index.
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 and the LLVMContext applied.
void setOnlyReadsMemory()
bool isTargetIntrinsic() const
isTargetIntrinsic - Returns true if this function is an intrinsic and the intrinsic is specific to a ...
void removeFnAttrs(const AttributeMask &Attrs)
DenormalMode getDenormalModeRaw() const
Return the representational value of "denormal-fp-math".
void addRetAttr(Attribute::AttrKind Kind)
Add return value attributes to this function.
DenormalMode getDenormalModeF32Raw() const
Return the representational value of "denormal-fp-math-f32".
Constant * getPrologueData() const
Get the prologue data associated with this function.
void convertFromNewDbgValues()
Constant * getPersonalityFn() const
Get the personality function associated with this function.
void setOnlyWritesMemory()
void setPersonalityFn(Constant *Fn)
DenseSet< GlobalValue::GUID > getImportGUIDs() const
Returns the set of GUIDs that needs to be imported to the function for sample PGO,...
void removeAttributeAtIndex(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes for the given arg.
void addRangeRetAttr(const ConstantRange &CR)
adds the range attribute to the list of attributes for the return value.
void stealArgumentListFrom(Function &Src)
Steal arguments from another function.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
const std::string & getGC() const
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
adds the attribute to the list of attributes for the given arg.
bool doesNotAccessMemory() const
Determine if the function does not access memory.
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
void updateAfterNameChange()
Update internal caches that depend on the function name (such as the intrinsic ID and libcall cache).
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
bool hasRetAttribute(Attribute::AttrKind Kind) const
check if an attribute is in the list of attributes for the return value.
bool onlyWritesMemory() const
Determine if the function does not access or only writes memory.
std::optional< ProfileCount > getEntryCount(bool AllowSynthetic=false) const
Get the entry count for this function.
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
void setPrologueData(Constant *PrologueData)
void removeRetAttrs(const AttributeMask &Attrs)
removes the attributes from the return value list of attributes.
bool onlyAccessesArgMemory() const
Determine if the call can access memory only using pointers based on its arguments.
Function::iterator erase(Function::iterator FromIt, Function::iterator ToIt)
Erases a range of BasicBlocks from FromIt to (not including) ToIt.
void setMemoryEffects(MemoryEffects ME)
Constant * getPrefixData() const
Get the prefix data associated with this function.
Attribute getAttributeAtIndex(unsigned i, Attribute::AttrKind Kind) const
gets the attribute from the list of attributes.
void convertToNewDbgValues()
void setOnlyAccessesInaccessibleMemOrArgMem()
void setEntryCount(ProfileCount Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes for the given arg.
unsigned getInstructionCount() const
Returns the number of non-debug IR instructions in this function.
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
void addAttributeAtIndex(unsigned i, Attribute Attr)
adds the attribute to the list of attributes.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
Attribute getRetAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind for the return value.
LLVM_ABI void copyAttributesFrom(const GlobalObject *Src)
This is an important class for using LLVM in a threaded context.
@ OB_clang_arc_attachedcall
const MDOperand & getOperand(unsigned I) const
unsigned getNumOperands() const
Return number of MDNode operands.
static MemoryEffectsBase readOnly()
static MemoryEffectsBase argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
static MemoryEffectsBase inaccessibleMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
static MemoryEffectsBase writeOnly()
static MemoryEffectsBase inaccessibleOrArgMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
static MemoryEffectsBase none()
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A Use represents the edge between a Value definition and its users.
void dropAllReferences()
Drop all references to operands.
user_iterator user_begin()
bool hasOneUse() const
Return true if there is exactly one use of this value.
iterator_range< user_iterator > users()
void push_back(pointer val)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
LLVM_ABI LLVM_READNONE bool supportsNonVoidReturnType(CallingConv::ID CC)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ ARM64EC_Thunk_Native
Calling convention used in the ARM64EC ABI to implement calls between ARM64 code and thunks.
@ AArch64_VectorCall
Used between AArch64 Advanced SIMD functions.
@ X86_64_SysV
The C convention as specified in the x86-64 supplement to the System V ABI, used on most non-Windows ...
@ RISCV_VectorCall
Calling convention used for RISC-V V-extension.
@ AMDGPU_CS
Used for Mesa/AMDPAL compute shaders.
@ M68k_INTR
Used for M68k interrupt routines.
@ AMDGPU_VS
Used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (vertex shader if tess...
@ MSP430_BUILTIN
Used for special MSP430 rtlib functions which have an "optimized" convention using additional registe...
@ AVR_SIGNAL
Used for AVR signal routines.
@ HiPE
Used by the High-Performance Erlang Compiler (HiPE).
@ Swift
Calling convention for Swift.
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
@ AArch64_SVE_VectorCall
Used between AArch64 SVE functions.
@ ARM_APCS
ARM Procedure Calling Standard (obsolete, but still used on some targets).
@ CFGuard_Check
Special calling convention on Windows for calling the Control Guard Check ICall funtion.
@ AVR_INTR
Used for AVR interrupt routines.
@ PreserveMost
Used for runtime calls that preserves most registers.
@ AnyReg
OBSOLETED - Used for stack based JavaScript calls.
@ AMDGPU_Gfx
Used for AMD graphics targets.
@ DUMMY_HHVM
Placeholders for HHVM calling conventions (deprecated, removed).
@ AMDGPU_CS_ChainPreserve
Used on AMDGPUs to give the middle-end more control over argument placement.
@ AMDGPU_HS
Used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
@ ARM_AAPCS
ARM Architecture Procedure Calling Standard calling convention (aka EABI).
@ AMDGPU_GS
Used for Mesa/AMDPAL geometry shaders.
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2
Preserve X2-X15, X19-X29, SP, Z0-Z31, P0-P15.
@ CXX_FAST_TLS
Used for access functions.
@ X86_INTR
x86 hardware interrupt context.
@ RISCV_VLSCall_32
Calling convention used for RISC-V V-extension fixed vectors.
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0
Preserve X0-X13, X19-X29, SP, Z0-Z31, P0-P15.
@ WASM_EmscriptenInvoke
For emscripten __invoke_* functions.
@ AMDGPU_CS_Chain
Used on AMDGPUs to give the middle-end more control over argument placement.
@ AVR_BUILTIN
Used for special AVR rtlib functions which have an "optimized" convention to preserve registers.
@ GHC
Used by the Glasgow Haskell Compiler (GHC).
@ AMDGPU_PS
Used for Mesa/AMDPAL pixel shaders.
@ Cold
Attempts to make code in the caller as efficient as possible under the assumption that the call is no...
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1
Preserve X1-X15, X19-X29, SP, Z0-Z31, P0-P15.
@ X86_ThisCall
Similar to X86_StdCall.
@ PTX_Device
Call to a PTX device function.
@ SPIR_KERNEL
Used for SPIR kernel functions.
@ PreserveAll
Used for runtime calls that preserves (almost) all registers.
@ X86_StdCall
stdcall is mostly used by the Win32 API.
@ SPIR_FUNC
Used for SPIR non-kernel device functions.
@ Fast
Attempts to make calls as fast as possible (e.g.
@ MSP430_INTR
Used for MSP430 interrupt routines.
@ X86_VectorCall
MSVC calling convention that passes vectors and vector aggregates in SSE registers.
@ Intel_OCL_BI
Used for Intel OpenCL built-ins.
@ PreserveNone
Used for runtime calls that preserves none general registers.
@ AMDGPU_ES
Used for AMDPAL shader stage before geometry shader if geometry is in use.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
@ Win64
The C convention as implemented on Windows/x86-64 and AArch64.
@ SwiftTail
This follows the Swift calling convention in how arguments are passed but guarantees tail calls will ...
@ GRAAL
Used by GraalVM. Two additional registers are reserved.
@ AMDGPU_LS
Used for AMDPAL vertex shader if tessellation is in use.
@ ARM_AAPCS_VFP
Same as ARM_AAPCS, but uses hard floating point ABI.
@ ARM64EC_Thunk_X64
Calling convention used in the ARM64EC ABI to implement calls between x64 code and thunks.
@ M68k_RTD
Used for M68k rtd-based CC (similar to X86's stdcall).
@ C
The default llvm calling convention, compatible with C.
@ X86_FastCall
'fast' analog of X86_StdCall.
LLVM_ABI bool isConstrainedFPIntrinsic(ID QID)
Returns true if the intrinsic ID is for one of the "ConstrainedFloating-Point Intrinsics".
LLVM_ABI ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
LLVM_ABI AttributeList getAttributes(LLVMContext &C, ID id, FunctionType *FT)
Return the attributes for an intrinsic.
LLVM_ABI bool getIntrinsicSignature(Intrinsic::ID, FunctionType *FT, SmallVectorImpl< Type * > &ArgTys)
Gets the type arguments of an intrinsic call by matching type contraints specified by the ....
LLVM_ABI bool isTargetIntrinsic(ID IID)
isTargetIntrinsic - Returns true if IID is an intrinsic specific to a certain target.
initializer< Ty > init(const Ty &Val)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract_or_null(Y &&MD)
Extract a Value from Metadata, allowing null.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
Context & getContext() const
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
unsigned getPointerAddressSpace(const Type *T)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
@ None
No unwind table requested.
LLVM_ABI bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
bool isPointerTy(const Type *T)
FunctionAddr VTableAddr Count
Function::ProfileCount ProfileCount
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
DWARFExpression::Operation Op
DenormalMode parseDenormalFPAttribute(StringRef Str)
Returns the denormal mode to use for inputs and outputs.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
bool capturesNothing(CaptureComponents CC)
Represent subnormal handling kind for floating point instruction inputs and outputs.
static constexpr DenormalMode getInvalid()
static LLVM_ABI const char * SyntheticFunctionEntryCount
static LLVM_ABI const char * FunctionEntryCount
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.