[LLVMdev] mixing static/dynamic code

Paul Martin srucnoc at gmail.com
Sun May 24 13:06:37 PDT 2009


Hi,
I have the following code, the lines preceded by `>` being added at runtime
(the snipped was also printed at runtime)

define i32 @myfunc(i32 %pi) {
entry:
        %pi_addr = alloca i32           ; <i32*> [#uses=3]
        %retval = alloca i32            ; <i32*> [#uses=2]
        %tmp = alloca i32               ; <i32*> [#uses=2]
>       %ptr32 = alloca i32             ; <i32*> [#uses=2]
        %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]

>       store i32 %pi, i32* %ptr32
>       %ptr8 = bitcast i32* %ptr32 to i8*              ; <i8*> [#uses=1]
>       call void @roc( i8* %ptr8 )

        store i32 %pi, i32* %pi_addr
        %pi_addr1 = bitcast i32* %pi_addr to i8*                ; <i8*>
[#uses=1]
        call void @roc( i8* %pi_addr1 )
...

void roc(void*) is a function that only prints its argument as an integer.

I was expecting for the program to print the same thing twice (the address
of the myfunc argument) because the code added at runtime looks to me
identical with the code that was compiled (3 lines each).
However, that was not the case; what I got was:

147156320
147117168

What am I missing?
Thanks,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090524/b49247c5/attachment.html>


More information about the llvm-dev mailing list