[LLVMdev] inttoptr weirdness

Eli Friedman eli.friedman at gmail.com
Mon Dec 14 13:57:12 PST 2009


On Mon, Dec 14, 2009 at 12:27 PM, Scott Shumaker <sshumaker at gmail.com> wrote:
> define void @"compile-test::__toplevel-main"() {
> entry:
>        store i8* null, i8** @"compile-test::*testObj*"
>        %1 = load i8** @"compile-test::*testObj*"               ; <i8*> [#uses=1]

Here, %1 is guaranteed to be null.

>        %2 = ptrtoint i8* %1 to i32             ; <i32> [#uses=1]
>        %3 = add i32 %2, 8              ; <i32> [#uses=1]
>        %4 = inttoptr i32 %3 to i8*             ; <i8*> [#uses=1]
>        %5 = load i8* %4                ; <i8> [#uses=1]

So therefore, this load loads from null+8.

-Eli




More information about the llvm-dev mailing list