[llvm-dev] Enabling statistics in release builds / static constructors

Reid Kleckner via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 13 12:56:38 PST 2016


Given that LLVM has so many auto-registration systems (cl::opt, target
registry, pass registry, statistics, I'm sure there's more), maybe we
should spend the time to build an auto-registration system that doesn't
involve static constructors?

It needs custom code for every supported object file format, and is hard to
get right when DSOs are involved, but in the long run it's probably worth
fixing this problem once and for all.

On Tue, Dec 13, 2016 at 11:53 AM, Matthias Braun via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Analyzing a compilers behavior and timings is an important tool to track
> code size and compile time regressions. One of the tools we would like to
> use are Statistic variable (llvm/include/ADT/Statistic.h). However today
> I cannot enable them in release builds without a performance hits because
> the lazy initialisation present forces a memory fence on every single
> increment of the statistic variable. This is trivial to fix: Do the
> initialization in the constructor. See https://reviews.llvm.org/D27724
>
> I am writing this mail because I expect opposition against introducing
> static constructors. Looking at previous discussions it is obvious that a
> lot of static constructor usage is bad as it promotes global state that
> should better be put into LLVMContext.
> However lazily initializing the Statistic variables makes them in no way
> less static, we just somewhat delay the initialization at the price of a
> heavy performance penalty on usage. I don't see a better alternative at the
> moment.
>
> - Matthias
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161213/395699a8/attachment.html>


More information about the llvm-dev mailing list