[LLVMdev] Get the value of a GlobalVariable

Varun Agrawal varun729 at gmail.com
Sun Jan 20 11:52:04 PST 2013


Hi,

I am executing a C program using JIT. When the program exits, the control
comes back to my program which initiates the JIT. Now, I want to read
the value(not the LLVM nomenclature) of a global variable (not the LLVM
nomenclature). I am able to get the global variable, using the following
command:
GlobalVariable *my_global = Mod->getNamedGlobal("MY_GLOBAL");

I want to know the value which was stored in this variable, I use the
following command, but it gives error:
APInt value = my_global->getValue();

Error is:
llvm/lib/IR/Constants.cpp:1257: llvm::Constant
*llvm::Constant::getSplatValue() const: Assertion
`this->getType()->isVectorTy() && "Only valid for vectors!"' failed.


I am new to LLVM, so a lot of nomenclature is still not very familiar to me
and I am trying to understand it as I go forward.

Thanks,
Varun Agrawal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130120/661f0c22/attachment.html>


More information about the llvm-dev mailing list