From 33ee997b37a6a8a53d807e033f868393708967fe Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Wed, 21 Oct 2015 06:10:55 +0000 Subject: [PATCH] Revert "Add missing #include, found by modules build." This reverts commit r250239. It seems unwanted changes got committed here, and part of the patch does not seem correct. For instance RoundUpToAlignment() is called without its returned value actually used. From: Mehdi Amini git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250882 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../llvm/Transforms/Utils/LoopVersioning.h | 1 - tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 90 ++----------------- 2 files changed, 8 insertions(+), 83 deletions(-) diff --git a/include/llvm/Transforms/Utils/LoopVersioning.h b/include/llvm/Transforms/Utils/LoopVersioning.h index 41eb50c7662..58a9e5b5a70 100644 --- a/include/llvm/Transforms/Utils/LoopVersioning.h +++ b/include/llvm/Transforms/Utils/LoopVersioning.h @@ -16,7 +16,6 @@ #ifndef LLVM_TRANSFORMS_UTILS_LOOPVERSIONING_H #define LLVM_TRANSFORMS_UTILS_LOOPVERSIONING_H -#include "llvm/Analysis/LoopAccessAnalysis.h" #include "llvm/Transforms/Utils/ValueMapper.h" #include "llvm/Transforms/Utils/LoopUtils.h" diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index b7e0921d4f8..b67b89d018c 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -35,7 +35,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Format.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MathExtras.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" @@ -336,20 +335,11 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, } struct PerRecordStats { - /// The number of times this record code has been seen. unsigned NumInstances; - /// The number of times this record code has been seen abbreviated. unsigned NumAbbrev; - /// The total number of bits used for this record on disk. uint64_t TotalBits; - /// The number of bits that would have been used if no abbrevs were used. - uint64_t UnabbrevBits; - /// The number of bits that would be used if "good" abbreviations were used. - uint64_t GoodAbbrevBits; - - PerRecordStats() - : NumInstances(0), NumAbbrev(0), TotalBits(0), UnabbrevBits(0), - GoodAbbrevBits(0) {} + + PerRecordStats() : NumInstances(0), NumAbbrev(0), TotalBits(0) {} }; struct PerBlockIDStats { @@ -388,58 +378,6 @@ static bool Error(const Twine &Err) { return true; } -static unsigned computeVBR6Bits(uint64_t Val) { - unsigned Bits = 0; - do { - Bits += 6; - } while (Val >>= 5); - return Bits; -} - -static void addBlobSize(uint64_t &Bits, StringRef Blob) { - // Blob size is always VBR6. - Bits += computeVBR6Bits(Blob.size()); - - // Blob is always 32-bit aligned, and padded to a multiple of 32 bits. - RoundUpToAlignment(Bits, 32); - Bits += Blob.size() * 8; - RoundUpToAlignment(Bits, 32); -} - -/// \brief Compute the number of bits that would be used by the record if it -/// were unabbreviated. -static uint64_t computeUnabbrevBits(unsigned AbbrevIDWidth, unsigned Code, - ArrayRef Record, StringRef Blob) { - uint64_t Bits = - AbbrevIDWidth + computeVBR6Bits(Code) + computeVBR6Bits(Record.size()); - // Use VBR6 for all fields. - for (uint64_t Val : Record) - Bits += computeVBR6Bits(Val); - // Assume Blob representation for the blob, even though a Blob cannot - // be unabbreviated. - if (!Blob.empty()) - addBlobSize(Bits, Blob); - return Bits; -} - -/// \brief Compute the number of bits that would be used by the record if a -/// "good" abbreviation were used. We use an extremely simple heuristic for -/// "good"ness: pick the best abbrev that uses a Literal for the record code, -/// a normal Blob field for the blob (if present), and a minimal-width Fixed -/// field for everything else. -static uint64_t computeGoodAbbrevBits(unsigned AbbrevIDWidth, unsigned Code, - ArrayRef Record, - StringRef Blob) { - uint64_t Bits = AbbrevIDWidth; - // Use Fixed for all fields (other than the record code). - for (uint64_t Val : Record) - Bits += 64 - llvm::countLeadingZeros(Val); - // Assume Blob representation for the blob. - if (!Blob.empty()) - addBlobSize(Bits, Blob); - return Bits; -} - /// ParseBlock - Read a block, updating statistics, etc. static bool ParseBlock(BitstreamCursor &Stream, unsigned BlockID, unsigned IndentLevel, CurStreamTypeType CurStreamType) { @@ -544,10 +482,6 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned BlockID, BlockStats.CodeFreq[Code].NumInstances++; BlockStats.CodeFreq[Code].TotalBits += Stream.GetCurrentBitNo()-RecordStartBit; - BlockStats.CodeFreq[Code].UnabbrevBits += - computeUnabbrevBits(Stream.getAbbrevIDWidth(), Code, Record, Blob); - BlockStats.CodeFreq[Code].GoodAbbrevBits += - computeGoodAbbrevBits(Stream.getAbbrevIDWidth(), Code, Record, Blob); if (Entry.ID != bitc::UNABBREV_RECORD) { BlockStats.CodeFreq[Code].NumAbbrev++; ++BlockStats.NumAbbreviatedRecords; @@ -786,36 +720,28 @@ static int AnalyzeBitcode() { // Print a histogram of the codes we see. if (!NoHistogram && !Stats.CodeFreq.empty()) { - std::vector > FreqPairs; // + std::vector > FreqPairs; // for (unsigned i = 0, e = Stats.CodeFreq.size(); i != e; ++i) - if (unsigned Freq = Stats.CodeFreq[i].TotalBits) + if (unsigned Freq = Stats.CodeFreq[i].NumInstances) FreqPairs.push_back(std::make_pair(Freq, i)); std::stable_sort(FreqPairs.begin(), FreqPairs.end()); std::reverse(FreqPairs.begin(), FreqPairs.end()); outs() << "\tRecord Histogram:\n"; - outs() << "\t\t Count # Bits % Abv % Cmp (cur/best) Record Kind\n"; + outs() << "\t\t Count # Bits %% Abv Record Kind\n"; for (unsigned i = 0, e = FreqPairs.size(); i != e; ++i) { const PerRecordStats &RecStats = Stats.CodeFreq[FreqPairs[i].second]; - outs() << format("\t\t%7d %9lu ", + outs() << format("\t\t%7d %9lu", RecStats.NumInstances, (unsigned long)RecStats.TotalBits); if (RecStats.NumAbbrev) outs() << - format("%7.2f ", + format("%7.2f ", (double)RecStats.NumAbbrev/RecStats.NumInstances*100); else - outs() << " "; - - if (RecStats.UnabbrevBits) - outs() << format( - "%7.2f / %7.2f ", - (double)RecStats.TotalBits / RecStats.UnabbrevBits * 100, - (double)RecStats.GoodAbbrevBits / RecStats.UnabbrevBits * 100); - else - outs() << " "; + outs() << " "; if (const char *CodeName = GetCodeName(FreqPairs[i].second, I->first, StreamFile, -- 2.34.1