56 #define DEBUG_TYPE "instrprof" 62 cl::desc(
"Set the range of size in memory intrinsic calls to be profiled " 63 "precisely, in a format of <start_val>:<end_val>"),
69 cl::desc(
"Set large value thresthold in memory intrinsic size profiling. " 70 "Value of 0 disables the large value profiling."),
76 cl::desc(
"Enable name string compression"),
80 "hash-based-counter-split",
81 cl::desc(
"Rename counter variable of a comdat function based on cfg hash"),
86 cl::desc(
"Do static counter allocation for value profiler"),
90 "vp-counters-per-site",
91 cl::desc(
"The average number of profile counters allocated " 92 "per value profiling site."),
101 cl::desc(
"Do counter update using atomic fetch add " 102 " for promoted counters only"),
111 cl::desc(
"Do counter register promotion"),
115 cl::desc(
"Max number counter promotions per loop to avoid" 116 " increasing register pressure too much"));
121 cl::desc(
"Max number of allowed counter promotions"));
125 cl::desc(
"The max number of exiting blocks of a loop to allow " 126 " speculative counter promotion"));
130 cl::desc(
"When the option is false, if the target block is in a loop, " 131 "the promotion will be disallowed unless the promoted counter " 132 " update can be further/iteratively promoted into an acyclic " 137 cl::desc(
"Allow counter promotion across the whole loop nest."));
139 class InstrProfilingLegacyPass :
public ModulePass {
145 InstrProfilingLegacyPass() :
ModulePass(ID) {}
150 return "Frontend instrumentation-based coverage lowering";
153 bool runOnModule(
Module &M)
override {
154 return InstrProf.
run(M, getAnalysis<TargetLibraryInfoWrapperPass>().getTLI());
172 PGOCounterPromoterHelper(
179 InsertPts(InsertPts), LoopToCandidates(LoopToCands), LI(LI) {
181 assert(isa<StoreInst>(S));
182 SSA.AddAvailableValue(PH,
Init);
185 void doExtraRewritesBeforeFinalDeletion()
const override {
186 for (
unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) {
192 Value *LiveInValue =
SSA.GetValueInMiddleOfBlock(ExitBlock);
195 if (AtomicCounterUpdatePromoted)
201 LoadInst *OldVal = Builder.CreateLoad(Addr,
"pgocount.promoted");
202 auto *NewVal = Builder.CreateAdd(OldVal, LiveInValue);
203 auto *NewStore = Builder.CreateStore(NewVal, Addr);
206 if (IterativeCounterPromotion) {
207 auto *TargetLoop = LI.getLoopFor(ExitBlock);
209 LoopToCandidates[TargetLoop].emplace_back(OldVal, NewStore);
226 class PGOCounterPromoter {
231 : LoopToCandidates(LoopToCands), ExitBlocks(), InsertPts(), L(CurLoop),
236 L.getExitBlocks(LoopExitBlocks);
238 for (
BasicBlock *ExitBlock : LoopExitBlocks) {
239 if (BlockSet.
insert(ExitBlock).second) {
240 ExitBlocks.push_back(ExitBlock);
246 bool run(int64_t *NumPromoted) {
248 if (ExitBlocks.size() == 0)
250 unsigned MaxProm = getMaxNumOfPromotionsInLoop(&L);
254 unsigned Promoted = 0;
255 for (
auto &Cand : LoopToCandidates[&L]) {
261 PGOCounterPromoterHelper Promoter(Cand.first, Cand.second,
SSA, InitVal,
262 L.getLoopPreheader(), ExitBlocks,
263 InsertPts, LoopToCandidates, LI);
266 if (Promoted >= MaxProm)
270 if (MaxNumOfPromotions != -1 && *NumPromoted >= MaxNumOfPromotions)
274 LLVM_DEBUG(
dbgs() << Promoted <<
" counters promoted for loop (depth=" 275 << L.getLoopDepth() <<
")\n");
276 return Promoted != 0;
280 bool allowSpeculativeCounterPromotion(
Loop *LP) {
282 L.getExitingBlocks(ExitingBlocks);
284 if (ExitingBlocks.
size() == 1)
286 if (ExitingBlocks.
size() > SpeculativeCounterPromotionMaxExiting)
292 unsigned getMaxNumOfPromotionsInLoop(
Loop *LP) {
311 if (ExitingBlocks.
size() == 1)
312 return MaxNumOfPromotionsPerLoop;
314 if (ExitingBlocks.
size() > SpeculativeCounterPromotionMaxExiting)
318 if (SpeculativeCounterPromotionToLoop)
319 return MaxNumOfPromotionsPerLoop;
322 unsigned MaxProm = MaxNumOfPromotionsPerLoop;
323 for (
auto *TargetBlock : LoopExitBlocks) {
324 auto *TargetLoop = LI.
getLoopFor(TargetBlock);
327 unsigned MaxPromForTarget = getMaxNumOfPromotionsInLoop(TargetLoop);
328 unsigned PendingCandsInTarget = LoopToCandidates[TargetLoop].size();
330 std::min(MaxProm,
std::max(MaxPromForTarget, PendingCandsInTarget) -
331 PendingCandsInTarget);
355 InstrProfilingLegacyPass,
"instrprof",
356 "Frontend instrumentation-based coverage lowering.",
false,
false)
359 InstrProfilingLegacyPass,
"instrprof",
360 "Frontend instrumentation-based coverage lowering.",
false,
false)
364 return new InstrProfilingLegacyPass(Options);
374 bool InstrProfiling::lowerIntrinsics(
Function *
F) {
375 bool MadeChange =
false;
376 PromotionCandidates.clear();
378 for (
auto I = BB.begin(),
E = BB.end();
I !=
E;) {
384 }
else if (
auto *Ind = dyn_cast<InstrProfValueProfileInst>(Instr)) {
385 lowerValueProfileInst(Ind);
394 promoteCounterLoadStores(F);
398 bool InstrProfiling::isCounterPromotionEnabled()
const {
399 if (DoCounterPromotion.getNumOccurrences() > 0)
400 return DoCounterPromotion;
402 return Options.DoCounterPromotion;
405 void InstrProfiling::promoteCounterLoadStores(
Function *F) {
406 if (!isCounterPromotionEnabled())
413 for (
const auto &
LoadStore : PromotionCandidates) {
420 LoopPromotionCandidates[ParentLoop].emplace_back(CounterLoad, CounterStore);
428 PGOCounterPromoter Promoter(LoopPromotionCandidates, *
Loop, LI);
429 Promoter.run(&TotalCountersPromoted);
455 ProfileDataMap.clear();
462 bool MadeChange = emitRuntimeHook();
476 for (
auto I = BB.begin(),
E = BB.end();
I !=
E;
I++)
477 if (
auto *Ind = dyn_cast<InstrProfValueProfileInst>(
I))
478 computeNumValueSiteCounts(Ind);
479 else if (FirstProfIncInst ==
nullptr)
484 if (FirstProfIncInst !=
nullptr)
485 static_cast<void>(getOrCreateRegionCounters(FirstProfIncInst));
491 if (CoverageNamesVar) {
492 lowerCoverageData(CoverageNamesVar);
503 emitInitialization();
509 bool IsRange =
false) {
515 Type *ParamTypes[] = {
516 #define VALUE_PROF_FUNC_PARAM(ParamType, ParamName, ParamLLVMType) ParamLLVMType 519 auto *ValueProfilingCallTy =
522 ValueProfilingCallTy);
524 Type *RangeParamTypes[] = {
525 #define VALUE_RANGE_PROF 1 526 #define VALUE_PROF_FUNC_PARAM(ParamType, ParamName, ParamLLVMType) ParamLLVMType 528 #undef VALUE_RANGE_PROF 530 auto *ValueRangeProfilingCallTy =
533 ValueRangeProfilingCallTy);
536 if (
Function *FunRes = dyn_cast<Function>(Res)) {
538 FunRes->addParamAttr(2, AK);
547 auto It = ProfileDataMap.find(Name);
548 if (It == ProfileDataMap.end()) {
549 PerFunctionProfileData
PD;
551 ProfileDataMap[
Name] =
PD;
552 }
else if (It->second.NumValueSites[ValueKind] <= Index)
553 It->second.NumValueSites[
ValueKind] = Index + 1;
558 auto It = ProfileDataMap.find(Name);
559 assert(It != ProfileDataMap.end() && It->second.DataVar &&
560 "value profiling detected in function with no counter incerement");
566 Index += It->second.NumValueSites[
Kind];
570 llvm::InstrProfValueKind::IPVK_MemOPSize);
574 Builder.CreateBitCast(DataVar, Builder.getInt8PtrTy()),
575 Builder.getInt32(Index)};
580 Builder.CreateBitCast(DataVar, Builder.getInt8PtrTy()),
581 Builder.getInt32(Index),
582 Builder.getInt64(MemOPSizeRangeStart),
583 Builder.getInt64(MemOPSizeRangeLast),
588 if (
auto AK = TLI->getExtAttrForI32Param(
false))
604 if (isCounterPromotionEnabled())
605 PromotionCandidates.emplace_back(cast<Instruction>(Load),
Store);
609 void InstrProfiling::lowerCoverageData(
GlobalVariable *CoverageNamesVar) {
615 assert(isa<GlobalVariable>(V) &&
"Missing reference to function name");
619 ReferencedNames.push_back(Name);
633 return (Prefix + Name).str();
637 return (Prefix + Name).str();
638 return (Prefix + Name +
"." +
Twine(FuncHash)).str();
645 !HasAvailableExternallyLinkage)
651 if (HasAvailableExternallyLinkage &&
704 auto It = ProfileDataMap.find(NamePtr);
705 PerFunctionProfileData
PD;
706 if (It != ProfileDataMap.end()) {
707 if (It->second.RegionCounters)
708 return It->second.RegionCounters;
717 Comdat *ProfileVarsComdat =
nullptr;
730 CounterPtr->setSection(
732 CounterPtr->setAlignment(8);
733 CounterPtr->setComdat(ProfileVarsComdat);
742 NS += PD.NumValueSites[
Kind];
751 ValuesVar->setSection(
753 ValuesVar->setAlignment(8);
754 ValuesVar->setComdat(ProfileVarsComdat);
763 Type *DataTypes[] = {
764 #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) LLVMType, 773 Constant *Int16ArrayVals[IPVK_Last + 1];
778 #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Init, 786 Data->setAlignment(INSTR_PROF_DATA_ALIGNMENT);
787 Data->setComdat(ProfileVarsComdat);
789 PD.RegionCounters = CounterPtr;
791 ProfileDataMap[NamePtr] =
PD;
794 UsedVars.push_back(
Data);
800 ReferencedNames.push_back(NamePtr);
805 void InstrProfiling::emitVNodes() {
806 if (!ValueProfileStaticAlloc)
816 for (
auto &
PD : ProfileDataMap) {
818 TotalNS +=
PD.second.NumValueSites[
Kind];
824 uint64_t NumCounters = TotalNS * NumCountersPerValueSite;
832 #define INSTR_PROF_MIN_VAL_COUNTS 10 837 Type *VNodeTypes[] = {
838 #define INSTR_PROF_VALUE_NODE(Type, LLVMType, Name, Init) LLVMType, 847 VNodesVar->setSection(
849 UsedVars.push_back(VNodesVar);
852 void InstrProfiling::emitNameData() {
853 std::string UncompressedData;
855 if (ReferencedNames.empty())
858 std::string CompressedNameStr;
860 DoNameCompression)) {
866 Ctx,
StringRef(CompressedNameStr),
false);
870 NamesSize = CompressedNameStr.size();
873 UsedVars.push_back(NamesVar);
875 for (
auto *NamePtr : ReferencedNames)
876 NamePtr->eraseFromParent();
879 void InstrProfiling::emitRegistration() {
891 if (Options.NoRedZone)
892 RegisterF->addFnAttr(Attribute::NoRedZone);
895 auto *RuntimeRegisterF =
901 if (
Data != NamesVar && !isa<Function>(
Data))
905 Type *ParamTypes[] = {VoidPtrTy, Int64Ty};
906 auto *NamesRegisterTy =
908 auto *NamesRegisterF =
918 bool InstrProfiling::emitRuntimeHook() {
938 User->addFnAttr(Attribute::NoInline);
939 if (Options.NoRedZone)
940 User->addFnAttr(Attribute::NoRedZone);
950 UsedVars.push_back(
User);
954 void InstrProfiling::emitUses() {
955 if (!UsedVars.empty())
959 void InstrProfiling::emitInitialization() {
960 StringRef InstrProfileOutput = Options.InstrProfileOutput;
962 if (!InstrProfileOutput.
empty()) {
968 ProfileNameConst, INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_NAME_VAR));
969 if (TT.supportsCOMDAT()) {
972 StringRef(INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_NAME_VAR))));
986 F->addFnAttr(Attribute::NoInline);
987 if (Options.NoRedZone)
988 F->addFnAttr(Attribute::NoRedZone);
void setVisibility(VisibilityTypes V)
cl::opt< std::string > MemOPSizeRange("memop-size-range", cl::desc("Set the range of size in memory intrinsic calls to be profiled " "precisely, in a format of <start_val>:<end_val>"), cl::init(""))
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
StringRef getInstrProfRuntimeHookVarUseFuncName()
Return the name of the compiler generated function that references the runtime hook variable...
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
bool hasLocalLinkage() const
Helper class for SSA formation on a set of values defined in multiple blocks.
Value * getPointerOperand(Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
ConstantInt * getIndex() const
void dropAllReferences()
Drop all references to operands.
StringRef getInstrProfNameVarPrefix()
Return the name prefix of variables containing instrumented function names.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Compute iterated dominance frontiers using a linear time algorithm.
cl::opt< unsigned > MemOPSizeLarge("memop-size-large", cl::desc("Set large value thresthold in memory intrinsic size profiling. " "Value of 0 disables the large value profiling."), cl::init(8192))
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
StringRef getInstrProfRegFuncsName()
Return the name of function that registers all the per-function control data at program startup time ...
A Module instance is used to store all the information related to an LLVM module. ...
bool hasDedicatedExits() const
Return true if no exit block for the loop has a predecessor that is outside the loop.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
static bool containsProfilingIntrinsics(Module &M)
Check if the module contains uses of any profiling intrinsics.
#define INSTR_PROF_MIN_VAL_COUNTS
This class represents a function call, abstracting a target machine's calling convention.
bool hasAvailableExternallyLinkage() const
bool canRenameComdatFunc(const Function &F, bool CheckAddressTaken=false)
Check if we can safely rename this Comdat function.
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
const GlobalVariable * getNamedGlobal(StringRef Name) const
Return the global variable in the module with the specified name, of arbitrary type.
Like Internal, but omit from symbol table.
Externally visible function.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
This file provides the interface for LLVM's PGO Instrumentation lowering pass.
std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
An instruction for reading from memory.
static IntegerType * getInt64Ty(LLVMContext &C)
ModulePass * createInstrProfilingLegacyPass(const InstrProfOptions &Options=InstrProfOptions())
Insert frontend instrumentation based profiling.
static IntegerType * getInt16Ty(LLVMContext &C)
StringRef getInstrProfValuesVarPrefix()
Return the name prefix of value profile variables.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Attribute::AttrKind getExtAttrForI32Param(bool Signed=true) const
Returns extension attribute kind to be used for i32 parameters corresponding to C-level int or unsign...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
StringRef getInstrProfInitFuncName()
Return the name of the runtime initialization method that is generated by the compiler.
std::string toString(Error E)
Write all error messages (if any) in E to a string.
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
StringRef getInstrProfDataVarPrefix()
Return the name prefix of variables containing per-function control data.
LLVMContext & getContext() const
Get the global data context.
Instrumentation based profiling lowering pass.
ReturnInst * CreateRet(Value *V)
Create a 'ret <val>' instruction.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This file contains the simple types necessary to represent the attributes associated with functions a...
Error collectPGOFuncNameStrings(ArrayRef< std::string > NameStrs, bool doCompression, std::string &Result)
Given a vector of strings (function PGO names) NameStrs, the method generates a combined string Resul...
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
StringRef getCoverageUnusedNamesVarName()
Return the name of the internal variable recording the array of PGO name vars referenced by the cover...
static StructType * get(LLVMContext &Context, ArrayRef< Type *> Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
StringRef getInstrProfNamesRegFuncName()
Return the name of the runtime interface that registers the PGO name strings.
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
void getExitBlocks(SmallVectorImpl< BlockT *> &ExitBlocks) const
Return all of the successor blocks of this loop.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
Type * getType() const
All values are typed, get the type of this value.
void appendToUsed(Module &M, ArrayRef< GlobalValue *> Values)
Adds global values to the llvm.used list.
Class to represent array types.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LinkageTypes getLinkage() const
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool hasLinkOnceLinkage() const
GlobalVariable * getName() const
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Value * getOperand(unsigned i) const
ConstantInt * getNumCounters() const
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
bool isIRPGOFlagSet(const Module *M)
Check if INSTR_PROF_RAW_VERSION_VAR is defined.
static std::string getVarName(InstrProfIncrementInst *Inc, StringRef Prefix)
Get the name of a profiling variable for a particular function.
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
LoadInst * CreateLoad(Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ptr, "...")' correctly, instead of converting the string to 'bool' fo...
void getMemOPSizeRangeFromOption(StringRef Str, int64_t &RangeStart, int64_t &RangeLast)
bool needsComdatForCounter(const Function &F, const Module &M)
Check if we can use Comdat for profile variables.
Same, but only replaced by something equivalent.
initializer< Ty > init(const Ty &Val)
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
A set of analyses that are preserved following a run of a transformation pass.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
VisibilityTypes getVisibility() const
ConstantInt * getIndex() const
static Constant * getOrInsertValueProfilingCall(Module &M, const TargetLibraryInfo &TLI, bool IsRange=false)
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
StringRef getInstrProfValueProfFuncName()
Return the name profile runtime entry point to do value profiling for a given site.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
StringRef getInstrProfNamesVarName()
Return the name of the variable holding the strings (possibly compressed) of all function's PGO names...
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
Represent the analysis usage information of a pass.
static Type * getVoidTy(LLVMContext &C)
bool any_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
static bool shouldRecordFunctionAddr(Function *F)
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static Constant * get(StructType *T, ArrayRef< Constant *> V)
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
void getExitingBlocks(SmallVectorImpl< BlockT *> &ExitingBlocks) const
Return all blocks inside the loop that have successors outside of the loop.
StringRef toStringRef(bool B)
Construct a string ref from a boolean.
const Constant * stripPointerCasts() const
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static bool needsRuntimeRegistrationOfSectionRange(const Module &M)
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
Triple - Helper class for working with autoconf configuration names.
StringRef getInstrProfCountersVarPrefix()
Return the name prefix of profile counter variables.
unsigned getNumOperands() const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
Provides information about what library functions are available for the current target.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
void appendToGlobalCtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)
Append F to the list of global ctors of module M with the given Priority.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
void setLinkage(LinkageTypes LT)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
ConstantArray - Constant Array Declarations.
StringRef getInstrProfRuntimeHookVarName()
Return the name of the hook variable defined in profile runtime library.
StringRef getInstrProfRegFuncName()
Return the name of the runtime interface that registers per-function control data for one instrumente...
Options for the frontend instrumentation based profiling pass.
Value * CreateConstInBoundsGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
This represents the llvm.instrprof_increment intrinsic.
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
static IntegerType * getInt32Ty(LLVMContext &C)
Value * getTargetValue() const
Represents a single loop in the control flow graph.
ConstantInt * getHash() const
StringRef getName() const
Return a constant reference to the value's name.
const Function * getParent() const
Return the enclosing method, or null if none.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Keep one copy of named function when linking (weak)
Rename collisions when linking (static functions).
SmallVector< LoopT *, 4 > getLoopsInPreorder()
Return all of the loops in the function in preorder across the loop nests, with siblings in forward p...
Analysis pass providing the TargetLibraryInfo.
bool hasAddressTaken(const User **=nullptr) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef getInstrProfValueRangeProfFuncName()
Return the name profile runtime entry point to do value range profiling.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
StringRef getInstrProfVNodesVarName()
Return the name of value profile node array variables:
GlobalVariable * getName() const
Lightweight error class with error context and mandatory checking.
ConstantInt * getValueKind() const
static Comdat * getOrCreateProfileComdat(Module &M, Function &F, InstrProfIncrementInst *Inc)
StringRef - Represent a constant reference to a string, i.e.
A container for analyses that lazily runs them and caches their results.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
StringRef getInstrProfComdatPrefix()
Return the name prefix of the COMDAT group for instrumentation variables associated with a COMDAT fun...
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
static bool lowerIntrinsics(Module &M)
This represents the llvm.instrprof_value_profile intrinsic.
static InstrProfIncrementInst * castToIncrementInst(Instruction *Instr)
void setSection(StringRef S)
Change the section for this global.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
INITIALIZE_PASS_BEGIN(InstrProfilingLegacyPass, "instrprof", "Frontend instrumentation-based coverage lowering.", false, false) INITIALIZE_PASS_END(InstrProfilingLegacyPass
const BasicBlock * getParent() const
CallInst * CreateCall(Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)