<br>Nick,<br>Thanks for the quick answer.<br>Dereferencing the pointer does yield the same result in both cases but that's not what I want to do. I want to instrument the program dynamically and keep track of certain memory locations which is a problem if the same variable has different addresses for the static/dynamic code - as far I see this is what it's happening but I have no clue why.<br>
<br>Paul<br><br><div class="gmail_quote">On Sun, May 24, 2009 at 10:15 PM, Nick Lewycky <span dir="ltr"><<a href="mailto:nicholas@mxc.ca">nicholas@mxc.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Paul Martin wrote:<br>
> Hi,<br>
> I have the following code, the lines preceded by `>` being added at<br>
> runtime (the snipped was also printed at runtime)<br>
><br>
> define i32 @myfunc(i32 %pi) {<br>
> entry:<br>
>         %pi_addr = alloca i32           ; <i32*> [#uses=3]<br>
>         %retval = alloca i32            ; <i32*> [#uses=2]<br>
>         %tmp = alloca i32               ; <i32*> [#uses=2]<br>
>  >       %ptr32 = alloca i32             ; <i32*> [#uses=2]<br>
>         %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]<br>
><br>
>  >       store i32 %pi, i32* %ptr32<br>
>  >       %ptr8 = bitcast i32* %ptr32 to i8*              ; <i8*> [#uses=1]<br>
>  >       call void @roc( i8* %ptr8 )<br>
><br>
>         store i32 %pi, i32* %pi_addr<br>
>         %pi_addr1 = bitcast i32* %pi_addr to i8*                ; <i8*><br>
> [#uses=1]<br>
>         call void @roc( i8* %pi_addr1 )<br>
> ...<br>
><br>
> void roc(void*) is a function that only prints its argument as an integer.<br>
<br>
</div>So it's printing the pointer.<br>
<div class="im"><br>
> I was expecting for the program to print the same thing twice (the<br>
> address of the myfunc argument) because the code added at runtime looks<br>
> to me identical with the code that was compiled (3 lines each).<br>
> However, that was not the case; what I got was:<br>
><br>
> 147156320<br>
> 147117168<br>
><br>
> What am I missing?<br>
<br>
</div>Make roc() dereference the pointers it's given and print that instead.<br>
<br>
Nick<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br>