[PATCH] D81525: [Support] Ensure errs() is constructed after outs() and don't rerun tie when errs() is called

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 13:14:07 PDT 2020


dblaikie added a comment.

In D81525#2086997 <https://reviews.llvm.org/D81525#2086997>, @labath wrote:

> In D81525#2085642 <https://reviews.llvm.org/D81525#2085642>, @dblaikie wrote:
>
> > In D81525#2084521 <https://reviews.llvm.org/D81525#2084521>, @labath wrote:
> >
> > > i) `std` streams are thread-safe by default -- one has to call `sync_with_stdio(false)` explicitly, and I don't think many people do. `outs()` is not thread safe by default.
> >
> >
> > When you say "not thread safe" you mean specifically for using outs from more than one thread at the same time, yes?
>
>
> Affirmative.
>
> >> I think it would be nice to have them be tied by default, though it's true that there is a fair amount of potential for breaking existing use cases
> > 
> > If they can still at least provide "The usual thread safety guarantees" (writing to (apparently) independent objects (errs() and outs()) does not race) then I'm not significantly opposed. If this breaks that guarantee - I don't think that's a sufficiently worthwhile tradeoff.
>
> Unfortunately, I don't think there's a good way to provide those guarantees -- this amounts to ensuring that `flush()` does not race with any other stream output operation (including itself). That is probably impossible without locking, which will likely have significant implications on the stream performance.
>
> When you say "worthwhile tradeoff", what do you mean exactly? `errs()` and `outs()` being tied by default, or the entire tieing concept in general?


Sorry, yeah - I mean tie-by-default. Essentially: Seems like this is isn't a good idea if it means that outs and errs become racy by default. I think that makes this an opt-in situation, where the app has to make the choice/provide the guarantee that it won't be writing to outs and errs from different threads.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81525





More information about the llvm-commits mailing list