57 #define DEBUG_TYPE "instrprof" 63 cl::desc(
"Set the range of size in memory intrinsic calls to be profiled " 64 "precisely, in a format of <start_val>:<end_val>"),
70 cl::desc(
"Set large value thresthold in memory intrinsic size profiling. " 71 "Value of 0 disables the large value profiling."),
77 cl::desc(
"Enable name string compression"),
81 "hash-based-counter-split",
82 cl::desc(
"Rename counter variable of a comdat function based on cfg hash"),
87 cl::desc(
"Do static counter allocation for value profiler"),
91 "vp-counters-per-site",
92 cl::desc(
"The average number of profile counters allocated " 93 "per value profiling site."),
102 cl::desc(
"Make all profile counter updates atomic (for testing only)"),
107 cl::desc(
"Do counter update using atomic fetch add " 108 " for promoted counters only"),
117 cl::desc(
"Do counter register promotion"),
121 cl::desc(
"Max number counter promotions per loop to avoid" 122 " increasing register pressure too much"));
127 cl::desc(
"Max number of allowed counter promotions"));
131 cl::desc(
"The max number of exiting blocks of a loop to allow " 132 " speculative counter promotion"));
136 cl::desc(
"When the option is false, if the target block is in a loop, " 137 "the promotion will be disallowed unless the promoted counter " 138 " update can be further/iteratively promoted into an acyclic " 143 cl::desc(
"Allow counter promotion across the whole loop nest."));
145 class InstrProfilingLegacyPass :
public ModulePass {
151 InstrProfilingLegacyPass() :
ModulePass(ID) {}
152 InstrProfilingLegacyPass(
const InstrProfOptions &Options,
bool IsCS =
false)
156 return "Frontend instrumentation-based coverage lowering";
159 bool runOnModule(
Module &M)
override {
161 return this->getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
163 return InstrProf.
run(M, GetTLI);
181 PGOCounterPromoterHelper(
188 InsertPts(InsertPts), LoopToCandidates(LoopToCands), LI(LI) {
190 assert(isa<StoreInst>(S));
191 SSA.AddAvailableValue(PH,
Init);
194 void doExtraRewritesBeforeFinalDeletion()
override {
195 for (
unsigned i = 0,
e = ExitBlocks.size(); i !=
e; ++i) {
201 Value *LiveInValue =
SSA.GetValueInMiddleOfBlock(ExitBlock);
205 if (AtomicCounterUpdatePromoted)
211 LoadInst *OldVal = Builder.CreateLoad(Ty, Addr,
"pgocount.promoted");
212 auto *NewVal = Builder.CreateAdd(OldVal, LiveInValue);
213 auto *NewStore = Builder.CreateStore(NewVal, Addr);
216 if (IterativeCounterPromotion) {
217 auto *TargetLoop = LI.getLoopFor(ExitBlock);
219 LoopToCandidates[TargetLoop].emplace_back(OldVal, NewStore);
236 class PGOCounterPromoter {
241 : LoopToCandidates(LoopToCands), ExitBlocks(), InsertPts(), L(CurLoop),
246 L.getExitBlocks(LoopExitBlocks);
248 for (
BasicBlock *ExitBlock : LoopExitBlocks) {
249 if (BlockSet.
insert(ExitBlock).second) {
250 ExitBlocks.push_back(ExitBlock);
256 bool run(int64_t *NumPromoted) {
258 if (ExitBlocks.size() == 0)
260 unsigned MaxProm = getMaxNumOfPromotionsInLoop(&L);
264 unsigned Promoted = 0;
265 for (
auto &Cand : LoopToCandidates[&L]) {
273 auto *BB = Cand.first->getParent();
280 if (PreheaderCount &&
281 (PreheaderCount.getValue() * 3) >= (
InstrCount.getValue() * 2))
285 PGOCounterPromoterHelper Promoter(Cand.first, Cand.second,
SSA, InitVal,
286 L.getLoopPreheader(), ExitBlocks,
287 InsertPts, LoopToCandidates, LI);
290 if (Promoted >= MaxProm)
294 if (MaxNumOfPromotions != -1 && *NumPromoted >= MaxNumOfPromotions)
298 LLVM_DEBUG(
dbgs() << Promoted <<
" counters promoted for loop (depth=" 299 << L.getLoopDepth() <<
")\n");
300 return Promoted != 0;
304 bool allowSpeculativeCounterPromotion(
Loop *LP) {
306 L.getExitingBlocks(ExitingBlocks);
308 if (ExitingBlocks.
size() == 1)
310 if (ExitingBlocks.
size() > SpeculativeCounterPromotionMaxExiting)
316 unsigned getMaxNumOfPromotionsInLoop(
Loop *LP) {
340 if (ExitingBlocks.
size() == 1)
341 return MaxNumOfPromotionsPerLoop;
343 if (ExitingBlocks.
size() > SpeculativeCounterPromotionMaxExiting)
347 if (SpeculativeCounterPromotionToLoop)
348 return MaxNumOfPromotionsPerLoop;
351 unsigned MaxProm = MaxNumOfPromotionsPerLoop;
352 for (
auto *TargetBlock : LoopExitBlocks) {
353 auto *TargetLoop = LI.
getLoopFor(TargetBlock);
356 unsigned MaxPromForTarget = getMaxNumOfPromotionsInLoop(TargetLoop);
357 unsigned PendingCandsInTarget = LoopToCandidates[TargetLoop].size();
359 std::min(MaxProm,
std::max(MaxPromForTarget, PendingCandsInTarget) -
360 PendingCandsInTarget);
389 InstrProfilingLegacyPass,
"instrprof",
390 "Frontend instrumentation-based coverage lowering.",
false,
false)
393 InstrProfilingLegacyPass,
"instrprof",
394 "Frontend instrumentation-based coverage lowering.",
false,
false)
399 return new InstrProfilingLegacyPass(Options, IsCS);
409 bool InstrProfiling::lowerIntrinsics(
Function *
F) {
410 bool MadeChange =
false;
411 PromotionCandidates.clear();
413 for (
auto I = BB.begin(),
E = BB.end();
I !=
E;) {
419 }
else if (
auto *Ind = dyn_cast<InstrProfValueProfileInst>(Instr)) {
420 lowerValueProfileInst(Ind);
429 promoteCounterLoadStores(F);
433 bool InstrProfiling::isCounterPromotionEnabled()
const {
434 if (DoCounterPromotion.getNumOccurrences() > 0)
435 return DoCounterPromotion;
437 return Options.DoCounterPromotion;
440 void InstrProfiling::promoteCounterLoadStores(
Function *F) {
441 if (!isCounterPromotionEnabled())
448 std::unique_ptr<BlockFrequencyInfo>
BFI;
449 if (Options.UseBFIInPromotion) {
450 std::unique_ptr<BranchProbabilityInfo> BPI;
455 for (
const auto &
LoadStore : PromotionCandidates) {
462 LoopPromotionCandidates[ParentLoop].emplace_back(CounterLoad, CounterStore);
470 PGOCounterPromoter Promoter(LoopPromotionCandidates, *
Loop, LI, BFI.get());
471 Promoter.run(&TotalCountersPromoted);
495 this->GetTLI = std::move(GetTLI);
498 ProfileDataMap.clear();
505 bool MadeChange = emitRuntimeHook();
519 for (
auto I = BB.begin(),
E = BB.end();
I !=
E;
I++)
520 if (
auto *Ind = dyn_cast<InstrProfValueProfileInst>(
I))
521 computeNumValueSiteCounts(Ind);
522 else if (FirstProfIncInst ==
nullptr)
527 if (FirstProfIncInst !=
nullptr)
528 static_cast<void>(getOrCreateRegionCounters(FirstProfIncInst));
534 if (CoverageNamesVar) {
535 lowerCoverageData(CoverageNamesVar);
546 emitInitialization();
552 bool IsRange =
false) {
558 AL = AL.addParamAttribute(M.
getContext(), 2, AK);
561 Type *ParamTypes[] = {
562 #define VALUE_PROF_FUNC_PARAM(ParamType, ParamName, ParamLLVMType) ParamLLVMType 565 auto *ValueProfilingCallTy =
568 ValueProfilingCallTy, AL);
570 Type *RangeParamTypes[] = {
571 #define VALUE_RANGE_PROF 1 572 #define VALUE_PROF_FUNC_PARAM(ParamType, ParamName, ParamLLVMType) ParamLLVMType 574 #undef VALUE_RANGE_PROF 576 auto *ValueRangeProfilingCallTy =
579 ValueRangeProfilingCallTy, AL);
587 auto It = ProfileDataMap.find(Name);
588 if (It == ProfileDataMap.end()) {
589 PerFunctionProfileData
PD;
591 ProfileDataMap[
Name] =
PD;
592 }
else if (It->second.NumValueSites[ValueKind] <= Index)
593 It->second.NumValueSites[
ValueKind] = Index + 1;
598 auto It = ProfileDataMap.find(Name);
599 assert(It != ProfileDataMap.end() && It->second.DataVar &&
600 "value profiling detected in function with no counter incerement");
606 Index += It->second.NumValueSites[
Kind];
610 llvm::InstrProfValueKind::IPVK_MemOPSize);
615 Builder.CreateBitCast(DataVar, Builder.getInt8PtrTy()),
616 Builder.getInt32(Index)};
621 Builder.CreateBitCast(DataVar, Builder.getInt8PtrTy()),
622 Builder.getInt32(Index),
623 Builder.getInt64(MemOPSizeRangeStart),
624 Builder.getInt64(MemOPSizeRangeLast),
629 if (
auto AK = TLI->getExtAttrForI32Param(
false))
643 if (Options.Atomic || AtomicCounterUpdateAll) {
651 if (isCounterPromotionEnabled())
652 PromotionCandidates.emplace_back(cast<Instruction>(Load),
Store);
657 void InstrProfiling::lowerCoverageData(
GlobalVariable *CoverageNamesVar) {
663 assert(isa<GlobalVariable>(V) &&
"Missing reference to function name");
667 ReferencedNames.push_back(Name);
681 return (Prefix + Name).str();
685 return (Prefix + Name).str();
686 return (Prefix + Name +
"." +
Twine(FuncHash)).str();
693 !HasAvailableExternallyLinkage)
699 if (HasAvailableExternallyLinkage &&
735 auto It = ProfileDataMap.find(NamePtr);
736 PerFunctionProfileData
PD;
737 if (It != ProfileDataMap.end()) {
738 if (It->second.RegionCounters)
739 return It->second.RegionCounters;
748 if (
TT.isOSBinFormatCOFF()) {
762 if (
TT.isOSBinFormatCOFF()) {
785 CounterPtr->setVisibility(Visibility);
786 CounterPtr->setSection(
788 CounterPtr->setAlignment(
Align(8));
789 MaybeSetComdat(CounterPtr);
790 CounterPtr->setLinkage(Linkage);
799 NS += PD.NumValueSites[
Kind];
807 ValuesVar->setVisibility(Visibility);
808 ValuesVar->setSection(
810 ValuesVar->setAlignment(
Align(8));
811 MaybeSetComdat(ValuesVar);
820 Type *DataTypes[] = {
821 #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) LLVMType, 830 Constant *Int16ArrayVals[IPVK_Last + 1];
835 #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Init, 841 Data->setVisibility(Visibility);
843 Data->setAlignment(
Align(INSTR_PROF_DATA_ALIGNMENT));
844 MaybeSetComdat(
Data);
845 Data->setLinkage(Linkage);
847 PD.RegionCounters = CounterPtr;
849 ProfileDataMap[NamePtr] =
PD;
852 UsedVars.push_back(
Data);
858 ReferencedNames.push_back(NamePtr);
863 void InstrProfiling::emitVNodes() {
864 if (!ValueProfileStaticAlloc)
874 for (
auto &
PD : ProfileDataMap) {
876 TotalNS +=
PD.second.NumValueSites[
Kind];
882 uint64_t NumCounters = TotalNS * NumCountersPerValueSite;
890 #define INSTR_PROF_MIN_VAL_COUNTS 10 895 Type *VNodeTypes[] = {
896 #define INSTR_PROF_VALUE_NODE(Type, LLVMType, Name, Init) LLVMType, 905 VNodesVar->setSection(
907 UsedVars.push_back(VNodesVar);
910 void InstrProfiling::emitNameData() {
911 std::string UncompressedData;
913 if (ReferencedNames.empty())
916 std::string CompressedNameStr;
918 DoNameCompression)) {
924 Ctx,
StringRef(CompressedNameStr),
false);
928 NamesSize = CompressedNameStr.size();
935 UsedVars.push_back(NamesVar);
937 for (
auto *NamePtr : ReferencedNames)
938 NamePtr->eraseFromParent();
941 void InstrProfiling::emitRegistration() {
953 if (Options.NoRedZone)
954 RegisterF->addFnAttr(Attribute::NoRedZone);
957 auto *RuntimeRegisterF =
963 if (
Data != NamesVar && !isa<Function>(
Data))
967 Type *ParamTypes[] = {VoidPtrTy, Int64Ty};
968 auto *NamesRegisterTy =
970 auto *NamesRegisterF =
980 bool InstrProfiling::emitRuntimeHook() {
1000 User->addFnAttr(Attribute::NoInline);
1001 if (Options.NoRedZone)
1002 User->addFnAttr(Attribute::NoRedZone);
1004 if (
TT.supportsCOMDAT())
1012 UsedVars.push_back(
User);
1016 void InstrProfiling::emitUses() {
1017 if (!UsedVars.empty())
1021 void InstrProfiling::emitInitialization() {
1038 F->addFnAttr(Attribute::NoInline);
1039 if (Options.NoRedZone)
1040 F->addFnAttr(Attribute::NoRedZone);
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(""))
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
Optional< uint64_t > getBlockProfileCount(const BasicBlock *BB, bool AllowSynthetic=false) const
Returns the estimated profile count of BB.
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...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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.
ConstantInt * getIndex() const
void dropAllReferences()
Drop all references to operands.
StringRef getInstrProfNameVarPrefix()
Return the name prefix of variables containing instrumented function names.
LLVM_NODISCARD bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
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.
This class represents lattice values for constants.
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))
StringRef getInstrProfRegFuncsName()
Return the name of function that registers all the per-function control data at program startup time ...
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
bool hasDedicatedExits() const
Return true if no exit block for the loop has a predecessor that is outside the loop.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
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 unsigned InstrCount
static IntegerType * getInt64Ty(LLVMContext &C)
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
static IntegerType * getInt16Ty(LLVMContext &C)
StringRef getInstrProfValuesVarPrefix()
Return the name prefix of value profile variables.
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...
ModulePass * createInstrProfilingLegacyPass(const InstrProfOptions &Options=InstrProfOptions(), bool IsCS=false)
Insert frontend instrumentation based profiling. Parameter IsCS indicates if.
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...
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
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.
VisibilityTypes
An enumeration for the kinds of visibility of global values.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LLVM_NODISCARD size_t size() const
size - Get the string size.
LinkageTypes getLinkage() const
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
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 FunctionCallee getOrInsertValueProfilingCall(Module &M, const TargetLibraryInfo &TLI, bool IsRange=false)
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)
bool isOSWindows() const
Tests whether the OS is Windows.
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.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Same, but only replaced by something equivalent.
initializer< Ty > init(const Ty &Val)
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
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
void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput)
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...
bool isPS4CPU() const
Tests whether the target is the PS4 CPU.
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.
const Function * getFunction() const
Return the function this instruction belongs to.
AtomicRMWInst * CreateAtomicRMW(AtomicRMWInst::BinOp Op, Value *Ptr, Value *Val, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
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
static constexpr const Align None()
Returns a default constructed Align which corresponds to no alignment.
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 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.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
unsigned getNumOperands() const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
static bool needsRuntimeRegistrationOfSectionRange(const Triple &TT)
Align max(MaybeAlign Lhs, Align Rhs)
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.
bool isOSLinux() const
Tests whether the OS is Linux.
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:
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
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.
LinkageTypes
An enumeration for the kinds of linkage for global values.
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.
This represents the llvm.instrprof_increment intrinsic.
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
Analysis providing branch probability information.
static IntegerType * getInt32Ty(LLVMContext &C)
Linkage
Describes symbol linkage.
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)
Type * getValueType() const
Rename collisions when linking (static functions).
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
const Value * getPointerOperand(const Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
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
print Print MemDeps of function
StringRef - Represent a constant reference to a string, i.e.
A container for analyses that lazily runs them and caches their results.
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.
Value * CreateConstInBoundsGEP2_64(Type *Ty, Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
INITIALIZE_PASS_BEGIN(InstrProfilingLegacyPass, "instrprof", "Frontend instrumentation-based coverage lowering.", false, false) INITIALIZE_PASS_END(InstrProfilingLegacyPass
const BasicBlock * getParent() const
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...