[LLVMdev] annotations preventing optimizations/cleanup?

ret val retval386 at gmail.com
Tue Nov 1 19:08:12 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?

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
  ...



More information about the llvm-dev mailing list