[LLVMdev] global constant integer and pointer

Eli Friedman eli.friedman at gmail.com
Fri Oct 10 08:54:44 PDT 2008


On Fri, Oct 10, 2008 at 7:00 AM, Le Anh Quang <anhquangbk at googlemail.com> wrote:
>  Hi all,
>
>  I have tried to use llvm to translate some programs. Today I saw a weird
> thing:
>
> - My program has a global pointer @ptr1 = 0. And the constant integer '0' is
> stored in value memory at index 64.
>
> "@ptr = weak global i32 0; <i32*>"
>
> - Somewhere in my program, there is a store instruction:
>
> "store i32 %tmp31, i32* @ptr"
>
> it writes %tmp32 into memory, where @ptr pointed to (here: index 64 of value
> memory).
>
> - Afterward, another instruction needs to load the integer value '0' from
> value memory :
>
> "%tmp17 = mul i32 %mb_col, 0"
>
> It will try to read the value memory at index 64, but it is no more '0' but
> now %tmp31. So, the result is not correct !
>
> I do not understand, how llvm handled this case. Anybody known it ?

What pass is doing this?  Can you provide a testcase?

-Eli



More information about the llvm-dev mailing list