diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-04-07 02:56:46 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-04-07 02:56:46 +0000 |
| commit | 73ab815c275d490d99d50a3b6c67939c250fc135 (patch) | |
| tree | 2057efe18c82c07589c56dbf22bfce331e1e9438 /llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | |
| parent | 47d6e7b93e3d957c38b21a30963d48bff88fd1a5 (diff) | |
| download | bcm5719-llvm-73ab815c275d490d99d50a3b6c67939c250fc135.tar.gz bcm5719-llvm-73ab815c275d490d99d50a3b6c67939c250fc135.zip | |
Add an API for the bitstream reader to read blobs and return
them by reference, instead of packing each byte into a
smallvector.
llvm-svn: 68486
Diffstat (limited to 'llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp')
| -rw-r--r-- | llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index 2953e08afa5..4832a4c0b21 100644 --- a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -342,32 +342,14 @@ static bool ParseBlock(BitstreamReader &Stream, unsigned IndentLevel) { break; default: Record.clear(); - bool HasBlob = false; ++BlockStats.NumRecords; - if (AbbrevID != bitc::UNABBREV_RECORD) { + if (AbbrevID != bitc::UNABBREV_RECORD) ++BlockStats.NumAbbreviatedRecords; - const BitCodeAbbrev *Abbv = Stream.getAbbrev(AbbrevID); - if (Abbv->getNumOperandInfos() != 0) { - const BitCodeAbbrevOp &LastOp = - Abbv->getOperandInfo(Abbv->getNumOperandInfos()-1); - // If the last operand is a blob, then this record has blob data. - if (LastOp.isEncoding() && - LastOp.getEncoding() == BitCodeAbbrevOp::Blob) - HasBlob = true; - } - } - unsigned Code; const char *BlobStart = 0; unsigned BlobLen = 0; - if (!HasBlob) - Code = Stream.ReadRecord(AbbrevID, Record); - else { - Code = Stream.ReadRecord(AbbrevID, Record); - BlobStart = BlobStart; - BlobLen = BlobLen; - } + unsigned Code = Stream.ReadRecord(AbbrevID, Record, BlobStart, BlobLen); // Increment the # occurrences of this code. if (BlockStats.CodeFreq.size() <= Code) @@ -388,7 +370,24 @@ static bool ParseBlock(BitstreamReader &Stream, unsigned IndentLevel) { for (unsigned i = 0, e = Record.size(); i != e; ++i) std::cerr << " op" << i << "=" << (int64_t)Record[i]; - std::cerr << "/>\n"; + std::cerr << "/>"; + + if (BlobStart) { + std::cerr << " blob data = "; + bool BlobIsPrintable = true; + for (unsigned i = 0; i != BlobLen; ++i) + if (!isprint(BlobStart[i])) { + BlobIsPrintable = false; + break; + } + + if (BlobIsPrintable) + std::cerr << "'" << std::string(BlobStart, BlobStart+BlobLen) <<"'"; + else + std::cerr << "unprintable, " << BlobLen << " bytes."; + } + + std::cerr << "\n"; } break; |

