>From this stackoverflow 
>[page](https://stackoverflow.com/questions/39946715/llvm-how-to-execute-code-in-a-module-before-any-other-code),
> I got the answer finally. 

" *You can put the code you want to run early into a function and add that 
function to [ `llvm.global_ctors` 
](http://llvm.org/docs/LangRef.html#the-llvm-global-ctors-global-variable). 
This is the equivalent of using [ `__attribute__((constructor))` 
](https://stackoverflow.com/questions/2053029/how-exactly-does-attribute-constructor-work)
 in C or C++.*

*To do this from a pass, you can use the [ `llvm::appendToGlobalCtors` 
](http://llvm.org/docs/doxygen/html/namespacellvm.html#ae85c8b3bbab3831fdbb0a4eddebddcdf)
 function, which is declared in  `llvm/Transforms/Utils/ModuleUtils.h` .*"





---
[Visit 
Topic](https://discuss.tvm.ai/t/solved-how-is-tvm-module-startup-invoked/6891/5)
 to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.ai/email/unsubscribe/fe13374adaa71c6e19b33529b69ad3da2362d5bd7b712c65070545797535168e).

Reply via email to