[llvm-dev] Accessing global variable values from IRBuilder

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Accessing global variable values from IRBuilder

Bruce Hoult via llvm-dev
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?


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Accessing global variable values from IRBuilder

Bruce Hoult via llvm-dev

It seems like you are creating a new global variable, you may need to look into Module->getGlobalVariable(..) function.

 

- Ashutosh

 

From: llvm-dev [mailto:[hidden email]] On Behalf Of Jacob Ajit via llvm-dev
Sent: Thursday, July 5, 2018 11:35 PM
To: [hidden email]
Subject: [llvm-dev] Accessing global variable values from IRBuilder

 

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?

 


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev