[LLVMdev] An explanation to ConstantInt

Tim Northover t.p.northover at gmail.com
Sun Jan 20 23:42:29 PST 2013


Hi Varun,

> I can actually get the value of a ConstantInt variable using getValue().
> I am getting confused with the nomenclature of Constant. Any
> explanation for why it is called Constant?

It's a Constant because the value it represents is the address of the
global variable, which isn't expected to change during execution. I'm
not sure what calling getValue on a GlobalVariable will do, but it's
probably not what you want; I'd go via the execution engine.

It's all related to the fact that after you've declared
    @var = global i32 0
you use it as
    %value = load i32* @var

Hope this helps.

Tim.



More information about the llvm-dev mailing list