summaryrefslogtreecommitdiff
path: root/lib/Bitcode/Reader
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2013-01-21 18:18:25 +0000
committerChris Lattner <sabre@nondot.org>2013-01-21 18:18:25 +0000
commit47543a8a66fb9451126f134808b55853aca57e1c (patch)
treea3bf17b040568cf138ba76ba0c1590a8ab1632f5 /lib/Bitcode/Reader
parentfd0543d9be9886398628e411aba8c392b28d17b6 (diff)
downloadllvm-47543a8a66fb9451126f134808b55853aca57e1c.tar.gz
llvm-47543a8a66fb9451126f134808b55853aca57e1c.tar.bz2
llvm-47543a8a66fb9451126f134808b55853aca57e1c.tar.xz
wean Blob handling logic off of banging on NextChar directly. Instead, make
it reason about the current bit position, which is always independent of the underlying cursors word size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173063 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Reader')
-rw-r--r--lib/Bitcode/Reader/BitstreamReader.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/Bitcode/Reader/BitstreamReader.cpp b/lib/Bitcode/Reader/BitstreamReader.cpp
index eb8b5dea72..92133bb969 100644
--- a/lib/Bitcode/Reader/BitstreamReader.cpp
+++ b/lib/Bitcode/Reader/BitstreamReader.cpp
@@ -184,17 +184,17 @@ void BitstreamCursor::skipRecord(unsigned AbbrevID) {
SkipToFourByteBoundary(); // 32-bit alignment
// Figure out where the end of this blob will be including tail padding.
- size_t NewEnd = NextChar+((NumElts+3)&~3);
+ size_t NewEnd = GetCurrentBitNo()+((NumElts+3)&~3)*8;
// If this would read off the end of the bitcode file, just set the
// record to empty and return.
- if (!canSkipToPos(NewEnd)) {
+ if (!canSkipToPos(NewEnd/8)) {
NextChar = BitStream->getBitcodeBytes().getExtent();
break;
}
// Skip over the blob.
- NextChar = NewEnd;
+ JumpToBit(NewEnd);
}
}
@@ -244,11 +244,12 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
SkipToFourByteBoundary(); // 32-bit alignment
// Figure out where the end of this blob will be including tail padding.
- size_t NewEnd = NextChar+((NumElts+3)&~3);
+ size_t CurBitPos = GetCurrentBitNo();
+ size_t NewEnd = CurBitPos+((NumElts+3)&~3)*8;
// If this would read off the end of the bitcode file, just set the
// record to empty and return.
- if (!canSkipToPos(NewEnd)) {
+ if (!canSkipToPos(NewEnd/8)) {
Vals.append(NumElts, 0);
NextChar = BitStream->getBitcodeBytes().getExtent();
break;
@@ -259,14 +260,16 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
if (Blob) {
*Blob =
StringRef((const char*)BitStream->getBitcodeBytes().getPointer(
- NextChar, NumElts),
- NumElts);
+ CurBitPos/8, NumElts),
+ NumElts);
} else {
- for (; NumElts; ++NextChar, --NumElts)
- Vals.push_back(getByte(NextChar));
+ // FIXME: This is a brutally inefficient way to do this. Why isn't this
+ // just using getPointer?
+ for (; NumElts; --NumElts)
+ Vals.push_back(Read(8));
}
// Skip over tail padding.
- NextChar = NewEnd;
+ JumpToBit(NewEnd);
}
unsigned Code = (unsigned)Vals[0];