diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-12-01 05:47:58 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-12-01 05:47:58 +0000 |
commit | cf2750a501da4bc44d89a606c6be4fe23f0b115d (patch) | |
tree | dadda1ae18fe89d8fd973823ba279c217d704603 /llvm/tools | |
parent | 2eed75926c411e14cfe4d5d4a612da092034e927 (diff) | |
download | bcm5719-llvm-cf2750a501da4bc44d89a606c6be4fe23f0b115d.tar.gz bcm5719-llvm-cf2750a501da4bc44d89a606c6be4fe23f0b115d.zip |
Bitcode: Correctly handle Fixed and VBR arrays in BitstreamCursor::skipRecord().
The assertions were wrong; we need to call getEncodingData() on the element,
not the array. While here, simplify the skipRecord() implementation for Fixed
and Char6 arrays. This is tested by the code I added to llvm-bcanalyzer
which makes sure that we can skip any record.
Differential Revision: https://reviews.llvm.org/D27241
llvm-svn: 288315
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index 14957e60b2b..d866201723a 100644 --- a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -567,7 +567,7 @@ static bool ParseBlock(BitstreamCursor &Stream, BitstreamBlockInfo &BlockInfo, ++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 @@ static bool ParseBlock(BitstreamCursor &Stream, BitstreamBlockInfo &BlockInfo, 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 @@ static bool ParseBlock(BitstreamCursor &Stream, BitstreamBlockInfo &BlockInfo, outs() << "\n"; } + + // Make sure that we can skip the current record. + Stream.JumpToBit(CurrentRecordPos); + Stream.skipRecord(Entry.ID); } } |