Go to the documentation of this file.
59 #define DEBUG_TYPE "instrprof"
64 cl::desc(
"Use debug info to correlate profiles."),
71 "hash-based-counter-split",
72 cl::desc(
"Rename counter variable of a comdat function based on cfg hash"),
76 RuntimeCounterRelocation(
"runtime-counter-relocation",
77 cl::desc(
"Enable relocating counters at runtime."),
82 cl::desc(
"Do static counter allocation for value profiler"),
86 "vp-counters-per-site",
87 cl::desc(
"The average number of profile counters allocated "
88 "per value profiling site."),
96 "instrprof-atomic-counter-update-all",
97 cl::desc(
"Make all profile counter updates atomic (for testing only)"),
101 "atomic-counter-update-promoted",
102 cl::desc(
"Do counter update using atomic fetch add "
103 " for promoted counters only"),
107 "atomic-first-counter",
108 cl::desc(
"Use atomic fetch add for first counter in a function (usually "
109 "the entry counter)"),
118 cl::desc(
"Do counter register promotion"),
121 "max-counter-promotions-per-loop",
cl::init(20),
122 cl::desc(
"Max number counter promotions per loop to avoid"
123 " increasing register pressure too much"));
127 MaxNumOfPromotions(
"max-counter-promotions",
cl::init(-1),
128 cl::desc(
"Max number of allowed counter promotions"));
131 "speculative-counter-promotion-max-exiting",
cl::init(3),
132 cl::desc(
"The max number of exiting blocks of a loop to allow "
133 " speculative counter promotion"));
136 "speculative-counter-promotion-to-loop",
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 "
143 "iterative-counter-promotion",
cl::init(
true),
144 cl::desc(
"Allow counter promotion across the whole loop nest."));
147 "skip-ret-exit-block",
cl::init(
true),
148 cl::desc(
"Suppress counter promotion if exit blocks contain ret."));
150 class InstrProfilingLegacyPass :
public ModulePass {
163 return "Frontend instrumentation-based coverage lowering";
166 bool runOnModule(
Module &M)
override {
168 return this->getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
170 return InstrProf.
run(M, GetTLI);
188 PGOCounterPromoterHelper(
195 InsertPts(InsertPts), LoopToCandidates(LoopToCands), LI(LI) {
198 SSA.AddAvailableValue(PH,
Init);
201 void doExtraRewritesBeforeFinalDeletion()
override {
202 for (
unsigned i = 0,
e = ExitBlocks.size();
i !=
e; ++
i) {
208 Value *LiveInValue =
SSA.GetValueInMiddleOfBlock(ExitBlock);
212 if (
auto *AddrInst = dyn_cast_or_null<IntToPtrInst>(
Addr)) {
219 auto *OrigBiasInst = dyn_cast<BinaryOperator>(AddrInst->getOperand(0));
221 Value *BiasInst =
Builder.Insert(OrigBiasInst->clone());
224 if (AtomicCounterUpdatePromoted)
232 auto *NewVal =
Builder.CreateAdd(OldVal, LiveInValue);
233 auto *NewStore =
Builder.CreateStore(NewVal,
Addr);
236 if (IterativeCounterPromotion) {
237 auto *TargetLoop = LI.getLoopFor(ExitBlock);
239 LoopToCandidates[TargetLoop].emplace_back(OldVal, NewStore);
256 class PGOCounterPromoter {
261 : LoopToCandidates(LoopToCands), L(CurLoop), LI(LI),
BFI(
BFI) {
268 L.getExitBlocks(LoopExitBlocks);
269 if (!isPromotionPossible(&L, LoopExitBlocks))
272 for (
BasicBlock *ExitBlock : LoopExitBlocks) {
273 if (BlockSet.
insert(ExitBlock).second) {
274 ExitBlocks.push_back(ExitBlock);
280 bool run(int64_t *NumPromoted) {
282 if (ExitBlocks.size() == 0)
290 if (SkipRetExitBlock) {
291 for (
auto BB : ExitBlocks)
292 if (isa<ReturnInst>(
BB->getTerminator()))
296 unsigned MaxProm = getMaxNumOfPromotionsInLoop(&L);
300 unsigned Promoted = 0;
301 for (
auto &Cand : LoopToCandidates[&L]) {
309 auto *
BB = Cand.first->getParent();
313 auto PreheaderCount =
BFI->getBlockProfileCount(L.getLoopPreheader());
316 if (PreheaderCount && (*PreheaderCount * 3) >= (*
InstrCount * 2))
320 PGOCounterPromoterHelper Promoter(Cand.first, Cand.second,
SSA, InitVal,
321 L.getLoopPreheader(), ExitBlocks,
322 InsertPts, LoopToCandidates, LI);
325 if (Promoted >= MaxProm)
329 if (MaxNumOfPromotions != -1 && *NumPromoted >= MaxNumOfPromotions)
333 LLVM_DEBUG(
dbgs() << Promoted <<
" counters promoted for loop (depth="
334 << L.getLoopDepth() <<
")\n");
335 return Promoted != 0;
339 bool allowSpeculativeCounterPromotion(
Loop *LP) {
341 L.getExitingBlocks(ExitingBlocks);
343 if (ExitingBlocks.size() == 1)
345 if (ExitingBlocks.size() > SpeculativeCounterPromotionMaxExiting)
353 isPromotionPossible(
Loop *LP,
372 unsigned getMaxNumOfPromotionsInLoop(
Loop *LP) {
375 if (!isPromotionPossible(LP, LoopExitBlocks))
386 if (ExitingBlocks.size() == 1)
387 return MaxNumOfPromotionsPerLoop;
389 if (ExitingBlocks.size() > SpeculativeCounterPromotionMaxExiting)
393 if (SpeculativeCounterPromotionToLoop)
394 return MaxNumOfPromotionsPerLoop;
397 unsigned MaxProm = MaxNumOfPromotionsPerLoop;
398 for (
auto *TargetBlock : LoopExitBlocks) {
399 auto *TargetLoop = LI.
getLoopFor(TargetBlock);
402 unsigned MaxPromForTarget = getMaxNumOfPromotionsInLoop(TargetLoop);
403 unsigned PendingCandsInTarget = LoopToCandidates[TargetLoop].size();
406 PendingCandsInTarget);
419 enum class ValueProfilingCallType {
444 "Frontend instrumentation-based coverage lowering.",
454 return new InstrProfilingLegacyPass(
Options, IsCS);
457 bool InstrProfiling::lowerIntrinsics(
Function *
F) {
458 bool MadeChange =
false;
459 PromotionCandidates.clear();
462 if (
auto *IPIS = dyn_cast<InstrProfIncrementInstStep>(&Instr)) {
463 lowerIncrement(IPIS);
465 }
else if (
auto *IPI = dyn_cast<InstrProfIncrementInst>(&Instr)) {
468 }
else if (
auto *IPC = dyn_cast<InstrProfCoverInst>(&Instr)) {
471 }
else if (
auto *IPVP = dyn_cast<InstrProfValueProfileInst>(&Instr)) {
472 lowerValueProfileInst(IPVP);
481 promoteCounterLoadStores(
F);
485 bool InstrProfiling::isRuntimeCounterRelocationEnabled()
const {
490 if (RuntimeCounterRelocation.getNumOccurrences() > 0)
491 return RuntimeCounterRelocation;
497 bool InstrProfiling::isCounterPromotionEnabled()
const {
498 if (DoCounterPromotion.getNumOccurrences() > 0)
499 return DoCounterPromotion;
501 return Options.DoCounterPromotion;
504 void InstrProfiling::promoteCounterLoadStores(
Function *
F) {
505 if (!isCounterPromotionEnabled())
512 std::unique_ptr<BlockFrequencyInfo>
BFI;
513 if (
Options.UseBFIInPromotion) {
514 std::unique_ptr<BranchProbabilityInfo> BPI;
519 for (
const auto &
LoadStore : PromotionCandidates) {
526 LoopPromotionCandidates[ParentLoop].emplace_back(CounterLoad, CounterStore);
534 PGOCounterPromoter Promoter(LoopPromotionCandidates, *
Loop, LI,
BFI.get());
535 Promoter.run(&TotalCountersPromoted);
541 if (TT.isOSFuchsia())
549 auto containsIntrinsic = [&](
int ID) {
551 return !
F->use_empty();
554 return containsIntrinsic(llvm::Intrinsic::instrprof_cover) ||
555 containsIntrinsic(llvm::Intrinsic::instrprof_increment) ||
556 containsIntrinsic(llvm::Intrinsic::instrprof_increment_step) ||
557 containsIntrinsic(llvm::Intrinsic::instrprof_value_profile);
566 ProfileDataMap.clear();
567 CompilerUsedVars.clear();
569 TT =
Triple(
M.getTargetTriple());
571 bool MadeChange =
false;
575 MadeChange = emitRuntimeHook();
589 for (
auto I =
BB.begin(),
E =
BB.end();
I !=
E;
I++)
590 if (
auto *Ind = dyn_cast<InstrProfValueProfileInst>(
I))
591 computeNumValueSiteCounts(Ind);
592 else if (FirstProfIncInst ==
nullptr)
593 FirstProfIncInst = dyn_cast<InstrProfIncrementInst>(
I);
597 if (FirstProfIncInst !=
nullptr)
598 static_cast<void>(getOrCreateRegionCounters(FirstProfIncInst));
602 MadeChange |= lowerIntrinsics(&
F);
604 if (CoverageNamesVar) {
605 lowerCoverageData(CoverageNamesVar);
617 emitInitialization();
629 AL =
AL.addParamAttribute(
M.getContext(), 2, AK);
632 CallType == ValueProfilingCallType::MemOp) &&
633 "Must be Default or MemOp");
634 Type *ParamTypes[] = {
635 #define VALUE_PROF_FUNC_PARAM(ParamType, ParamName, ParamLLVMType) ParamLLVMType
638 auto *ValueProfilingCallTy =
643 return M.getOrInsertFunction(FuncName, ValueProfilingCallTy,
AL);
650 auto &
PD = ProfileDataMap[
Name];
661 "Value profiling is not yet supported with lightweight instrumentation");
663 auto It = ProfileDataMap.find(
Name);
664 assert(It != ProfileDataMap.end() && It->second.DataVar &&
665 "value profiling detected in function with no counter incerement");
675 llvm::InstrProfValueKind::IPVK_MemOPSize);
699 if (
auto AK = TLI->getExtAttrForI32Param(
false))
700 Call->addParamAttr(2, AK);
706 auto *Counters = getOrCreateRegionCounters(
I);
710 Counters->getValueType(), Counters, 0,
I->getIndex()->getZExtValue());
712 if (!isRuntimeCounterRelocationEnabled())
716 Function *Fn =
I->getParent()->getParent();
717 LoadInst *&BiasLI = FunctionToProfileBiasMap[Fn];
734 Bias->setComdat(
M->getOrInsertComdat(
Bias->getName()));
736 BiasLI = EntryBuilder.CreateLoad(Int64Ty, Bias);
739 return Builder.CreateIntToPtr(Add,
Addr->getType());
743 auto *
Addr = getCounterAddress(CoverInstruction);
751 auto *
Addr = getCounterAddress(Inc);
754 if (
Options.Atomic || AtomicCounterUpdateAll ||
763 if (isCounterPromotionEnabled())
764 PromotionCandidates.emplace_back(cast<Instruction>(
Load),
Store);
769 void InstrProfiling::lowerCoverageData(
GlobalVariable *CoverageNamesVar) {
774 Value *V =
NC->stripPointerCasts();
775 assert(isa<GlobalVariable>(V) &&
"Missing reference to function name");
779 ReferencedNames.push_back(
Name);
780 if (isa<ConstantExpr>(
NC))
781 NC->dropAllReferences();
807 auto *MD = dyn_cast_or_null<ConstantAsMetadata>(
M.getModuleFlag(
Flag));
813 return cast<ConstantInt>(MD->getValue())->getZExtValue();
835 bool HasAvailableExternallyLinkage =
F->hasAvailableExternallyLinkage();
836 if (!
F->hasLinkOnceLinkage() && !
F->hasLocalLinkage() &&
837 !HasAvailableExternallyLinkage)
843 if (HasAvailableExternallyLinkage &&
844 F->hasFnAttribute(Attribute::AlwaysInline))
850 if (
F->hasLocalLinkage() &&
F->hasComdat())
860 return F->hasAddressTaken() ||
F->hasLinkOnceLinkage();
868 if (TT.isOSAIX() || TT.isOSLinux() || TT.isOSFreeBSD() || TT.isOSNetBSD() ||
869 TT.isOSSolaris() || TT.isOSFuchsia() || TT.isPS() || TT.isOSWindows())
879 auto &Ctx =
M->getContext();
881 if (isa<InstrProfCoverInst>(Inc)) {
885 std::vector<Constant *> InitialValues(NumCounters,
903 auto &
PD = ProfileDataMap[NamePtr];
904 if (
PD.RegionCounters)
905 return PD.RegionCounters;
947 std::string CntsVarName =
949 std::string DataVarName =
957 Comdat *
C =
M->getOrInsertComdat(GroupName);
967 auto *CounterPtr = createRegionCounters(Inc, CntsVarName, Linkage);
968 CounterPtr->setVisibility(Visibility);
969 CounterPtr->setSection(
971 MaybeSetComdat(CounterPtr);
972 CounterPtr->setLinkage(Linkage);
973 PD.RegionCounters = CounterPtr;
977 Metadata *FunctionNameAnnotation[] = {
985 Metadata *NumCountersAnnotation[] = {
994 auto *DICounter = DB.createGlobalVariableExpression(
995 SP, CounterPtr->getName(),
StringRef(), SP->getFile(),
996 0, DB.createUnspecifiedType(
"Profile Data Type"),
997 CounterPtr->hasLocalLinkage(),
true,
nullptr,
1000 CounterPtr->addDebugInfo(DICounter);
1003 std::string
Msg = (
"Missing debug info for function " + Fn->
getName() +
1004 "; required for profile correlation.")
1017 NS +=
PD.NumValueSites[
Kind];
1018 if (NS > 0 && ValueProfileStaticAlloc &&
1024 ValuesVar->setVisibility(Visibility);
1025 ValuesVar->setSection(
1027 ValuesVar->setAlignment(
Align(8));
1028 MaybeSetComdat(ValuesVar);
1035 CompilerUsedVars.push_back(
PD.RegionCounters);
1036 return PD.RegionCounters;
1040 auto *IntPtrTy =
M->getDataLayout().getIntPtrType(
M->getContext());
1043 Type *DataTypes[] = {
1044 #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) LLVMType,
1053 Constant *Int16ArrayVals[IPVK_Last + 1];
1068 if (NS == 0 && !(DataReferencedByCode && NeedComdat && !Renamed) &&
1075 new GlobalVariable(*M, DataTy,
false, Linkage,
nullptr, DataVarName);
1078 auto *RelativeCounterPtr =
1083 #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Init,
1088 Data->setVisibility(Visibility);
1090 Data->setAlignment(
Align(INSTR_PROF_DATA_ALIGNMENT));
1091 MaybeSetComdat(
Data);
1092 Data->setLinkage(Linkage);
1097 CompilerUsedVars.push_back(
Data);
1103 ReferencedNames.push_back(NamePtr);
1105 return PD.RegionCounters;
1108 void InstrProfiling::emitVNodes() {
1109 if (!ValueProfileStaticAlloc)
1119 for (
auto &
PD : ProfileDataMap) {
1121 TotalNS +=
PD.second.NumValueSites[
Kind];
1127 uint64_t NumCounters = TotalNS * NumCountersPerValueSite;
1135 #define INSTR_PROF_MIN_VAL_COUNTS 10
1139 auto &Ctx =
M->getContext();
1140 Type *VNodeTypes[] = {
1141 #define INSTR_PROF_VALUE_NODE(Type, LLVMType, Name, Init) LLVMType,
1150 VNodesVar->setSection(
1154 UsedVars.push_back(VNodesVar);
1157 void InstrProfiling::emitNameData() {
1158 std::string UncompressedData;
1160 if (ReferencedNames.empty())
1163 std::string CompressedNameStr;
1169 auto &Ctx =
M->getContext();
1175 NamesSize = CompressedNameStr.size();
1184 UsedVars.push_back(NamesVar);
1186 for (
auto *NamePtr : ReferencedNames)
1190 void InstrProfiling::emitRegistration() {
1203 RegisterF->addFnAttr(Attribute::NoRedZone);
1206 auto *RuntimeRegisterF =
1212 if (!isa<Function>(
Data))
1213 IRB.CreateCall(RuntimeRegisterF, IRB.CreateBitCast(
Data, VoidPtrTy));
1215 if (
Data != NamesVar && !isa<Function>(
Data))
1216 IRB.CreateCall(RuntimeRegisterF, IRB.CreateBitCast(
Data, VoidPtrTy));
1219 Type *ParamTypes[] = {VoidPtrTy, Int64Ty};
1220 auto *NamesRegisterTy =
1222 auto *NamesRegisterF =
1225 IRB.CreateCall(NamesRegisterF, {IRB.CreateBitCast(NamesVar, VoidPtrTy),
1226 IRB.getInt64(NamesSize)});
1229 IRB.CreateRetVoid();
1232 bool InstrProfiling::emitRuntimeHook() {
1250 CompilerUsedVars.push_back(Var);
1256 User->addFnAttr(Attribute::NoInline);
1258 User->addFnAttr(Attribute::NoRedZone);
1265 IRB.CreateRet(
Load);
1268 CompilerUsedVars.push_back(
User);
1273 void InstrProfiling::emitUses() {
1295 void InstrProfiling::emitInitialization() {
1312 F->addFnAttr(Attribute::NoInline);
1314 F->addFnAttr(Attribute::NoRedZone);
1318 IRB.CreateCall(RegisterF, {});
1319 IRB.CreateRetVoid();
ModulePass * createInstrProfilingLegacyPass(const InstrProfOptions &Options=InstrProfOptions(), bool IsCS=false)
Insert frontend instrumentation based profiling. Parameter IsCS indicates if.
#define INSTR_PROF_MIN_VAL_COUNTS
A set of analyses that are preserved following a run of a transformation pass.
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
void setComdat(Comdat *C)
This is an optimization pass for GlobalISel generic memory operations.
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
INITIALIZE_PASS_BEGIN(InstrProfilingLegacyPass, "instrprof", "Frontend instrumentation-based coverage lowering.", false, false) INITIALIZE_PASS_END(InstrProfilingLegacyPass
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
void getExitBlocks(SmallVectorImpl< BlockT * > &ExitBlocks) const
Return all of the successor blocks of this loop.
static bool needsRuntimeHookUnconditionally(const Triple &TT)
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
StringRef getInstrProfNamesVarName()
Return the name of the variable holding the strings (possibly compressed) of all function's PGO names...
static std::string getVarName(InstrProfInstBase *Inc, StringRef Prefix, bool &Renamed)
Get the name of a profiling variable for a particular function.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
const Function * getParent() const
Return the enclosing method, or null if none.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
static const char * NumCountersAttributeName
LinkageTypes getLinkage() const
@ HiddenVisibility
The GV is hidden.
Represents a single loop in the control flow graph.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
A base class for all instrprof intrinsics.
bool isPS() const
Tests whether the target is the PS4 or PS5 platform.
bool needsComdatForCounter(const Function &F, const Module &M)
Check if we can use Comdat for profile variables.
@ NoDeduplicate
No deduplication is performed.
StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar)
Return the initializer in string of the PGO name var NameVar.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
DISubprogram * getSubprogram() const
Get the attached subprogram.
const BasicBlock & getEntryBlock() const
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Triple - Helper class for working with autoconf configuration names.
FunctionAnalysisManager FAM
StringRef getInstrProfRuntimeHookVarName()
Return the name of the hook variable defined in profile runtime library.
static unsigned InstrCount
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
The instances of the Type class are immutable: once they are created, they are never changed.
static bool containsProfilingIntrinsics(Module &M)
Check if the module contains uses of any profiling intrinsics.
auto reverse(ContainerTy &&C, std::enable_if_t< has_rbegin< ContainerTy >::value > *=nullptr)
Attribute::AttrKind getExtAttrForI32Param(bool Signed=true) const
Returns extension attribute kind to be used for i32 parameters corresponding to C-level int or unsign...
StringRef getInstrProfNamesRegFuncName()
Return the name of the runtime interface that registers the PGO name strings.
ConstantInt * getIndex() const
static const char * CFGHashAttributeName
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
ConstantInt * getNumCounters() const
@ DefaultVisibility
The GV is visible.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
bool isOSLinux() const
Tests whether the OS is Linux.
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
ConstantInt * getHash() const
LinkageTypes
An enumeration for the kinds of linkage for global values.
Class to represent array types.
void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput)
static IntegerType * getInt8Ty(LLVMContext &C)
static IntegerType * getInt32Ty(LLVMContext &C)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Instrumentation based profiling lowering pass.
static uint64_t getIntModuleFlagOrZero(const Module &M, StringRef Flag)
LLVM Basic Block Representation.
Annotations lets you mark points and ranges inside source code, for tests:
ConstantInt * getValueKind() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
A constant pointer value that points to null.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
VisibilityTypes
An enumeration for the kinds of visibility of global values.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
StringRef getInstrProfValuesVarPrefix()
Return the name prefix of value profile variables.
void setSection(StringRef S)
Change the section for this global.
(vector float) vec_cmpeq(*A, *B) C
static const char * FunctionNameAttributeName
Value * getTargetValue() const
Analysis providing branch probability information.
Represent the analysis usage information of a pass.
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
bool canRenameComdatFunc(const Function &F, bool CheckAddressTaken=false)
Check if we can safely rename this Comdat function.
StringRef getInstrProfCountersVarPrefix()
Return the name prefix of profile counter variables.
bool supportsCOMDAT() const
Tests whether the target supports comdat.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
StringRef toStringRef(const Optional< DWARFFormValue > &V, StringRef Default={})
Take an optional DWARFFormValue and try to extract a string value from it.
StringRef getInstrProfInitFuncName()
Return the name of the runtime initialization method that is generated by the compiler.
ConstantArray - Constant Array Declarations.
static Constant * getAllOnesValue(Type *Ty)
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
ObjectFormatType getObjectFormat() const
Get the object format for this triple.
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
void getExitingBlocks(SmallVectorImpl< BlockT * > &ExitingBlocks) const
Return all blocks inside the loop that have successors outside of the loop.
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.
ConstantInt * getIndex() const
@ InternalLinkage
Rename collisions when linking (static functions).
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
StringRef getInstrProfVNodesVarName()
Return the name of value profile node array variables:
StringRef getInstrProfNameVarPrefix()
Return the name prefix of variables containing instrumented function names.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This is an important base class in LLVM.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
This represents the llvm.instrprof.value.profile intrinsic.
VisibilityTypes getVisibility() const
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
This is an important class for using LLVM in a threaded context.
static bool profDataReferencedByCode(const Module &M)
static bool shouldRecordFunctionAddr(Function *F)
bool isIRPGOFlagSet(const Module *M)
Check if INSTR_PROF_RAW_VERSION_VAR is defined.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
initializer< Ty > init(const Ty &Val)
void appendToUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.used list.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
void setLinkage(LinkageTypes LT)
Options for the frontend instrumentation based profiling pass.
static MDString * get(LLVMContext &Context, StringRef Str)
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Diagnostic information for the PGO profiler.
bool hasDedicatedExits() const
Return true if no exit block for the loop has a predecessor that is outside the loop.
StringRef getInstrProfRuntimeHookVarUseFuncName()
Return the name of the compiler generated function that references the runtime hook variable.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
GlobalVariable * getName() const
print Print MemDeps of function
Frontend instrumentation based coverage lowering
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
A Module instance is used to store all the information related to an LLVM module.
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...
StringRef getInstrProfRegFuncsName()
Return the name of function that registers all the per-function control data at program startup time ...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
StringRef - Represent a constant reference to a string, i.e.
Type * getType() const
All values are typed, get the type of this value.
if(llvm_vc STREQUAL "") set(fake_version_inc "$
const Function * getFunction() const
Return the function this instruction belongs to.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
cl::opt< bool > DebugInfoCorrelate("debug-info-correlate", cl::desc("Use debug info to correlate profiles."), cl::init(false))
Linkage
Describes symbol linkage.
StringRef getName() const
Return a constant reference to the value's name.
An instruction for reading from memory.
const CustomOperand< const MCSubtargetInfo & > Msg[]
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
const Instruction & front() const
cl::opt< bool > DoInstrProfNameCompression
SmallVector< LoopT *, 4 > getLoopsInPreorder() const
Return all of the loops in the function in preorder across the loop nests, with siblings in forward p...
constexpr LLVM_NODISCARD size_t size() const
size - Get the string size.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static IntegerType * getInt64Ty(LLVMContext &C)
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Should compile to something r4 addze r3 instead we get
const char * toString(DWARFSectionKind Kind)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
bool isZeroValue() const
Return true if the value is negative zero or null value.
Lightweight error class with error context and mandatory checking.
static FunctionCallee getOrInsertValueProfilingCall(Module &M, const TargetLibraryInfo &TLI, ValueProfilingCallType CallType=ValueProfilingCallType::Default)
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
static bool enablesValueProfiling(const Module &M)
Provides information about what library functions are available for the current target.
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
This represents the llvm.instrprof.cover intrinsic.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
This represents the llvm.instrprof.increment intrinsic.
std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
@ ExternalLinkage
Externally visible function.
static Type * getVoidTy(LLVMContext &C)
@ PrivateLinkage
Like Internal, but omit from symbol table.
StringRef getInstrProfValueProfMemOpFuncName()
Return the name profile runtime entry point to do memop size value profiling.
unsigned getNumOperands() const
static bool needsRuntimeRegistrationOfSectionRange(const Triple &TT)
StringRef getCoverageUnusedNamesVarName()
Return the name of the internal variable recording the array of PGO name vars referenced by the cover...
StringRef getInstrProfCounterBiasVarName()
const BasicBlock * getParent() const
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
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)
A container for analyses that lazily runs them and caches their results.
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
This class represents a function call, abstracting a target machine's calling convention.
StringRef getInstrProfValueProfFuncName()
Return the name profile runtime entry point to do value profiling for a given site.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
AnalysisUsage & addRequired()
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
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.
Value * getOperand(unsigned i) const
StringRef getInstrProfDataVarPrefix()
Return the name prefix of variables containing per-function control data.
void setAlignment(MaybeAlign Align)
Helper class for SSA formation on a set of values defined in multiple blocks.
void initializeInstrProfilingLegacyPassPass(PassRegistry &)
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
LLVM Value Representation.
StringRef getInstrProfRegFuncName()
Return the name of the runtime interface that registers per-function control data for one instrumente...
Analysis pass providing the TargetLibraryInfo.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.