[llvm-dev] Global Variable Initialization via Internal Function

Aaron via llvm-dev llvm-dev at lists.llvm.org
Sun May 6 21:43:10 PDT 2018


Hello,

I'm trying to figure out how to initialize global variables via LLVM IR and
I found that clang creates a internal function to initialize global
variables if initialization values are not constants.

*Do we really need to create an internal function for complex global
variable initializations during variable declaration? Can't we create
instructions in global scope?*

Example Simple C++ code:

int func()
{
    return 5*2;
}

init globalVar = func();

int main(...)
...

Thanks for helping!

Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180506/731b5be2/attachment.html>


More information about the llvm-dev mailing list