aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-profgen/PerfReader.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-profgen/PerfReader.h')
-rw-r--r--llvm/tools/llvm-profgen/PerfReader.h34
1 files changed, 21 insertions, 13 deletions
diff --git a/llvm/tools/llvm-profgen/PerfReader.h b/llvm/tools/llvm-profgen/PerfReader.h
index 4b3ac8f..778fc12 100644
--- a/llvm/tools/llvm-profgen/PerfReader.h
+++ b/llvm/tools/llvm-profgen/PerfReader.h
@@ -395,10 +395,13 @@ using BranchSample = std::map<std::pair<uint64_t, uint64_t>, uint64_t>;
// The counter of range samples for one function indexed by the range,
// which is represented as the start and end offset pair.
using RangeSample = std::map<std::pair<uint64_t, uint64_t>, uint64_t>;
+// <<inst-addr, vtable-data-symbol>, count> map for data access samples.
+using DataAccessSample = std::map<std::pair<uint64_t, StringRef>, uint64_t>;
// Wrapper for sample counters including range counter and branch counter
struct SampleCounter {
RangeSample RangeCounter;
BranchSample BranchCounter;
+ DataAccessSample DataAccessCounter;
void recordRangeCount(uint64_t Start, uint64_t End, uint64_t Repeat) {
assert(Start <= End && "Invalid instruction range");
@@ -407,6 +410,10 @@ struct SampleCounter {
void recordBranchCount(uint64_t Source, uint64_t Target, uint64_t Repeat) {
BranchCounter[{Source, Target}] += Repeat;
}
+ void recordDataAccessCount(uint64_t InstAddr, StringRef DataSymbol,
+ uint64_t Repeat) {
+ DataAccessCounter[{InstAddr, DataSymbol}] += Repeat;
+ }
};
// Sample counter with context to support context-sensitive profile
@@ -572,6 +579,13 @@ public:
// Entry of the reader to parse multiple perf traces
virtual void parsePerfTraces() = 0;
+
+ // Parse the <ip, vtable-data-symbol> from the data access perf trace file,
+ // and accummuate the data access count for each <ip, data-symbol> pair.
+ void
+ parseDataAccessPerfTraces(StringRef DataAccessPerfFile,
+ std::optional<int32_t> PIDFilter = std::nullopt);
+
const ContextSampleCounterMap &getSampleCounters() const {
return SampleCounters;
}
@@ -598,6 +612,12 @@ public:
// Entry of the reader to parse multiple perf traces
void parsePerfTraces() override;
+
+ // Parse a single line of a PERF_RECORD_MMAP event looking for a
+ // mapping between the binary name and its memory layout.
+ static bool extractMMapEventForBinary(ProfiledBinary *Binary, StringRef Line,
+ MMapEvent &MMap);
+
// Generate perf script from perf data
static PerfInputFile convertPerfDataToTrace(ProfiledBinary *Binary,
bool SkipPID, PerfInputFile &File,
@@ -611,23 +631,11 @@ public:
static SmallVector<CleanupInstaller, 2> TempFileCleanups;
protected:
- // The parsed MMap event
- struct MMapEvent {
- int64_t PID = 0;
- uint64_t Address = 0;
- uint64_t Size = 0;
- uint64_t Offset = 0;
- StringRef BinaryPath;
- };
-
// Check whether a given line is LBR sample
static bool isLBRSample(StringRef Line);
// Check whether a given line is MMAP event
static bool isMMapEvent(StringRef Line);
- // Parse a single line of a PERF_RECORD_MMAP event looking for a
- // mapping between the binary name and its memory layout.
- static bool extractMMapEventForBinary(ProfiledBinary *Binary, StringRef Line,
- MMapEvent &MMap);
+
// Update base address based on mmap events
void updateBinaryAddress(const MMapEvent &Event);
// Parse mmap event and update binary address