[LLVMdev] C++ Constructors

John Criswell criswell at uiuc.edu
Thu Dec 11 14:35:23 PST 2008


Dear All,

Are global static constructors called before main() in LLVM these days 
using some behind-the-scenes magic that is not explicit in the LLVM 
bitcode?  In older versions of LLVM, llvm-gcc added an explicit function 
call to __main() as the first instruction in main(); __main() would call 
all global static constructors.  It seems __main() is now gone.

I've got a transform that instruments all code in a program (including 
constructors) with calls to a run-time library.  I need to make sure 
that the call to the run-time library happens before main() is called or 
any static constructors are called.

-- John T.





More information about the llvm-dev mailing list