[cfe-dev] BitstreamReader::GetCurrentBitNo() counterintuitive
Chris Lattner
clattner at apple.com
Tue Dec 23 11:39:19 PST 2008
On Dec 23, 2008, at 12:36 AM, Zhongxing Xu wrote:
> As the comments said, BitstreamReader::GetCurrentBitNo() should
> return the bit # of the bit we are reading. But the current
> implementation actually return 4 more bytes than the bit we are
> reading. It calculate the bit number by
>
> (NextChar-FirstChar)*8 + ((32-BitsInCurWord) & 31);
>
> But 'NextChar' is already after the word that we are reading. I
> propose to fix this by the following patch.
Hi Zhongxing,
This is ok as long as it doesn't cause any regressions in the *llvm*
dejagnu regression tests, thanks!
-Chris
>
>
> Index: include/llvm/Bitcode/BitstreamReader.h
> ===================================================================
> --- include/llvm/Bitcode/BitstreamReader.h (版本 61317)
> +++ include/llvm/Bitcode/BitstreamReader.h (工作副本)
> @@ -114,7 +114,8 @@
>
> /// GetCurrentBitNo - Return the bit # of the bit we are reading.
> uint64_t GetCurrentBitNo() const {
> - return (NextChar-FirstChar)*8 + ((32-BitsInCurWord) & 31);
> + return (NextChar-FirstChar-4)*8 + (BitsInCurWord ? (32-
> BitsInCurWord) & 31
> + : 32);
> }
>
> /// JumpToBit - Reset the stream to the specified bit number.
> @@ -130,7 +131,6 @@
>
> // Skip over any bits that are already consumed.
> if (WordBitNo) {
> - NextChar -= 4;
> Read(static_cast<unsigned>(WordBitNo));
> }
> }
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list