[llvm] Unittests and usability for BitstreamWriter incremental flushing (PR #92983)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 14:19:00 PDT 2024
================
@@ -141,16 +209,16 @@ class BitstreamWriter {
if (ByteNo >= NumOfFlushedBytes) {
assert((!endian::readAtBitAlignment<uint8_t, llvm::endianness::little,
unaligned>(
- &Out[ByteNo - NumOfFlushedBytes], StartBit)) &&
+ &Buffer[ByteNo - NumOfFlushedBytes], StartBit)) &&
"Expected to be patching over 0-value placeholders");
endian::writeAtBitAlignment<uint8_t, llvm::endianness::little, unaligned>(
- &Out[ByteNo - NumOfFlushedBytes], NewByte, StartBit);
+ &Buffer[ByteNo - NumOfFlushedBytes], NewByte, StartBit);
return;
}
// If the byte offset to backpatch is flushed, use seek to backfill data.
// First, save the file position to restore later.
- uint64_t CurPos = FS->tell();
+ uint64_t CurPos = fdStream()->tell();
----------------
mtrofin wrote:
we could use FD, but we should only be here if fdStream() != nullptr. The reason that happens is not very apparent, though: `GetNumOfFlushedBytes` returns 0 in that case, which makes the if-check above always succeed. Added an assert and a comment.
https://github.com/llvm/llvm-project/pull/92983
More information about the llvm-commits
mailing list