[all-commits] [llvm/llvm-project] 6dedbc: Make BinaryStreamWriter::padToAlignment write bloc...

Stella Laurenzo via All-commits all-commits at lists.llvm.org
Sat May 7 17:39:05 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6dedbcd5e96ff36ea7d38534068a2d3e4746a929
      https://github.com/llvm/llvm-project/commit/6dedbcd5e96ff36ea7d38534068a2d3e4746a929
  Author: Stella Laurenzo <stellaraccident at gmail.com>
  Date:   2022-05-07 (Sat, 07 May 2022)

  Changed paths:
    M llvm/lib/Support/BinaryStreamWriter.cpp
    M llvm/unittests/Support/BinaryStreamTest.cpp

  Log Message:
  -----------
  Make BinaryStreamWriter::padToAlignment write blocks vs bytes.

While I think this is a performance improvement over the original, this actually fixes a correctness issue: For an appendable underlying stream, padToAlignment would fail if the additional padding would have caused the stream to grow since it was doing its own check on bounds. By deferring to the regular writeArray method this takes the same path as everything else, which does the correct bounds check in WritableBinaryStreamRef::checkOffsetForWrite (i.e. skips the extension check if BSF_Append is set). I had started to fix the existing bounds check in BinaryStreamWriter but deferred to this because it layered better and is more efficient/consistent.

It didn't look like this method was tested at all, so I added a unit test.

Differential Revision: https://reviews.llvm.org/D124746




More information about the All-commits mailing list