[llvm] r259965 - llvm-bcanalyzer: Produce summary information for the BLOCKINFO block, it can be
Richard Smith via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 5 16:46:09 PST 2016
Author: rsmith
Date: Fri Feb 5 18:46:09 2016
New Revision: 259965
URL: http://llvm.org/viewvc/llvm-project?rev=259965&view=rev
Log:
llvm-bcanalyzer: Produce summary information for the BLOCKINFO block, it can be
a significant fraction of the file size (for files that otherwise have few
records). Also include an average size per record in the summary information.
Modified:
llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Modified: llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp?rev=259965&r1=259964&r2=259965&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp (original)
+++ llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Fri Feb 5 18:46:09 2016
@@ -406,13 +406,13 @@ static bool ParseBlock(BitstreamCursor &
BlockStats.NumInstances++;
// BLOCKINFO is a special part of the stream.
+ bool DumpRecords = Dump;
if (BlockID == bitc::BLOCKINFO_BLOCK_ID) {
if (Dump) outs() << Indent << "<BLOCKINFO_BLOCK/>\n";
- if (Stream.ReadBlockInfoBlock())
+ if (BitstreamCursor(Stream).ReadBlockInfoBlock())
return Error("Malformed BlockInfoBlock");
- uint64_t BlockBitEnd = Stream.GetCurrentBitNo();
- BlockStats.NumBits += BlockBitEnd-BlockBitStart;
- return false;
+ // It's not really interesting to dump the contents of the blockinfo block.
+ DumpRecords = false;
}
unsigned NumWords = 0;
@@ -420,7 +420,7 @@ static bool ParseBlock(BitstreamCursor &
return Error("Malformed block record");
const char *BlockName = nullptr;
- if (Dump) {
+ if (DumpRecords) {
outs() << Indent << "<";
if ((BlockName = GetBlockName(BlockID, *Stream.getBitStreamReader(),
CurStreamType)))
@@ -453,7 +453,7 @@ static bool ParseBlock(BitstreamCursor &
case BitstreamEntry::EndBlock: {
uint64_t BlockBitEnd = Stream.GetCurrentBitNo();
BlockStats.NumBits += BlockBitEnd-BlockBitStart;
- if (Dump) {
+ if (DumpRecords) {
outs() << Indent << "</";
if (BlockName)
outs() << BlockName << ">\n";
@@ -503,7 +503,7 @@ static bool ParseBlock(BitstreamCursor &
++BlockStats.NumAbbreviatedRecords;
}
- if (Dump) {
+ if (DumpRecords) {
outs() << Indent << " <";
if (const char *CodeName =
GetCodeName(Code, BlockID, *Stream.getBitStreamReader(),
@@ -764,7 +764,7 @@ static int AnalyzeBitcode() {
std::reverse(FreqPairs.begin(), FreqPairs.end());
outs() << "\tRecord Histogram:\n";
- outs() << "\t\t Count # Bits %% Abv Record Kind\n";
+ outs() << "\t\t Count # Bits b/Rec % Abv Record Kind\n";
for (unsigned i = 0, e = FreqPairs.size(); i != e; ++i) {
const PerRecordStats &RecStats = Stats.CodeFreq[FreqPairs[i].second];
@@ -772,13 +772,20 @@ static int AnalyzeBitcode() {
RecStats.NumInstances,
(unsigned long)RecStats.TotalBits);
+ if (RecStats.NumInstances > 1)
+ outs() << format(" %9.1f",
+ (double)RecStats.TotalBits/RecStats.NumInstances);
+ else
+ outs() << " ";
+
if (RecStats.NumAbbrev)
outs() <<
- format("%7.2f ",
+ format(" %7.2f",
(double)RecStats.NumAbbrev/RecStats.NumInstances*100);
else
- outs() << " ";
+ outs() << " ";
+ outs() << " ";
if (const char *CodeName =
GetCodeName(FreqPairs[i].second, I->first, StreamFile,
CurStreamType))
More information about the llvm-commits
mailing list