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 ...
Duncan Sands
2011-Nov-02 08:47 UTC
[LLVMdev] annotations preventing optimizations/cleanup?
> 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
I'm more curious about the stuff before the annotations. In the code I got from modifying the AST it doesn't look like the function is getting params like normal, and its not even annotated. int somefunc(int (*ptr)(int)) { if(ptr == NULL) return 1; global = ptr; return 0; } becomes %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* Thanks On Wed, Nov 2, 2011 at 4:47 AM, Duncan Sands <baldrick at free.fr> wrote:>> 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 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Apparently Analagous Threads
- [LLVMdev] annotations preventing optimizations/cleanup?
- Translation of custom attribute (defined for variables) from clang to llvm
- Translation of custom attribute (defined for variables) from clang to llvm
- [LLVMdev] LLVM use chains
- Translation of custom attribute (defined for variables) from clang to llvm