[PATCH] D81525: [Support] Initialize outs() errs() nulls() once
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 9 20:57:23 PDT 2020
dblaikie added a comment.
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.
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.
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