summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-12-01 05:47:58 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-12-01 05:47:58 +0000
commitcf2750a501da4bc44d89a606c6be4fe23f0b115d (patch)
treedadda1ae18fe89d8fd973823ba279c217d704603 /llvm/lib/Bitcode
parent2eed75926c411e14cfe4d5d4a612da092034e927 (diff)
downloadbcm5719-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/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Reader/BitstreamReader.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
index f1237069f7b..43c9aebd79e 100644
--- a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
@@ -131,18 +131,16 @@ void BitstreamCursor::skipRecord(unsigned AbbrevID) {
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;
OpenPOWER on IntegriCloud