diff options
author | Craig Topper <craig.topper@intel.com> | 2020-09-01 10:42:50 -0700 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2020-09-01 11:06:45 -0700 |
commit | 96ae43bad5b86aad90a9820d2e3c1a51f0af8a75 (patch) | |
tree | 6a0fcbef8de87e252ec3d9fba2539fe4413aef37 /llvm/lib/Bitstream/Reader/BitstreamReader.cpp | |
parent | 5ded4442520d3dbb1aa72e6fe03cddef8828c618 (diff) | |
download | llvm-96ae43bad5b86aad90a9820d2e3c1a51f0af8a75.zip llvm-96ae43bad5b86aad90a9820d2e3c1a51f0af8a75.tar.gz llvm-96ae43bad5b86aad90a9820d2e3c1a51f0af8a75.tar.bz2 |
[Bitstream] Use alignTo to make code more readable. NFC
I was recently debugging a similar issue to https://reviews.llvm.org/D86500 only with a large metadata section. Only after I finished debugging it did I discover it was fixed very recently.
My version of the fix was going to alignTo since that uses uint64_t and improves the readability of the code. So I though I would go ahead and share it.
Differential Revision: https://reviews.llvm.org/D86957
Diffstat (limited to 'llvm/lib/Bitstream/Reader/BitstreamReader.cpp')
-rw-r--r-- | llvm/lib/Bitstream/Reader/BitstreamReader.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Bitstream/Reader/BitstreamReader.cpp b/llvm/lib/Bitstream/Reader/BitstreamReader.cpp index 2f153f1e..1d4f045 100644 --- a/llvm/lib/Bitstream/Reader/BitstreamReader.cpp +++ b/llvm/lib/Bitstream/Reader/BitstreamReader.cpp @@ -187,8 +187,7 @@ Expected<unsigned> BitstreamCursor::skipRecord(unsigned AbbrevID) { SkipToFourByteBoundary(); // 32-bit alignment // Figure out where the end of this blob will be including tail padding. - const size_t NewEnd = - GetCurrentBitNo() + ((static_cast<uint64_t>(NumElts) + 3) & ~3) * 8; + const size_t NewEnd = GetCurrentBitNo() + alignTo(NumElts, 4) * 8; // If this would read off the end of the bitcode file, just set the // record to empty and return. @@ -316,8 +315,7 @@ Expected<unsigned> BitstreamCursor::readRecord(unsigned AbbrevID, // Figure out where the end of this blob will be including tail padding. size_t CurBitPos = GetCurrentBitNo(); - const size_t NewEnd = - CurBitPos + ((static_cast<uint64_t>(NumElts) + 3) & ~3) * 8; + const size_t NewEnd = CurBitPos + alignTo(NumElts, 4) * 8; // If this would read off the end of the bitcode file, just set the // record to empty and return. |