[llvm-dev] How to get the address of a global variable in LLVM? (original) (raw)

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 28 14:34:46 PDT 2017


On 28 April 2017 at 14:32, Jonathan Roelofs via llvm-dev <llvm-dev at lists.llvm.org> wrote:

You need a load instruction since your function takes an i32, not an i32*.... A global's value in llvm is its address, not the numeric data it contains.

I suspect he actually wants to make his function take an "i8*" and bitcast his pointer to that type before calling it. [*]

Tim.

[*] Keeping it as an i32/i64 and using ptrtoint instead of bitcast would also work, but be less portable and elegant.



More information about the llvm-dev mailing list