12#ifndef LLVM_PROFILEDATA_INSTRPROFCORRELATOR_H
13#define LLVM_PROFILEDATA_INSTRPROFCORRELATOR_H
65 return Ctx->CountersSectionEnd -
Ctx->CountersSectionStart;
82 std::unique_ptr<MemoryBuffer>
Buffer;
102 const std::unique_ptr<Context>
Ctx;
139template <
class IntPtrT>
148 return Data.empty() ? nullptr :
Data.data();
155 get(std::unique_ptr<InstrProfCorrelator::Context> Ctx,
159 std::vector<RawInstrProf::ProfileData<IntPtrT>>
Data;
171 IntPtrT CounterOffset, IntPtrT BitmapOffset,
172 IntPtrT FunctionPtr,
uint32_t NumCounters,
182 std::unique_ptr<InstrProfCorrelator::Context> Ctx)
190template <
class IntPtrT>
194 std::unique_ptr<InstrProfCorrelator::Context>
Ctx)
199 std::unique_ptr<DWARFContext> DICtx;
202 std::optional<uint64_t> getLocation(
const DWARFDie &Die)
const;
208 std::optional<std::pair<InstrProfCorrelator::Probe, IntPtrT>>
209 addCountersToDataProbe(
const DWARFDie &Die,
const bool UnlimitedWarnings,
210 int &NumSuppressedWarnings);
212 std::optional<std::pair<InstrProfCorrelator::Probe, IntPtrT>>
213 addBitmapToDataProbe(
const DWARFDie &Die,
const bool UnlimitedWarnings,
214 int &NumSuppressedWarnings);
243 void correlateProfileDataImpl(
252template <
class IntPtrT>
265 void correlateProfileDataImpl(
This file declares a Build ID fetcher implementation for obtaining debug info from debuginfod.
This file declares a library for handling Build IDs and using them to find debug info.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file implements a map that provides insertion order iteration.
static constexpr StringLiteral Filename
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t getNamesSize() const
Return the number of bytes in the names string.
const char * getNamesPointer() const
Return a pointer to the names string that this class constructs.
BinaryInstrProfCorrelator(std::unique_ptr< InstrProfCorrelator::Context > Ctx)
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Implements a dense probed hash-table based set.
DwarfInstrProfCorrelator(std::unique_ptr< DWARFContext > DICtx, std::unique_ptr< InstrProfCorrelator::Context > Ctx)
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
static llvm::Expected< std::unique_ptr< InstrProfCorrelatorImpl< IntPtrT > > > get(std::unique_ptr< InstrProfCorrelator::Context > Ctx, const object::ObjectFile &Obj, ProfCorrelatorKind FileKind)
virtual Error correlateProfileNameImpl()=0
virtual void correlateProfileDataImpl(int MaxWarnings, InstrProfCorrelator::CorrelationData *Data=nullptr)=0
std::vector< RawInstrProf::ProfileData< IntPtrT > > Data
Error correlateProfileData(int MaxWarnings) override
Construct a ProfileData vector used to correlate raw instrumentation data to their functions.
static bool classof(const InstrProfCorrelator *C)
InstrProfCorrelatorImpl(std::unique_ptr< InstrProfCorrelator::Context > Ctx)
void addDataProbe(uint64_t FunctionName, uint64_t CFGHash, IntPtrT CounterOffset, IntPtrT BitmapOffset, IntPtrT FunctionPtr, uint32_t NumCounters, uint32_t NumBitmapBytes)
const RawInstrProf::ProfileData< IntPtrT > * getDataPointer() const
Return a pointer to the underlying ProfileData vector that this class constructs.
T maybeSwap(T Value) const
Error dumpYaml(int MaxWarnings, raw_ostream &OS) override
Process debug info and dump the correlation data.
size_t getDataSize() const
Return the number of ProfileData elements.
InstrProfCorrelator - A base class used to create raw instrumentation data to their functions.
virtual Error correlateProfileData(int MaxWarnings)=0
Construct a ProfileData vector used to correlate raw instrumentation data to their functions.
static LLVM_ABI const char * FunctionNameAttributeName
static LLVM_ABI const char * CFGHashAttributeName
InstrProfCorrelator(InstrProfCorrelatorKind K, std::unique_ptr< Context > Ctx)
uint64_t getCountersSectionSize() const
Return the size of the counters section in bytes.
std::vector< std::string > NamesVec
static LLVM_ABI const char * NumCountersAttributeName
virtual Error dumpYaml(int MaxWarnings, raw_ostream &OS)=0
Process debug info and dump the correlation data.
const char * getNamesPointer() const
Return a pointer to the names string that this class constructs.
virtual ~InstrProfCorrelator()=default
InstrProfCorrelatorKind getKind() const
const std::unique_ptr< Context > Ctx
LLVM_ABI std::optional< size_t > getDataSize() const
Return the number of ProfileData elements.
static LLVM_ABI llvm::Expected< std::unique_ptr< InstrProfCorrelator > > get(StringRef Filename, ProfCorrelatorKind FileKind, const object::BuildIDFetcher *BIDFetcher=nullptr, const ArrayRef< llvm::object::BuildID > BIs={})
static LLVM_ABI const char * NumBitmapBitsAttributeName
size_t getNamesSize() const
Return the number of bytes in the names string.
Represent a constant reference to a string, i.e.
LLVM Value Representation.
BuildIDFetcher searches local cache directories for debug info.
This class is the base class for all object file types.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr ValuesPtrExpr NumBitmapBytes
constexpr T byteswap(T V) noexcept
Reverses the bytes in the given integer value V.
ProfCorrelatorKind
Whether the debug info or the profile metadata sections correlate raw profile data to functions.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
bool ShouldSwapBytes
True if target and host have different endian orders.
std::unique_ptr< MemoryBuffer > Buffer
uint64_t CountersSectionEnd
uint64_t CountersSectionStart
The address range of the __llvm_prf_cnts section.
llvm::DenseMap< uint64_t, uint64_t > MachOFixups
Resolved values for Mach-O linker fixup chains when FileKind is Binary.
static LLVM_ABI llvm::Expected< std::unique_ptr< Context > > get(std::unique_ptr< MemoryBuffer > Buffer, object::ObjectFile &Obj, ProfCorrelatorKind FileKind)
uint64_t BitmapSectionEnd
uint64_t BitmapSectionStart
The address range of the __llvm_prf_bits section.
const char * DataStart
The pointer points to start/end of profile data/name sections if FileKind is Binary.
std::vector< Probe > Probes
std::optional< std::string > LinkageName
std::optional< int > LineNumber
yaml::Hex64 CounterOffset
std::optional< std::string > FilePath
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
This class should be specialized by any type for which vectors of that type need to be converted to/f...