[PATCH] D80803: [llvm-dwarfdump] Flush output before warning and errors are reported

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 2 07:41:42 PDT 2020


jhenderson added a comment.

I've tried getting the `tied_raw_fd_ostream` approach to work, by tying `errs()` to `outs()` as suggested, but it doesn't work when it comes to testing D80989 <https://reviews.llvm.org/D80989> (and possibly others) in lit. The problem is that llvm-dwarfdump uses a `ToolOutputFile`, which contains its own `raw_fd_ostream` pointing to stdout, with its own buffer independent of the version that is provided by `outs()`. Consequently, the flush triggered by writing to `errs()` flushes the empty `outs()` buffer, before writing the error message, rather than the real output buffer provided by the `ToolOutputFile`. I see three possible ways forward: 1) Go ahead with my existing approach as suggested in the current patch (my preference), 2) abandon the whole idea of keeping the two in sync (I don't like this idea for reasons already outlined), or 3) have `raw_fd_ostream` instances contructed with `-` (the stdout variant) actually use the `outs()` stream, rather than its own one - this will prevent potential weird situations where we have two independent streams with their own buffers both writing to stdout, and therefore potentially getting very weird interleaving, but I'm not sure of the knock-on effects of this yet.

Thoughts?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80803/new/

https://reviews.llvm.org/D80803





More information about the llvm-commits mailing list