[llvm] Unittests and usability for BitstreamWriter incremental flushing (PR #92983)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Tue May 28 07:12:43 PDT 2024
================
@@ -5055,13 +5055,13 @@ void llvm::WriteBitcodeToFile(const Module &M, raw_ostream &Out,
Triple TT(M.getTargetTriple());
if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
Buffer.insert(Buffer.begin(), BWH_HeaderSize, 0);
-
- BitcodeWriter Writer(Buffer, dyn_cast<raw_fd_stream>(&Out));
- Writer.writeModule(M, ShouldPreserveUseListOrder, Index, GenerateHash,
- ModHash);
- Writer.writeSymtab();
- Writer.writeStrtab();
-
+ {
----------------
teresajohnson wrote:
Does emitDarwinBCHeaderAndTrailer unconditionally overwrite Buffer instead of appending to it? Ah looks like that is the case. Is that the issue fixed by doing the additional flushing with this change?
If so, then probably add a comment about why Writer is in a nested scope (to trigger the destructor to complete the flushing), and probably assert that Buffer is empty after that scope completes? It probably also makes sense to move the write from 5070 under the if statement at line 5065, since that should be the only remaining case requiring writing?
https://github.com/llvm/llvm-project/pull/92983
More information about the llvm-commits
mailing list