58 #define DEBUG_TYPE "instrprof" 64 cl::desc(
"Set the range of size in memory intrinsic calls to be profiled " 65 "precisely, in a format of <start_val>:<end_val>"),
71 cl::desc(
"Set large value thresthold in memory intrinsic size profiling. " 72 "Value of 0 disables the large value profiling."),
78 cl::desc(
"Enable name string compression"),
82 "hash-based-counter-split",
83 cl::desc(
"Rename counter variable of a comdat function based on cfg hash"),
88 cl::desc(
"Do static counter allocation for value profiler"),
92 "vp-counters-per-site",
93 cl::desc(
"The average number of profile counters allocated " 94 "per value profiling site."),
103 cl::desc(
"Make all profile counter updates atomic (for testing only)"),
108 cl::desc(
"Do counter update using atomic fetch add " 109 " for promoted counters only"),
118 cl::desc(
"Do counter register promotion"),
122 cl::desc(
"Max number counter promotions per loop to avoid" 123 " increasing register pressure too much"));
128 cl::desc(
"Max number of allowed counter promotions"));
132 cl::desc(
"The max number of exiting blocks of a loop to allow " 133 " speculative counter promotion"));
137 cl::desc(
"When the option is false, if the target block is in a loop, " 138 "the promotion will be disallowed unless the promoted counter " 139 " update can be further/iteratively promoted into an acyclic " 144 cl::desc(
"Allow counter promotion across the whole loop nest."));
146 class InstrProfilingLegacyPass :
public ModulePass {
152 InstrProfilingLegacyPass() :
ModulePass(ID) {}
153 InstrProfilingLegacyPass(
const InstrProfOptions &Options,
bool IsCS =
false)
157 return "Frontend instrumentation-based coverage lowering";
160 bool runOnModule(
Module &M)
override {
162 return this->getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
164 return InstrProf.
run(M, GetTLI);
182 PGOCounterPromoterHelper(
189 InsertPts(InsertPts), LoopToCandidates(LoopToCands), LI(LI) {
191 assert(isa<StoreInst>(S));
192 SSA.AddAvailableValue(PH,
Init);
195 void doExtraRewritesBeforeFinalDeletion()
override {
196 for (
unsigned i = 0,
e = ExitBlocks.size(); i !=
e; ++i) {
202 Value *LiveInValue =
SSA.GetValueInMiddleOfBlock(ExitBlock);
206 if (AtomicCounterUpdatePromoted)
212 LoadInst *OldVal = Builder.CreateLoad(Ty, Addr,
"pgocount.promoted");
213 auto *NewVal = Builder.CreateAdd(OldVal, LiveInValue);
214 auto *NewStore = Builder.CreateStore(NewVal, Addr);
217 if (IterativeCounterPromotion) {
218 auto *TargetLoop = LI.getLoopFor(ExitBlock);
220 LoopToCandidates[TargetLoop].emplace_back(OldVal, NewStore);
237 class PGOCounterPromoter {
242 : LoopToCandidates(LoopToCands), ExitBlocks(), InsertPts(), L(CurLoop),
247 L.getExitBlocks(LoopExitBlocks);
249 for (
BasicBlock *ExitBlock : LoopExitBlocks) {
250 if (BlockSet.
insert(ExitBlock).second) {
251 ExitBlocks.push_back(ExitBlock);
257 bool run(int64_t *NumPromoted) {
259 if (ExitBlocks.size() == 0)
261 unsigned MaxProm = getMaxNumOfPromotionsInLoop(&L);
265 unsigned Promoted = 0;
266 for (
auto &Cand : LoopToCandidates[&L]) {
274 auto *BB = Cand.first->getParent();
281 if (PreheaderCount &&
282 (PreheaderCount.getValue() * 3) >= (
InstrCount.getValue() * 2))
286 PGOCounterPromoterHelper Promoter(Cand.first, Cand.second,
SSA, InitVal,
287 L.getLoopPreheader(), ExitBlocks,
288 InsertPts, LoopToCandidates, LI);
291 if (Promoted >= MaxProm)
295 if (MaxNumOfPromotions != -1 && *NumPromoted >= MaxNumOfPromotions)
299 LLVM_DEBUG(
dbgs() << Promoted <<
" counters promoted for loop (depth=" 300 << L.getLoopDepth() <<
")\n");
301 return Promoted != 0;
305 bool allowSpeculativeCounterPromotion(
Loop *LP) {
307 L.getExitingBlocks(ExitingBlocks);
309 if (ExitingBlocks.
size() == 1)
311 if (ExitingBlocks.
size() > SpeculativeCounterPromotionMaxExiting)
317 unsigned getMaxNumOfPromotionsInLoop(
Loop *LP) {
341 if (ExitingBlocks.
size() == 1)
342 return MaxNumOfPromotionsPerLoop;
344 if (ExitingBlocks.
size() > SpeculativeCounterPromotionMaxExiting)
348 if (SpeculativeCounterPromotionToLoop)
349 return MaxNumOfPromotionsPerLoop;
352 unsigned MaxProm = MaxNumOfPromotionsPerLoop;
353 for (
auto *TargetBlock : LoopExitBlocks) {
354 auto *TargetLoop = LI.
getLoopFor(TargetBlock);
357 unsigned MaxPromForTarget = getMaxNumOfPromotionsInLoop(TargetLoop);
358 unsigned PendingCandsInTarget = LoopToCandidates[TargetLoop].size();
360 std::min(MaxProm,
std::max(MaxPromForTarget, PendingCandsInTarget) -
361 PendingCandsInTarget);
390 InstrProfilingLegacyPass,
"instrprof",
391 "Frontend instrumentation-based coverage lowering.",
false,
false)
394 InstrProfilingLegacyPass,
"instrprof",
395 "Frontend instrumentation-based coverage lowering.",
false,
false)
400 return new InstrProfilingLegacyPass(Options, IsCS);
410 bool InstrProfiling::lowerIntrinsics(
Function *
F) {
411 bool MadeChange =
false;
412 PromotionCandidates.clear();
414 for (
auto I = BB.begin(),
E = BB.end();
I !=
E;) {
420 }
else if (
auto *Ind = dyn_cast<InstrProfValueProfileInst>(Instr)) {
421 lowerValueProfileInst(Ind);
430 promoteCounterLoadStores(F);
434 bool InstrProfiling::isCounterPromotionEnabled()
const {
435 if (DoCounterPromotion.getNumOccurrences() > 0)
436 return DoCounterPromotion;
438 return Options.DoCounterPromotion;
441 void InstrProfiling::promoteCounterLoadStores(
Function *F) {
442 if (!isCounterPromotionEnabled())
449 std::unique_ptr<BlockFrequencyInfo>
BFI;
450 if (Options.UseBFIInPromotion) {
451 std::unique_ptr<BranchProbabilityInfo> BPI;
456 for (
const auto &
LoadStore : PromotionCandidates) {
463 LoopPromotionCandidates[ParentLoop].emplace_back(CounterLoad, CounterStore);
471 PGOCounterPromoter Promoter(LoopPromotionCandidates, *
Loop, LI, BFI.get());
472 Promoter.run(&TotalCountersPromoted);
496 this->GetTLI = std::move(GetTLI);
499 ProfileDataMap.clear();
506 bool MadeChange = emitRuntimeHook();
520 for (
auto I = BB.begin(),
E = BB.end();
I !=
E;
I++)
521 if (
auto *Ind = dyn_cast<InstrProfValueProfileInst>(
I))
522 computeNumValueSiteCounts(Ind);
523 else if (FirstProfIncInst ==
nullptr)
528 if (FirstProfIncInst !=
nullptr)
529 static_cast<void>(getOrCreateRegionCounters(FirstProfIncInst));
535 if (CoverageNamesVar) {
536 lowerCoverageData(CoverageNamesVar);
547 emitInitialization();
553 bool IsRange =
false) {
559 AL = AL.addParamAttribute(M.
getContext(), 2, AK);
562 Type *ParamTypes[] = {
563 #define VALUE_PROF_FUNC_PARAM(ParamType, ParamName, ParamLLVMType) ParamLLVMType 566 auto *ValueProfilingCallTy =
569 ValueProfilingCallTy, AL);
571 Type *RangeParamTypes[] = {
572 #define VALUE_RANGE_PROF 1 573 #define VALUE_PROF_FUNC_PARAM(ParamType, ParamName, ParamLLVMType) ParamLLVMType 575 #undef VALUE_RANGE_PROF 577 auto *ValueRangeProfilingCallTy =
580 ValueRangeProfilingCallTy, AL);
588 auto It = ProfileDataMap.find(Name);
589 if (It == ProfileDataMap.end()) {
590 PerFunctionProfileData
PD;
592 ProfileDataMap[
Name] =
PD;
593 }
else if (It->second.NumValueSites[ValueKind] <= Index)
594 It->second.NumValueSites[
ValueKind] = Index + 1;
599 auto It = ProfileDataMap.find(Name);
600 assert(It != ProfileDataMap.end() && It->second.DataVar &&
601 "value profiling detected in function with no counter incerement");
607 Index += It->second.NumValueSites[
Kind];
611 llvm::InstrProfValueKind::IPVK_MemOPSize);
616 Builder.CreateBitCast(DataVar, Builder.getInt8PtrTy()),
617 Builder.getInt32(Index)};
622 Builder.CreateBitCast(DataVar, Builder.getInt8PtrTy()),
623 Builder.getInt32(Index),
624 Builder.getInt64(MemOPSizeRangeStart),
625 Builder.getInt64(MemOPSizeRangeLast),
630 if (
auto AK = TLI->getExtAttrForI32Param(
false))
644 if (Options.Atomic || AtomicCounterUpdateAll) {
652 if (isCounterPromotionEnabled())
653 PromotionCandidates.emplace_back(cast<Instruction>(Load),
Store);
658 void InstrProfiling::lowerCoverageData(
GlobalVariable *CoverageNamesVar) {
664 assert(isa<GlobalVariable>(V) &&
"Missing reference to function name");
668 ReferencedNames.push_back(Name);
682 return (Prefix + Name).str();
686 return (Prefix + Name).str();
687 return (Prefix + Name +
"." +
Twine(FuncHash)).str();
694 !HasAvailableExternallyLinkage)
700 if (HasAvailableExternallyLinkage &&
736 auto It = ProfileDataMap.find(NamePtr);
737 PerFunctionProfileData
PD;
738 if (It != ProfileDataMap.end()) {
739 if (It->second.RegionCounters)
740 return It->second.RegionCounters;
749 if (
TT.isOSBinFormatCOFF()) {
763 if (
TT.isOSBinFormatCOFF()) {
786 CounterPtr->setVisibility(Visibility);
787 CounterPtr->setSection(
789 CounterPtr->setAlignment(
Align(8));
790 MaybeSetComdat(CounterPtr);
791 CounterPtr->setLinkage(Linkage);
800 NS += PD.NumValueSites[
Kind];
808 ValuesVar->setVisibility(Visibility);
809 ValuesVar->setSection(
811 ValuesVar->setAlignment(
Align(8));
812 MaybeSetComdat(ValuesVar);
821 Type *DataTypes[] = {
822 #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) LLVMType, 831 Constant *Int16ArrayVals[IPVK_Last + 1];
836 #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Init, 842 Data->setVisibility(Visibility);
844 Data->setAlignment(
Align(INSTR_PROF_DATA_ALIGNMENT));
845 MaybeSetComdat(
Data);
846 Data->setLinkage(Linkage);
848 PD.RegionCounters = CounterPtr;
850 ProfileDataMap[NamePtr] =
PD;
853 UsedVars.push_back(
Data);
859 ReferencedNames.push_back(NamePtr);
864 void InstrProfiling::emitVNodes() {
865 if (!ValueProfileStaticAlloc)
875 for (
auto &
PD : ProfileDataMap) {
877 TotalNS +=
PD.second.NumValueSites[
Kind];
883 uint64_t NumCounters = TotalNS * NumCountersPerValueSite;
891 #define INSTR_PROF_MIN_VAL_COUNTS 10 896 Type *VNodeTypes[] = {
897 #define INSTR_PROF_VALUE_NODE(Type, LLVMType, Name, Init) LLVMType, 906 VNodesVar->setSection(
908 UsedVars.push_back(VNodesVar);
911 void InstrProfiling::emitNameData() {
912 std::string UncompressedData;
914 if (ReferencedNames.empty())
917 std::string CompressedNameStr;
919 DoNameCompression)) {
925 Ctx,
StringRef(CompressedNameStr),
false);
929 NamesSize = CompressedNameStr.size();
936 UsedVars.push_back(NamesVar);
938 for (
auto *NamePtr : ReferencedNames)
939 NamePtr->eraseFromParent();
942 void InstrProfiling::emitRegistration() {
954 if (Options.NoRedZone)
955 RegisterF->addFnAttr(Attribute::NoRedZone);
958 auto *RuntimeRegisterF =
964 if (
Data != NamesVar && !isa<Function>(
Data))
968 Type *ParamTypes[] = {VoidPtrTy, Int64Ty};
969 auto *NamesRegisterTy =
971 auto *NamesRegisterF =
981 bool InstrProfiling::emitRuntimeHook() {
1001 User->addFnAttr(Attribute::NoInline);
1002 if (Options.NoRedZone)
1003 User->addFnAttr(Attribute::NoRedZone);
1005 if (
TT.supportsCOMDAT())
1013 UsedVars.push_back(
User);
1017 void InstrProfiling::emitUses() {
1018 if (!UsedVars.empty())
1022 void InstrProfiling::emitInitialization() {
1039 F->addFnAttr(Attribute::NoInline);
1040 if (Options.NoRedZone)
1041 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 (macOS, iOS, tvOS 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 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...