[llvm-commits] [llvm] r173063 - /llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
Chris Lattner
sabre at nondot.org
Mon Jan 21 10:18:25 PST 2013
Author: lattner
Date: Mon Jan 21 12:18:25 2013
New Revision: 173063
URL: http://llvm.org/viewvc/llvm-project?rev=173063&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
Modified: llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp?rev=173063&r1=173062&r2=173063&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp Mon Jan 21 12:18:25 2013
@@ -184,17 +184,17 @@
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 @@
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 @@
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];
More information about the llvm-commits
mailing list