mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-18 16:03:17 +00:00
Print statistics for each record kind saying the number of bits
and % abbreviated. For example: Record Histogram: Count # Bits % Abv Record Kind 25738 3424174 100.00 SM_SLOC_INSTANTIATION_ENTRY 814 562079 100.00 SM_SLOC_FILE_ENTRY 798 34110 SM_HEADER_FILE_INFO 3 91104 100.00 SM_SLOC_BUFFER_BLOB 3 498 100.00 SM_SLOC_BUFFER_ENTRY 1 465 SM_LINE_TABLE git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70215 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2443747e45
commit
c167cac8f0
@ -247,6 +247,10 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID,
|
||||
|
||||
struct PerRecordStats {
|
||||
unsigned NumInstances;
|
||||
unsigned NumAbbrev;
|
||||
uint64_t TotalBits;
|
||||
|
||||
PerRecordStats() : NumInstances(0), NumAbbrev(0), TotalBits(0) {}
|
||||
};
|
||||
|
||||
struct PerBlockIDStats {
|
||||
@ -332,6 +336,8 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned IndentLevel) {
|
||||
if (Stream.AtEndOfStream())
|
||||
return Error("Premature end of bitstream");
|
||||
|
||||
uint64_t RecordStartBit = Stream.GetCurrentBitNo();
|
||||
|
||||
// Read the code for this record.
|
||||
unsigned AbbrevID = Stream.ReadCode();
|
||||
switch (AbbrevID) {
|
||||
@ -375,11 +381,17 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned IndentLevel) {
|
||||
unsigned BlobLen = 0;
|
||||
unsigned Code = Stream.ReadRecord(AbbrevID, Record, BlobStart, BlobLen);
|
||||
|
||||
|
||||
|
||||
// Increment the # occurrences of this code.
|
||||
if (BlockStats.CodeFreq.size() <= Code)
|
||||
BlockStats.CodeFreq.resize(Code+1);
|
||||
BlockStats.CodeFreq[Code].NumInstances++;
|
||||
|
||||
BlockStats.CodeFreq[Code].TotalBits +=
|
||||
Stream.GetCurrentBitNo()-RecordStartBit;
|
||||
if (AbbrevID != bitc::UNABBREV_RECORD)
|
||||
BlockStats.CodeFreq[Code].NumAbbrev++;
|
||||
|
||||
if (Dump) {
|
||||
std::cerr << Indent << " <";
|
||||
if (const char *CodeName =
|
||||
@ -545,9 +557,18 @@ static int AnalyzeBitcode() {
|
||||
std::reverse(FreqPairs.begin(), FreqPairs.end());
|
||||
|
||||
std::cerr << "\tRecord Histogram:\n";
|
||||
fprintf(stderr, "\t\t Count Record Kind\n");
|
||||
fprintf(stderr, "\t\t Count # Bits %% Abv Record Kind\n");
|
||||
for (unsigned i = 0, e = FreqPairs.size(); i != e; ++i) {
|
||||
fprintf(stderr, "\t\t%7d ", FreqPairs[i].first);
|
||||
const PerRecordStats &RecStats = Stats.CodeFreq[FreqPairs[i].second];
|
||||
|
||||
fprintf(stderr, "\t\t%7d %9llu ", RecStats.NumInstances,
|
||||
RecStats.TotalBits);
|
||||
|
||||
if (RecStats.NumAbbrev)
|
||||
fprintf(stderr, "%7.2f ",
|
||||
(double)RecStats.NumAbbrev/RecStats.NumInstances*100);
|
||||
else
|
||||
fprintf(stderr, " ");
|
||||
|
||||
if (const char *CodeName =
|
||||
GetCodeName(FreqPairs[i].second, I->first, StreamFile))
|
||||
|
Loading…
x
Reference in New Issue
Block a user