diff options
author | Chris Lattner <sabre@nondot.org> | 2013-01-21 18:18:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2013-01-21 18:18:25 +0000 |
commit | 9221b8fdac14c628c5f084bbf7bca352ee6bf3a2 (patch) | |
tree | 408aba1439439617846537ceb8b4f1db22d9b499 /llvm/lib/Bitcode/Reader/BitstreamReader.cpp | |
parent | e1817aae5f2612f45cda1983ce515a0f2fdea7c1 (diff) | |
download | llvm-9221b8fdac14c628c5f084bbf7bca352ee6bf3a2.zip llvm-9221b8fdac14c628c5f084bbf7bca352ee6bf3a2.tar.gz llvm-9221b8fdac14c628c5f084bbf7bca352ee6bf3a2.tar.bz2 |
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.
llvm-svn: 173063
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitstreamReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitstreamReader.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp index eb8b5de..92133bb9 100644 --- a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp +++ b/llvm/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]; |