From 3f75d3176b495f0a58a8b6cd0ebe1b50d0392fac Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 6 Apr 2009 22:44:40 +0000 Subject: stub out code for reading record with blobs as blobs. Not active yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68472 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'tools/llvm-bcanalyzer') diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index cde27fac48..2953e08afa 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -341,12 +341,33 @@ static bool ParseBlock(BitstreamReader &Stream, unsigned IndentLevel) { ++BlockStats.NumAbbrevs; break; default: + Record.clear(); + bool HasBlob = false; + ++BlockStats.NumRecords; - if (AbbrevID != bitc::UNABBREV_RECORD) + if (AbbrevID != bitc::UNABBREV_RECORD) { ++BlockStats.NumAbbreviatedRecords; - - Record.clear(); - unsigned Code = Stream.ReadRecord(AbbrevID, Record); + 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; + } // Increment the # occurrences of this code. if (BlockStats.CodeFreq.size() <= Code) -- cgit v1.2.3