aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKarl Schimpf <kschimpf@google.com>2013-05-24 09:55:03 -0700
committerKarl Schimpf <kschimpf@google.com>2013-05-24 09:55:03 -0700
commit80b7ba7480724c773b96da24999d817b6b46ef29 (patch)
tree6b7dba38623ef94b89b43f7cba898c1b8017294f /tools
parent501900058c0815d35e630d416e3d4e1373b75b9c (diff)
Make abbreviations explicit in pnacl-freeze/thaw.
[1] Explicitly enumerate all abbreviation values, including the maximum abbreviation for each type of block. [2] Make "enter subblock" calculate number of bits needed by passing in maximum abbreviation (associated with block) rather than requiring the developer to compute this value every time a subblock is entered. *NOTE* This code changes encoding sizes to be based on the maximum allowed value, rather than requiring the developer to calculate out the number of bits needed. This change doesn't make the PNaCL bitcode files incompatable with LLVM bitcode files, since it does not effect the bitcode reader. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/14813032
Diffstat (limited to 'tools')
-rw-r--r--tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp b/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp
index 7c542d79ae..445689bbc6 100644
--- a/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp
+++ b/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp
@@ -28,12 +28,15 @@
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "pnacl-bcanalyzer"
+
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Bitcode/NaCl/NaClBitstreamReader.h"
#include "llvm/Bitcode/NaCl/NaClLLVMBitCodes.h"
#include "llvm/Bitcode/NaCl/NaClReaderWriter.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -325,6 +328,7 @@ static bool Error(const std::string &Err) {
static bool ParseBlock(NaClBitstreamCursor &Stream, unsigned BlockID,
unsigned IndentLevel) {
std::string Indent(IndentLevel*2, ' ');
+ DEBUG(dbgs() << Indent << "-> ParseBlock(" << BlockID << ")\n");
uint64_t BlockBitStart = Stream.GetCurrentBitNo();
// Get the statistics for this BlockID.
@@ -339,6 +343,7 @@ static bool ParseBlock(NaClBitstreamCursor &Stream, unsigned BlockID,
return Error("Malformed BlockInfoBlock");
uint64_t BlockBitEnd = Stream.GetCurrentBitNo();
BlockStats.NumBits += BlockBitEnd-BlockBitStart;
+ DEBUG(dbgs() << Indent << "<- ParseBlock\n");
return false;
}
@@ -386,6 +391,7 @@ static bool ParseBlock(NaClBitstreamCursor &Stream, unsigned BlockID,
else
outs() << "UnknownBlock" << BlockID << ">\n";
}
+ DEBUG(dbgs() << Indent << "<- ParseBlock\n");
return false;
}
@@ -478,6 +484,7 @@ static void PrintSize(uint64_t Bits) {
/// AnalyzeBitcode - Analyze the bitcode file specified by InputFilename.
static int AnalyzeBitcode() {
+ DEBUG(dbgs() << "-> AnalyzeBitcode\n");
// Read the input file.
OwningPtr<MemoryBuffer> MemBuf;
@@ -620,6 +627,7 @@ static int AnalyzeBitcode() {
}
}
+ DEBUG(dbgs() << "<- AnalyzeBitcode\n");
return 0;
}