[LLVMdev] annotations preventing optimizations/cleanup?

Duncan Sands baldrick at free.fr
Wed Nov 2 01:47:46 PDT 2011


> I created a plugin to add simple Annotations to VarDecls and
> FieldDecls, and write this modified AST out to a file. I notice that
> when I use clang to compile this file I get different code then when I
> use the source directly. In both cases I'm compiling with -O4. Can
> anyone explain this?

This is how clang implements annotations on local variables, that's all.

Ciao, Duncan.

>
> Thanks
>
> define i32 @somefunc(i32 (i32)* %ptr) nounwind uwtable {
> entry:
>    %ptr.addr = alloca i32 (i32)*, align 8
>    store i32 (i32)* %ptr, i32 (i32)** %ptr.addr, align 8, !tbaa !0
>    %ptr.addr1 = bitcast i32 (i32)** %ptr.addr to i8*
>    call void @llvm.var.annotation(i8* %ptr.addr1, i8* getelementptr
> inbounds ([11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds
> ([51 x i8]* @.str1, i64 0, i64 0), i32 13)
>    %0 = load i32 (i32)** %ptr.addr, align 8, !tbaa !0
>    %cmp = icmp eq i32 (i32)* %0, null
>    ...
>
> VS
>
> define i32 @somefunc(i32 (i32)* %ptr) nounwind uwtable ssp {
> entry:
>    %cmp = icmp eq i32 (i32)* %ptr, null
>    ...
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list