[PATCH] D27241: Bitcode: Correctly handle Fixed and VBR arrays in BitstreamCursor::skipRecord().
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 30 21:58:05 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288315: Bitcode: Correctly handle Fixed and VBR arrays in BitstreamCursor::skipRecord(). (authored by pcc).
Changed prior to commit:
https://reviews.llvm.org/D27241?vs=79673&id=79863#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27241
Files:
llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Index: llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
===================================================================
--- llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -567,7 +567,7 @@
++BlockStats.NumRecords;
StringRef Blob;
- unsigned CurrentRecordPos = Stream.getCurrentByteNo();
+ unsigned CurrentRecordPos = Stream.GetCurrentBitNo();
unsigned Code = Stream.readRecord(Entry.ID, Record, &Blob);
// Increment the # occurrences of this code.
@@ -608,7 +608,7 @@
SHA1 Hasher;
StringRef Hash;
{
- int BlockSize = CurrentRecordPos - BlockEntryPos;
+ int BlockSize = (CurrentRecordPos / 8) - BlockEntryPos;
auto Ptr = Stream.getPointerToByte(BlockEntryPos, BlockSize);
Hasher.update(ArrayRef<uint8_t>(Ptr, BlockSize));
Hash = Hasher.result();
@@ -675,6 +675,10 @@
outs() << "\n";
}
+
+ // Make sure that we can skip the current record.
+ Stream.JumpToBit(CurrentRecordPos);
+ Stream.skipRecord(Entry.ID);
}
}
Index: llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
===================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
+++ llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
@@ -131,18 +131,16 @@
default:
report_fatal_error("Array element type can't be an Array or a Blob");
case BitCodeAbbrevOp::Fixed:
- assert((unsigned)Op.getEncodingData() <= MaxChunkSize);
- for (; NumElts; --NumElts)
- Read((unsigned)EltEnc.getEncodingData());
+ assert((unsigned)EltEnc.getEncodingData() <= MaxChunkSize);
+ JumpToBit(GetCurrentBitNo() + NumElts * EltEnc.getEncodingData());
break;
case BitCodeAbbrevOp::VBR:
- assert((unsigned)Op.getEncodingData() <= MaxChunkSize);
+ assert((unsigned)EltEnc.getEncodingData() <= MaxChunkSize);
for (; NumElts; --NumElts)
ReadVBR64((unsigned)EltEnc.getEncodingData());
break;
case BitCodeAbbrevOp::Char6:
- for (; NumElts; --NumElts)
- Read(6);
+ JumpToBit(GetCurrentBitNo() + NumElts * 6);
break;
}
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27241.79863.patch
Type: text/x-patch
Size: 2303 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161201/997c9969/attachment.bin>
More information about the llvm-commits
mailing list