LLVM: lib/Transforms/Instrumentation/CGProfile.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
10
21#include
22
23using namespace llvm;
24
25static bool
28 if (Counts.empty())
29 return false;
30
33 std::vector<Metadata *> Nodes;
34
35 for (auto E : Counts) {
40 Nodes.push_back(MDNode::get(Context, Vals));
41 }
42
45 return true;
46}
47
49 bool InLTO) {
54 if (NewCount == 0)
55 return;
56 if (!CalledF || .isLoweredToCall(CalledF) ||
57 CalledF->hasDLLImportStorageClass())
58 return;
61 };
62
63 (void)(bool)Symtab.create(M, InLTO);
64 for (auto &F : M) {
65
66
67 if (F.isDeclaration() || .getEntryCount())
68 continue;
71 continue;
73 for (auto &BB : F) {
74 std::optional<uint64_t> BBCount = BFI.getBlockProfileCount(&BB);
75 if (!BBCount)
76 continue;
77 for (auto &I : BB) {
79 if (!CB)
80 continue;
83 auto ValueData =
85 for (const auto &VD : ValueData)
86 UpdateCounts(TTI, &F, Symtab.getFunction(VD.Value), VD.Count);
87 continue;
88 }
90 }
91 }
92 }
93
95}
96
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool addModuleFlags(Module &M, MapVector< std::pair< Function *, Function * >, uint64_t > &Counts)
Definition CGProfile.cpp:26
static bool runCGProfilePass(Module &M, FunctionAnalysisManager &FAM, bool InLTO)
Definition CGProfile.cpp:48
This file provides the interface for LLVM's Call Graph Profile pass.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
This file implements a map that provides insertion order iteration.
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
This pass exposes codegen information to IR-level passes.
Analysis pass which computes BlockFrequencyInfo.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition CGProfile.cpp:97
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
LLVM_ABI bool isIndirectCall() const
Return true if the callsite is an indirect call.
A symbol table used for function [IR]PGO name look-up with keys (such as pointers,...
LLVM_ABI Error create(object::SectionRef &Section)
Create InstrProfSymtab from an object file section which contains function PGO names.
Function * getFunction(uint64_t FuncMD5Hash) const
Return function from the name's md5 hash. Return nullptr if not found.
This is an important class for using LLVM in a threaded context.
LLVM_ABI ConstantAsMetadata * createConstant(Constant *C)
Return the given constant as metadata.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a distinct node.
This class implements a map that also provides access to all stored values in a deterministic order.
A Module instance is used to store all the information related to an LLVM module.
@ Append
Appends the two values, which are required to be metadata nodes.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Analysis pass providing the TargetTransformInfo.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
FunctionAddr VTableAddr Count
LLVM_ABI SmallVector< InstrProfValueData, 4 > getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind, uint32_t MaxNumValueData, uint64_t &TotalC, bool GetNoICPValue=false)
Extract the value profile data from Inst and returns them if Inst is annotated with value profile dat...
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
std::enable_if_t< std::is_unsigned_v< T >, T > SaturatingAdd(T X, T Y, bool *ResultOverflowed=nullptr)
Add two unsigned integers, X and Y, of type T.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.