[LLVMdev] how to get and modify a global variable inside a module
erocha.ssa at gmail.com
Wed Dec 5 03:56:50 PST 2012
Hi Dong Chen,
You can write a ModulePass class and implement a runOnModule method.
Inside this method you can access Module::global_iterator and get a
reference to all global variables of a module. With this reference,
you can change this variable. But be careful, you may need to change
also the references to those variables. Have a look to the method
GlobalVariable::use_begin and use_end. They give you references to the
users of the global variable.
I hope this helps,
On Wed, Dec 5, 2012 at 9:07 AM, Dong Chen <jameschennerd at gmail.com> wrote:
> recently, i use LLVM API to write a program to read *.ll and excute it
> Further more, i want to change some global variables inside a module.
> i tried some functions provided by Module.h and ExecutionEngine.h but none
> were seemed to match my need.
> did someone have the experience or some advices?
> thank you ;)
> View this message in context: http://llvm.1065342.n5.nabble.com/how-to-get-and-modify-a-global-variable-inside-a-module-tp52289.html
> Sent from the LLVM - Dev mailing list archive at Nabble.com.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev