Skip to content

Commit 89cf9c8

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
2 parents 54aa16d + da72656 commit 89cf9c8

17 files changed

+223
-256
lines changed

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ class BinaryFunction {
386386
/// Profile match ratio.
387387
float ProfileMatchRatio{0.0f};
388388

389-
/// Raw branch count for this function in the profile.
390-
uint64_t RawBranchCount{0};
389+
/// Raw sample/branch count for this function in the profile.
390+
uint64_t RawSampleCount{0};
391391

392392
/// Dynamically executed function bytes, used for density computation.
393393
uint64_t SampleCountInBytes{0};
@@ -1880,13 +1880,12 @@ class BinaryFunction {
18801880
/// Return COUNT_NO_PROFILE if there's no profile info.
18811881
uint64_t getExecutionCount() const { return ExecutionCount; }
18821882

1883-
/// Return the raw profile information about the number of branch
1884-
/// executions corresponding to this function.
1885-
uint64_t getRawBranchCount() const { return RawBranchCount; }
1883+
/// Return the raw profile information about the number of samples (basic
1884+
/// profile) or branch executions (branch profile) recorded in this function.
1885+
uint64_t getRawSampleCount() const { return RawSampleCount; }
18861886

1887-
/// Set the profile data about the number of branch executions corresponding
1888-
/// to this function.
1889-
void setRawBranchCount(uint64_t Count) { RawBranchCount = Count; }
1887+
/// Set raw count of samples or branches recorded in this function.
1888+
void setRawSampleCount(uint64_t Count) { RawSampleCount = Count; }
18901889

18911890
/// Return the number of dynamically executed bytes, from raw perf data.
18921891
uint64_t getSampleCountInBytes() const { return SampleCountInBytes; }

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,6 @@ class DataAggregator : public DataReader {
9292
uint64_t Addr;
9393
};
9494

95-
/// Used for parsing specific pre-aggregated input files.
96-
struct AggregatedLBREntry {
97-
enum Type : char { BRANCH = 0, FT, FT_EXTERNAL_ORIGIN, TRACE };
98-
Location From;
99-
Location To;
100-
uint64_t Count;
101-
uint64_t Mispreds;
102-
Type EntryType;
103-
};
104-
10595
struct Trace {
10696
uint64_t From;
10797
uint64_t To;
@@ -131,7 +121,6 @@ class DataAggregator : public DataReader {
131121
/// and use them later for processing and assigning profile.
132122
std::unordered_map<Trace, TakenBranchInfo, TraceHash> BranchLBRs;
133123
std::unordered_map<Trace, FTInfo, TraceHash> FallthroughLBRs;
134-
std::vector<AggregatedLBREntry> AggregatedLBRs;
135124
std::unordered_map<uint64_t, uint64_t> BasicSamples;
136125
std::vector<PerfMemSample> MemSamples;
137126

@@ -223,11 +212,6 @@ class DataAggregator : public DataReader {
223212
uint64_t NumTraces{0};
224213
uint64_t NumInvalidTraces{0};
225214
uint64_t NumLongRangeTraces{0};
226-
/// Specifies how many samples were recorded in cold areas if we are dealing
227-
/// with profiling data collected in a bolted binary. For LBRs, incremented
228-
/// for the source of the branch to avoid counting cold activity twice (one
229-
/// for source and another for destination).
230-
uint64_t NumColdSamples{0};
231215
uint64_t NumTotalSamples{0};
232216

233217
/// Looks into system PATH for Linux Perf and set up the aggregator to use it
@@ -416,14 +400,7 @@ class DataAggregator : public DataReader {
416400
/// F 41be90 41be90 4
417401
/// B 4b1942 39b57f0 3 0
418402
/// B 4b196f 4b19e0 2 0
419-
void parsePreAggregated();
420-
421-
/// Parse the full output of pre-aggregated LBR samples generated by
422-
/// an external tool.
423-
std::error_code parsePreAggregatedLBRSamples();
424-
425-
/// Process parsed pre-aggregated data.
426-
void processPreAggregated();
403+
std::error_code parsePreAggregated();
427404

428405
/// If \p Address falls into the binary address space based on memory
429406
/// mapping info \p MMI, then adjust it for further processing by subtracting
@@ -486,7 +463,6 @@ class DataAggregator : public DataReader {
486463
void dump(const PerfMemSample &Sample) const;
487464

488465
/// Profile diagnostics print methods
489-
void printColdSamplesDiagnostic() const;
490466
void printLongRangeTracesDiagnostic() const;
491467
void printBranchSamplesDiagnostics() const;
492468
void printBasicSamplesDiagnostics(uint64_t OutOfRangeSamples) const;

bolt/include/bolt/Profile/DataReader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ struct FuncSampleData {
252252
/// Get the number of samples recorded in [Start, End)
253253
uint64_t getSamples(uint64_t Start, uint64_t End) const;
254254

255+
/// Returns the total number of samples recorded in this function.
256+
uint64_t getSamples() const;
257+
255258
/// Aggregation helper
256259
DenseMap<uint64_t, size_t> Index;
257260

bolt/include/bolt/Profile/Heatmap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class Heatmap {
5757
}
5858

5959
/// Register a single sample at \p Address.
60-
void registerAddress(uint64_t Address) {
60+
void registerAddress(uint64_t Address, uint64_t Count) {
6161
if (!ignoreAddress(Address))
62-
++Map[Address / BucketSize];
62+
Map[Address / BucketSize] += Count;
6363
}
6464

6565
/// Register \p Count samples at [\p StartAddress, \p EndAddress ].

bolt/include/bolt/Utils/CommandLineOpts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ extern llvm::cl::opt<unsigned> HeatmapBlock;
4444
extern llvm::cl::opt<unsigned long long> HeatmapMaxAddress;
4545
extern llvm::cl::opt<unsigned long long> HeatmapMinAddress;
4646
extern llvm::cl::opt<bool> HeatmapPrintMappings;
47+
extern llvm::cl::opt<bool> HeatmapStats;
4748
extern llvm::cl::opt<bool> HotData;
4849
extern llvm::cl::opt<bool> HotFunctionsAtEnd;
4950
extern llvm::cl::opt<bool> HotText;

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) {
473473
OS << "\n Image : 0x" << Twine::utohexstr(getImageAddress());
474474
if (ExecutionCount != COUNT_NO_PROFILE) {
475475
OS << "\n Exec Count : " << ExecutionCount;
476-
OS << "\n Branch Count: " << RawBranchCount;
476+
OS << "\n Branch Count: " << RawSampleCount;
477477
OS << "\n Profile Acc : " << format("%.1f%%", ProfileMatchRatio * 100.0f);
478478
}
479479

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
14451445
if (!Function.hasProfile())
14461446
continue;
14471447

1448-
uint64_t SampleCount = Function.getRawBranchCount();
1448+
uint64_t SampleCount = Function.getRawSampleCount();
14491449
TotalSampleCount += SampleCount;
14501450

14511451
if (Function.hasValidProfile()) {

0 commit comments

Comments
 (0)