[LLVMdev] llvm address of

Török Edwin edwintorok at gmail.com
Sun May 24 09:48:51 PDT 2009

On 2009-05-24 19:42, Paul Martin wrote:
> I'm trying to generate the equivalent of this function dynamically in
> llvm (a la http://llvm.org/docs/tutorial/JITTutorial1.html) but after
> half a day of searching I still haven't found how to create the
> equivalent of the & (address of) operator in the llvm API, more
> exactly how do I obtain the i8* from the i32 below
> void fn(int x) 
> { 
>    another_fn(&x); 
> } 

You should create a temporary variable on the stack, store the value of
'x' to it,
and use the address of that variable as argument to another_fn.

You can simply run your example on llvm-gcc/clang with -emit-llvm -S,
and you'll see how it can be done.

Best regards,

More information about the llvm-dev mailing list