[LLVMdev] print the memory address computed by getelementptr

Eli Friedman eli.friedman at gmail.com
Wed Jul 20 08:08:57 PDT 2011


On Wed, Jul 20, 2011 at 8:02 AM, Jimborean Alexandra
<xinfinity_a at yahoo.com> wrote:
> Hi,
>
> I want to print the memory locations computed by getelementptr. As I
> understood, getelementptr does not access the memory, but it contains the
> address it computes. I want to print these addresses at runtime (or process
> them).  So, I try to build a function that takes as argument a pointer and
> prints its value. And to call this function, by sending the gep instruction
> as a parameter.
>
> Surely, I obtain an error for a type mismatch. Can I declare the function as
> taking an int64 as parameter and then (somehow) sending the value computed
> by getelementptr?
>
> declare void @myFunction ( i64 )
>
>
> %tmp22 = getelementptr inbounds %struct.linked* %tmp21, i32 0, i32 1
>
> %tmp = convert_tmp22_to_i64_to_get_the_value_of_the_pointer

This instruction is called ptrtoint. :)

-Eli




More information about the llvm-dev mailing list