[PATCH] D81525: [Support] Initialize outs() errs() nulls() once
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 9 22:34:01 PDT 2020
MaskRay added a comment.
In D81525#2083967 <https://reviews.llvm.org/D81525#2083967>, @dblaikie wrote:
> Adding global ctors is generally avoided - as they add startup cost (which might be very important to interactive programs, etc) to code linking in the LLVM libraries.
>From a friend: "The output and error streams might be essential for logging in case of other initialization errors, so such cost is not worthless."
(It is hard to imagine an application which does not call outs() or errs() if they use raw_ostream.cpp)
> As for the gotchas:
>
>> if errs() is constructed before outs()
>
> Why is that a problem? when errs() calls outs(), the static local ctor for outs() will be initialized as intended, right?
>
>> and if errs() is changed to a buffered state
>
> Not sure I understand this issue - could you describe it in more detail?
>
>> when destructing errs() (outs() has been destructed), the tied-to pointer to outs() is dangling.
>
> Yeah, that's potentially a problem - a wrapper that avoids running the dtor on these types (but does flush them, perhaps?) might be useful in that regard.
The three conditions are conjunctions:/ When all three are satisfied, "the tied-to pointer to outs() is dangling" will be the result.
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