[cfe-dev] Static constructors: _cxx_global_var_initN vs _GLOBAL__sub_I_XXX
David Chisnall via cfe-dev
cfe-dev at lists.llvm.org
Thu Jan 7 01:56:00 PST 2016
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
More information about the cfe-dev
mailing list