summaryrefslogtreecommitdiffstats
path: root/tools/llvm-bcanalyzer
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-02-06 00:46:09 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-02-06 00:46:09 +0000
commit0f73f7ad3bceb9633986750999be5e50640bd560 (patch)
tree0fd188434a8e87e743478fa7e36664bc216b0de5 /tools/llvm-bcanalyzer
parent04de74cc79d4a357f4edcbd119caf104ac3cdeba (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259965 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-bcanalyzer')
-rw-r--r--tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
index 48523f99441a..1a4bc9ef178b 100644
--- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -406,13 +406,13 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned BlockID,
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 &Stream, unsigned BlockID,
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 &Stream, unsigned BlockID,
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 &Stream, unsigned BlockID,
++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))