[cfe-dev] Static constructors: _cxx_global_var_initN vs _GLOBAL__sub_I_XXX

Andrew Parker via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 7 02:10:10 PST 2016


Great, thanks for the info David!

On Thu, Jan 7, 2016 at 5:56 PM, David Chisnall <David.Chisnall at cl.cam.ac.uk>
wrote:

> On 7 Jan 2016, at 09:49, Andrew Parker <andrew.j.c.parker at gmail.com>
> wrote:
> >
> > - Is there any significance in the naming _GLOBAL__sub_I_ vs
> __cxx_global_var_init or is this just an artefact of the way clang
> generates the code?
>
> To the best of my knowledge, these are entirely private.  I think the
> _GLOBAL__ names are there to help debuggers spot what is going on.
>
> > - Can I assume that the order the functions appear in @llvm.global_ctors
> is always the order that they should be called in (assuming there's
> actually any dependencies)?
>
> Modulo the priority, yes, though the guarantees of the priority are very
> weak (and affected by linking.  Yay).
>
> > This is significant to me as I'm performing manipulations on the IR to
> alter the static ctrs and then recompiling (you may shudder should you wish
> to do so :) ).
>
> There’s an optimisation pass that tries to turn these things into static
> initialisers.  That’s probably a good place to start looking.
>
> David
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160107/d195f13c/attachment.html>


More information about the cfe-dev mailing list