65 "non-global-value-max-name-size", cl::Hidden, cl::init(1024),
66 cl::desc(
"Maximum size for the name of non-global values."));
70void Function::renumberBlocks() {
71 validateBlockNumbers();
74 for (
auto &BB : *
this)
75 BB.Number = NextBlockNum++;
79void Function::validateBlockNumbers()
const {
82 for (
const auto &BB : *
this) {
83 unsigned Num = BB.getNumber();
84 assert(Num < NextBlockNum &&
"out of range block number");
85 assert(!Numbers[Num] &&
"duplicate block numbers");
91void Function::convertToNewDbgValues() {
92 IsNewDbgInfoFormat =
true;
93 for (
auto &BB : *
this) {
94 BB.convertToNewDbgValues();
98void Function::convertFromNewDbgValues() {
99 IsNewDbgInfoFormat =
false;
100 for (
auto &BB : *
this) {
101 BB.convertFromNewDbgValues();
105void Function::setIsNewDbgInfoFormat(
bool NewFlag) {
106 if (NewFlag && !IsNewDbgInfoFormat)
107 convertToNewDbgValues();
108 else if (!NewFlag && IsNewDbgInfoFormat)
109 convertFromNewDbgValues();
111void Function::setNewDbgInfoFormatFlag(
bool NewFlag) {
112 for (
auto &BB : *
this) {
113 BB.setNewDbgInfoFormatFlag(NewFlag);
115 IsNewDbgInfoFormat = NewFlag;
123 :
Value(Ty,
Value::ArgumentVal), Parent(Par), ArgNo(ArgNo) {
127void Argument::setParent(
Function *parent) {
131bool Argument::hasNonNullAttr(
bool AllowUndefOrPoison)
const {
133 if (
getParent()->hasParamAttribute(getArgNo(), Attribute::NonNull) &&
134 (AllowUndefOrPoison ||
135 getParent()->hasParamAttribute(getArgNo(), Attribute::NoUndef)))
137 else if (getDereferenceableBytes() > 0 &&
144bool Argument::hasByValAttr()
const {
146 return hasAttribute(Attribute::ByVal);
149bool Argument::hasByRefAttr()
const {
152 return hasAttribute(Attribute::ByRef);
155bool Argument::hasSwiftSelfAttr()
const {
156 return getParent()->hasParamAttribute(getArgNo(), Attribute::SwiftSelf);
159bool Argument::hasSwiftErrorAttr()
const {
160 return getParent()->hasParamAttribute(getArgNo(), Attribute::SwiftError);
163bool Argument::hasInAllocaAttr()
const {
165 return hasAttribute(Attribute::InAlloca);
168bool Argument::hasPreallocatedAttr()
const {
171 return hasAttribute(Attribute::Preallocated);
174bool Argument::hasPassPointeeByValueCopyAttr()
const {
177 return Attrs.hasParamAttr(getArgNo(), Attribute::ByVal) ||
178 Attrs.hasParamAttr(getArgNo(), Attribute::InAlloca) ||
179 Attrs.hasParamAttr(getArgNo(), Attribute::Preallocated);
182bool Argument::hasPointeeInMemoryValueAttr()
const {
186 return Attrs.hasParamAttr(getArgNo(), Attribute::ByVal) ||
187 Attrs.hasParamAttr(getArgNo(), Attribute::StructRet) ||
188 Attrs.hasParamAttr(getArgNo(), Attribute::InAlloca) ||
189 Attrs.hasParamAttr(getArgNo(), Attribute::Preallocated) ||
190 Attrs.hasParamAttr(getArgNo(), Attribute::ByRef);
214 getParent()->getAttributes().getParamAttrs(getArgNo());
216 return DL.getTypeAllocSize(MemTy);
220Type *Argument::getPointeeInMemoryValueType()
const {
222 getParent()->getAttributes().getParamAttrs(getArgNo());
228 return getParent()->getParamAlign(getArgNo());
231MaybeAlign Argument::getParamStackAlign()
const {
232 return getParent()->getParamStackAlign(getArgNo());
235Type *Argument::getParamByValType()
const {
237 return getParent()->getParamByValType(getArgNo());
240Type *Argument::getParamStructRetType()
const {
242 return getParent()->getParamStructRetType(getArgNo());
245Type *Argument::getParamByRefType()
const {
247 return getParent()->getParamByRefType(getArgNo());
250Type *Argument::getParamInAllocaType()
const {
252 return getParent()->getParamInAllocaType(getArgNo());
255uint64_t Argument::getDereferenceableBytes()
const {
257 "Only pointers have dereferenceable bytes");
258 return getParent()->getParamDereferenceableBytes(getArgNo());
261uint64_t Argument::getDereferenceableOrNullBytes()
const {
263 "Only pointers have dereferenceable bytes");
264 return getParent()->getParamDereferenceableOrNullBytes(getArgNo());
268 return getParent()->getParamNoFPClass(getArgNo());
271std::optional<ConstantRange> Argument::getRange()
const {
272 const Attribute RangeAttr = getAttribute(llvm::Attribute::Range);
278bool Argument::hasNestAttr()
const {
280 return hasAttribute(Attribute::Nest);
283bool Argument::hasNoAliasAttr()
const {
285 return hasAttribute(Attribute::NoAlias);
288bool Argument::hasNoCaptureAttr()
const {
290 return hasAttribute(Attribute::NoCapture);
293bool Argument::hasNoFreeAttr()
const {
295 return hasAttribute(Attribute::NoFree);
298bool Argument::hasStructRetAttr()
const {
300 return hasAttribute(Attribute::StructRet);
303bool Argument::hasInRegAttr()
const {
304 return hasAttribute(Attribute::InReg);
307bool Argument::hasReturnedAttr()
const {
308 return hasAttribute(Attribute::Returned);
311bool Argument::hasZExtAttr()
const {
312 return hasAttribute(Attribute::ZExt);
315bool Argument::hasSExtAttr()
const {
316 return hasAttribute(Attribute::SExt);
319bool Argument::onlyReadsMemory()
const {
321 return Attrs.hasParamAttr(getArgNo(), Attribute::ReadOnly) ||
322 Attrs.hasParamAttr(getArgNo(), Attribute::ReadNone);
327 AL =
AL.addParamAttributes(Parent->getContext(), getArgNo(),
B);
332 getParent()->addParamAttr(getArgNo(), Kind);
336 getParent()->addParamAttr(getArgNo(), Attr);
340 getParent()->removeParamAttr(getArgNo(), Kind);
345 AL =
AL.removeParamAttributes(Parent->getContext(), getArgNo(), AM);
350 return getParent()->hasParamAttribute(getArgNo(), Kind);
353bool Argument::hasAttribute(
StringRef Kind)
const {
354 return getParent()->hasParamAttribute(getArgNo(), Kind);
358 return getParent()->getParamAttribute(getArgNo(), Kind);
362 return getParent()->getAttributes().getParamAttrs(getArgNo());
370 return getType()->getContext();
373const DataLayout &Function::getDataLayout()
const {
377unsigned Function::getInstructionCount()
const {
378 unsigned NumInstrs = 0;
380 NumInstrs += std::distance(BB.instructionsWithoutDebug().begin(),
381 BB.instructionsWithoutDebug().end());
387 return Create(Ty,
Linkage,
M.getDataLayout().getProgramAddressSpace(),
N, &M);
392 unsigned AddrSpace,
const Twine &
N,
397 if (UWTable != UWTableKind::None)
398 B.addUWTableAttr(UWTable);
399 switch (
M->getFramePointer()) {
400 case FramePointerKind::None:
403 case FramePointerKind::Reserved:
404 B.addAttribute(
"frame-pointer",
"reserved");
406 case FramePointerKind::NonLeaf:
407 B.addAttribute(
"frame-pointer",
"non-leaf");
409 case FramePointerKind::All:
410 B.addAttribute(
"frame-pointer",
"all");
413 if (
M->getModuleFlag(
"function_return_thunk_extern"))
414 B.addAttribute(Attribute::FnRetThunkExtern);
415 StringRef DefaultCPU =
F->getContext().getDefaultTargetCPU();
416 if (!DefaultCPU.
empty())
417 B.addAttribute(
"target-cpu", DefaultCPU);
418 StringRef DefaultFeatures =
F->getContext().getDefaultTargetFeatures();
419 if (!DefaultFeatures.
empty())
420 B.addAttribute(
"target-features", DefaultFeatures);
423 auto isModuleAttributeSet = [&](
const StringRef &ModAttr) ->
bool {
425 mdconst::extract_or_null<ConstantInt>(
M->getModuleFlag(ModAttr));
426 return Attr && !Attr->isZero();
429 auto AddAttributeIfSet = [&](
const StringRef &ModAttr) {
430 if (isModuleAttributeSet(ModAttr))
431 B.addAttribute(ModAttr);
435 if (isModuleAttributeSet(
"sign-return-address"))
436 SignType =
"non-leaf";
437 if (isModuleAttributeSet(
"sign-return-address-all"))
439 if (SignType !=
"none") {
440 B.addAttribute(
"sign-return-address", SignType);
441 B.addAttribute(
"sign-return-address-key",
442 isModuleAttributeSet(
"sign-return-address-with-bkey")
446 AddAttributeIfSet(
"branch-target-enforcement");
447 AddAttributeIfSet(
"branch-protection-pauth-lr");
448 AddAttributeIfSet(
"guarded-control-stack");
454void Function::removeFromParent() {
455 getParent()->getFunctionList().remove(getIterator());
458void Function::eraseFromParent() {
459 getParent()->getFunctionList().erase(getIterator());
465#ifdef EXPENSIVE_CHECKS
467 auto FromFEnd = FromF->
end();
468 for (
auto It = FromBeginIt; It != FromEndIt; ++It)
469 assert(It != FromFEnd &&
"FromBeginIt not before FromEndIt!");
471 BasicBlocks.splice(ToIt, FromF->BasicBlocks, FromBeginIt, FromEndIt);
476 return BasicBlocks.erase(FromIt, ToIt);
486 if (AddrSpace ==
static_cast<unsigned>(-1))
487 return M ?
M->getDataLayout().getProgramAddressSpace() : 0;
496 assert(FunctionType::isValidReturnType(getReturnType()) &&
497 "invalid return type");
498 setGlobalObjectSubClassData(0);
501 if (!getContext().shouldDiscardValueNames())
505 if (Ty->getNumParams())
506 setValueSubclassData(1);
513 HasLLVMReservedName =
getName().starts_with(
"llvm.");
518 setAttributes(Intrinsic::getAttributes(getContext(), IntID));
521Function::~Function() {
522 validateBlockNumbers();
534void Function::BuildLazyArguments()
const {
536 auto *FT = getFunctionType();
538 Arguments = std::allocator<Argument>().allocate(NumArgs);
539 for (
unsigned i = 0, e = NumArgs; i !=
e; ++i) {
540 Type *ArgTy = FT->getParamType(i);
541 assert(!ArgTy->
isVoidTy() &&
"Cannot have void typed arguments!");
547 unsigned SDC = getSubclassDataFromValue();
549 const_cast<Function*
>(
this)->setValueSubclassData(SDC);
550 assert(!hasLazyArguments());
557bool Function::isConstrainedFPIntrinsic()
const {
561void Function::clearArguments() {
566 std::allocator<Argument>().deallocate(
Arguments, NumArgs);
570void Function::stealArgumentListFrom(
Function &Src) {
571 assert(isDeclaration() &&
"Expected no references to current arguments");
574 if (!hasLazyArguments()) {
576 [](
const Argument &
A) {
return A.use_empty(); }) &&
577 "Expected arguments to be unused in declaration");
579 setValueSubclassData(getSubclassDataFromValue() | (1 << 0));
583 if (Src.hasLazyArguments())
587 assert(arg_size() == Src.arg_size());
589 Src.Arguments =
nullptr;
602 setValueSubclassData(getSubclassDataFromValue() & ~(1 << 0));
603 assert(!hasLazyArguments());
604 Src.setValueSubclassData(Src.getSubclassDataFromValue() | (1 << 0));
607void Function::deleteBodyImpl(
bool ShouldDrop) {
608 setIsMaterializable(
false);
615 while (!BasicBlocks.empty())
616 BasicBlocks.begin()->eraseFromParent();
618 if (getNumOperands()) {
621 User::dropAllReferences();
622 setNumHungOffUseOperands(0);
625 auto *CPN = ConstantPointerNull::get(PointerType::get(getContext(), 0));
630 setValueSubclassData(getSubclassDataFromValue() & ~0xe);
637void Function::addAttributeAtIndex(
unsigned i,
Attribute Attr) {
638 AttributeSets = AttributeSets.addAttributeAtIndex(getContext(), i, Attr);
642 AttributeSets = AttributeSets.addFnAttribute(getContext(), Kind);
646 AttributeSets = AttributeSets.addFnAttribute(getContext(), Kind, Val);
649void Function::addFnAttr(
Attribute Attr) {
650 AttributeSets = AttributeSets.addFnAttribute(getContext(), Attr);
653void Function::addFnAttrs(
const AttrBuilder &Attrs) {
654 AttributeSets = AttributeSets.addFnAttributes(getContext(), Attrs);
658 AttributeSets = AttributeSets.addRetAttribute(getContext(), Kind);
661void Function::addRetAttr(
Attribute Attr) {
662 AttributeSets = AttributeSets.addRetAttribute(getContext(), Attr);
665void Function::addRetAttrs(
const AttrBuilder &Attrs) {
666 AttributeSets = AttributeSets.addRetAttributes(getContext(), Attrs);
670 AttributeSets = AttributeSets.addParamAttribute(getContext(), ArgNo, Kind);
673void Function::addParamAttr(
unsigned ArgNo,
Attribute Attr) {
674 AttributeSets = AttributeSets.addParamAttribute(getContext(), ArgNo, Attr);
677void Function::addParamAttrs(
unsigned ArgNo,
const AttrBuilder &Attrs) {
678 AttributeSets = AttributeSets.addParamAttributes(getContext(), ArgNo, Attrs);
682 AttributeSets = AttributeSets.removeAttributeAtIndex(getContext(), i, Kind);
685void Function::removeAttributeAtIndex(
unsigned i,
StringRef Kind) {
686 AttributeSets = AttributeSets.removeAttributeAtIndex(getContext(), i, Kind);
690 AttributeSets = AttributeSets.removeFnAttribute(getContext(), Kind);
693void Function::removeFnAttr(
StringRef Kind) {
694 AttributeSets = AttributeSets.removeFnAttribute(getContext(), Kind);
698 AttributeSets = AttributeSets.removeFnAttributes(getContext(), AM);
702 AttributeSets = AttributeSets.removeRetAttribute(getContext(), Kind);
705void Function::removeRetAttr(
StringRef Kind) {
706 AttributeSets = AttributeSets.removeRetAttribute(getContext(), Kind);
710 AttributeSets = AttributeSets.removeRetAttributes(getContext(), Attrs);
714 AttributeSets = AttributeSets.removeParamAttribute(getContext(), ArgNo, Kind);
717void Function::removeParamAttr(
unsigned ArgNo,
StringRef Kind) {
718 AttributeSets = AttributeSets.removeParamAttribute(getContext(), ArgNo, Kind);
721void Function::removeParamAttrs(
unsigned ArgNo,
const AttributeMask &Attrs) {
723 AttributeSets.removeParamAttributes(getContext(), ArgNo, Attrs);
726void Function::addDereferenceableParamAttr(
unsigned ArgNo,
uint64_t Bytes) {
728 AttributeSets.addDereferenceableParamAttr(getContext(), ArgNo, Bytes);
732 return AttributeSets.hasFnAttr(Kind);
735bool Function::hasFnAttribute(
StringRef Kind)
const {
736 return AttributeSets.hasFnAttr(Kind);
740 return AttributeSets.hasRetAttr(Kind);
743bool Function::hasParamAttribute(
unsigned ArgNo,
745 return AttributeSets.hasParamAttr(ArgNo, Kind);
748bool Function::hasParamAttribute(
unsigned ArgNo,
StringRef Kind)
const {
749 return AttributeSets.hasParamAttr(ArgNo, Kind);
752Attribute Function::getAttributeAtIndex(
unsigned i,
754 return AttributeSets.getAttributeAtIndex(i, Kind);
758 return AttributeSets.getAttributeAtIndex(i, Kind);
761bool Function::hasAttributeAtIndex(
unsigned Idx,
763 return AttributeSets.hasAttributeAtIndex(
Idx, Kind);
767 return AttributeSets.getFnAttr(Kind);
771 return AttributeSets.getFnAttr(Kind);
775 return AttributeSets.getRetAttr(Kind);
782 if (
A.isStringAttribute()) {
784 if (Str.getAsInteger(0, Result))
785 getContext().emitError(
"cannot parse integer attribute " +
Name);
792Attribute Function::getParamAttribute(
unsigned ArgNo,
794 return AttributeSets.getParamAttr(ArgNo, Kind);
797void Function::addDereferenceableOrNullParamAttr(
unsigned ArgNo,
799 AttributeSets = AttributeSets.addDereferenceableOrNullParamAttr(getContext(),
804 AttributeSets = AttributeSets.addRangeRetAttr(getContext(), CR);
808 if (&FPType == &APFloat::IEEEsingle()) {
816 return getDenormalModeRaw();
820 Attribute Attr = getFnAttribute(
"denormal-fp-math");
826 Attribute Attr = getFnAttribute(
"denormal-fp-math-f32");
832 return DenormalMode::getInvalid();
835const std::string &Function::getGC()
const {
836 assert(hasGC() &&
"Function has no collector");
837 return getContext().getGC(*
this);
840void Function::setGC(std::string Str) {
841 setValueSubclassDataBit(14, !Str.empty());
842 getContext().setGC(*
this, std::move(Str));
845void Function::clearGC() {
848 getContext().deleteGC(*
this);
849 setValueSubclassDataBit(14,
false);
852bool Function::hasStackProtectorFnAttr()
const {
853 return hasFnAttribute(Attribute::StackProtect) ||
854 hasFnAttribute(Attribute::StackProtectStrong) ||
855 hasFnAttribute(Attribute::StackProtectReq);
860void Function::copyAttributesFrom(
const Function *Src) {
861 GlobalObject::copyAttributesFrom(Src);
862 setCallingConv(Src->getCallingConv());
863 setAttributes(Src->getAttributes());
868 if (Src->hasPersonalityFn())
869 setPersonalityFn(Src->getPersonalityFn());
870 if (Src->hasPrefixData())
871 setPrefixData(Src->getPrefixData());
872 if (Src->hasPrologueData())
873 setPrologueData(Src->getPrologueData());
880 addFnAttr(Attribute::getWithMemoryEffects(getContext(), ME));
884bool Function::doesNotAccessMemory()
const {
885 return getMemoryEffects().doesNotAccessMemory();
887void Function::setDoesNotAccessMemory() {
888 setMemoryEffects(MemoryEffects::none());
892bool Function::onlyReadsMemory()
const {
893 return getMemoryEffects().onlyReadsMemory();
895void Function::setOnlyReadsMemory() {
896 setMemoryEffects(getMemoryEffects() & MemoryEffects::readOnly());
900bool Function::onlyWritesMemory()
const {
901 return getMemoryEffects().onlyWritesMemory();
903void Function::setOnlyWritesMemory() {
904 setMemoryEffects(getMemoryEffects() & MemoryEffects::writeOnly());
909bool Function::onlyAccessesArgMemory()
const {
910 return getMemoryEffects().onlyAccessesArgPointees();
912void Function::setOnlyAccessesArgMemory() {
913 setMemoryEffects(getMemoryEffects() & MemoryEffects::argMemOnly());
918bool Function::onlyAccessesInaccessibleMemory()
const {
919 return getMemoryEffects().onlyAccessesInaccessibleMem();
921void Function::setOnlyAccessesInaccessibleMemory() {
922 setMemoryEffects(getMemoryEffects() & MemoryEffects::inaccessibleMemOnly());
927bool Function::onlyAccessesInaccessibleMemOrArgMem()
const {
928 return getMemoryEffects().onlyAccessesInaccessibleOrArgMem();
930void Function::setOnlyAccessesInaccessibleMemOrArgMem() {
931 setMemoryEffects(getMemoryEffects() &
932 MemoryEffects::inaccessibleOrArgMemOnly());
935bool Function::isTargetIntrinsic()
const {
936 return Intrinsic::isTargetIntrinsic(IntID);
939void Function::updateAfterNameChange() {
940 LibFuncCache = UnknownLibFunc;
942 if (!
Name.starts_with(
"llvm.")) {
943 HasLLVMReservedName =
false;
944 IntID = Intrinsic::not_intrinsic;
947 HasLLVMReservedName =
true;
948 IntID = Intrinsic::lookupIntrinsicID(
Name);
955bool Function::hasAddressTaken(
const User **PutOffender,
956 bool IgnoreCallbackUses,
957 bool IgnoreAssumeLikeCalls,
bool IgnoreLLVMUsed,
958 bool IgnoreARCAttachedCall,
959 bool IgnoreCastedDirectCall)
const {
961 const User *FU =
U.getUser();
962 if (isa<BlockAddress>(FU))
965 if (IgnoreCallbackUses) {
967 if (ACS && ACS.isCallbackCall())
971 const auto *
Call = dyn_cast<CallBase>(FU);
973 if (IgnoreAssumeLikeCalls &&
974 isa<BitCastOperator, AddrSpaceCastOperator>(FU) &&
976 if (const auto *I = dyn_cast<IntrinsicInst>(U))
977 return I->isAssumeLikeIntrinsic();
984 const User *FUU = FU;
985 if (isa<BitCastOperator, AddrSpaceCastOperator>(FU) &&
989 if (const auto *GV = dyn_cast<GlobalVariable>(U))
990 return GV->hasName() &&
991 (GV->getName() ==
"llvm.compiler.used" ||
992 GV->getName() ==
"llvm.used");
1002 if (IgnoreAssumeLikeCalls) {
1003 if (
const auto *
I = dyn_cast<IntrinsicInst>(Call))
1004 if (
I->isAssumeLikeIntrinsic())
1008 if (!
Call->isCallee(&U) || (!IgnoreCastedDirectCall &&
1009 Call->getFunctionType() != getFunctionType())) {
1010 if (IgnoreARCAttachedCall &&
1011 Call->isOperandBundleOfType(LLVMContext::OB_clang_arc_attachedcall,
1023bool Function::isDefTriviallyDead()
const {
1025 if (!hasLinkOnceLinkage() && !hasLocalLinkage() &&
1026 !hasAvailableExternallyLinkage())
1031 if (!isa<BlockAddress>(U))
1039bool Function::callsFunctionThatReturnsTwice()
const {
1041 if (
const auto *Call = dyn_cast<CallBase>(&
I))
1042 if (
Call->hasFnAttr(Attribute::ReturnsTwice))
1048Constant *Function::getPersonalityFn()
const {
1049 assert(hasPersonalityFn() && getNumOperands());
1050 return cast<Constant>(
Op<0>());
1053void Function::setPersonalityFn(
Constant *Fn) {
1054 setHungoffOperand<0>(Fn);
1055 setValueSubclassDataBit(3, Fn !=
nullptr);
1058Constant *Function::getPrefixData()
const {
1059 assert(hasPrefixData() && getNumOperands());
1060 return cast<Constant>(
Op<1>());
1063void Function::setPrefixData(
Constant *PrefixData) {
1064 setHungoffOperand<1>(PrefixData);
1065 setValueSubclassDataBit(1, PrefixData !=
nullptr);
1068Constant *Function::getPrologueData()
const {
1069 assert(hasPrologueData() && getNumOperands());
1070 return cast<Constant>(
Op<2>());
1073void Function::setPrologueData(
Constant *PrologueData) {
1074 setHungoffOperand<2>(PrologueData);
1075 setValueSubclassDataBit(2, PrologueData !=
nullptr);
1078void Function::allocHungoffUselist() {
1080 if (getNumOperands())
1083 allocHungoffUses(3,
false);
1084 setNumHungOffUseOperands(3);
1087 auto *CPN = ConstantPointerNull::get(PointerType::get(getContext(), 0));
1094void Function::setHungoffOperand(
Constant *
C) {
1096 allocHungoffUselist();
1098 }
else if (getNumOperands()) {
1099 Op<Idx>().set(ConstantPointerNull::get(PointerType::get(getContext(), 0)));
1103void Function::setValueSubclassDataBit(
unsigned Bit,
bool On) {
1104 assert(Bit < 16 &&
"SubclassData contains only 16 bits");
1106 setValueSubclassData(getSubclassDataFromValue() | (1 << Bit));
1108 setValueSubclassData(getSubclassDataFromValue() & ~(1 << Bit));
1114 auto PrevCount = getEntryCount();
1115 assert(!PrevCount || PrevCount->getType() == Count.
getType());
1118 auto ImportGUIDs = getImportGUIDs();
1119 if (S ==
nullptr && ImportGUIDs.size())
1124 LLVMContext::MD_prof,
1133std::optional<ProfileCount> Function::getEntryCount(
bool AllowSynthetic)
const {
1134 MDNode *MD = getMetadata(LLVMContext::MD_prof);
1137 if (MDS->getString() ==
"function_entry_count") {
1143 return std::nullopt;
1145 }
else if (AllowSynthetic &&
1146 MDS->getString() ==
"synthetic_function_entry_count") {
1152 return std::nullopt;
1157 if (
MDNode *MD = getMetadata(LLVMContext::MD_prof))
1159 if (MDS->getString() ==
"function_entry_count")
1161 R.insert(mdconst::extract<ConstantInt>(MD->
getOperand(i))
1167void Function::setSectionPrefix(
StringRef Prefix) {
1169 setMetadata(LLVMContext::MD_section_prefix,
1170 MDB.createFunctionSectionPrefix(Prefix));
1173std::optional<StringRef> Function::getSectionPrefix()
const {
1174 if (
MDNode *MD = getMetadata(LLVMContext::MD_section_prefix)) {
1176 "function_section_prefix" &&
1177 "Metadata not match");
1178 return cast<MDString>(MD->
getOperand(1))->getString();
1180 return std::nullopt;
1183bool Function::nullPointerIsDefined()
const {
1184 return hasFnAttribute(Attribute::NullPointerIsValid);
1188 if (
F &&
F->nullPointerIsDefined())
static unsigned getIntrinsicID(const SDNode *N)
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 GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Given that RA is a live propagate it s liveness to any other values it uses(according to Uses). void DeadArgumentEliminationPass
This file defines the DenseSet and SmallDenseSet classes.
Module.h This file contains the declarations for the Module class.
This defines the Use class.
Function::ProfileCount ProfileCount
llvm::cl::opt< bool > UseNewDbgInfoFormat
static StringRef getName(Value *V)
static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Development, "development", "for training")))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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)
uint64_t getZExtValue() const
Get zero extended value.
This class represents an incoming formal argument to a Function.
MemoryEffects getMemoryEffects() const
Returns memory effects of the function.
Type * getInAllocaType() const
Type * getByValType() const
Type * getStructRetType() const
Type * getPreallocatedType() const
Type * getByRefType() const
const ConstantRange & getRange() const
Returns the value of the range attribute.
StringRef getValueAsString() const
Return the attribute's value as a string.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
bool isValid() const
Return true if the attribute is any kind of attribute.
LLVM Basic Block Representation.
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.
This class represents a range of values.
This is an important base class in LLVM.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Implements a dense probed hash-table based set.
Class to represent profile counts.
uint64_t getCount() const
ProfileCountType getType() const
BasicBlockListType::iterator iterator
This is an important class for using LLVM in a threaded context.
const MDOperand & getOperand(unsigned I) const
unsigned getNumOperands() const
Return number of MDNode operands.
A Module instance is used to store all the information related to an LLVM module.
bool IsNewDbgInfoFormat
Is this Module using intrinsics to record the position of debugging information, or non-intrinsic rec...
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...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
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...
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVoidTy() const
Return true if this is 'void'.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
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)
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
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)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
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)
DenormalMode parseDenormalFPAttribute(StringRef Str)
Returns the denormal mode to use for inputs and outputs.
Represent subnormal handling kind for floating point instruction inputs and outputs.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.