[llvm-dev] Accessing global variable values from IRBuilder

Jacob Ajit via llvm-dev llvm-dev at lists.llvm.org
Thu Jul 5 11:05:12 PDT 2018


I'm trying to do something with a global variable value with IRBuilder in
LLVM pass. I refer to a specific global variable contained in a source
file.

  GlobalVariable *VarTest =
    new GlobalVariable(M, PointerType::get(Int32Ty, 0), false,
                       GlobalValue::ExternalLinkage, 0, "vartest");

Then, I pass that variable to a runtime function with CreateCall.

However, I can't seem to access any variables from the source code. I get
"undefined reference to 'vartest.5'" when attempting the pass. Why is it
adding a '.5' to my variable name?

How do I access a global variable from the target source?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180705/a189580a/attachment.html>


More information about the llvm-dev mailing list