[llvm-dev] llvm.annotation arguments

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] llvm.annotation arguments

韩玉 via llvm-dev
Hello all,

According to clang/lib/CodeGen/CodeGenFunction.cpp, a LLVM annotation intrinsic call has 4 arguments:

- llvm::Value *AnnotatedVal,        
- Builder.CreateBitCast(CGM.EmitAnnotationString(AnnotationStr), Int8PtrTy),
- Builder.CreateBitCast(CGM.EmitAnnotationUnit(Location), Int8PtrTy),
- CGM.EmitAnnotationLineNo(Location)

However, this is what an annotation intrinsic char __attribute__((annotate("DIFF"))) diff looks like in the IR:

@.str = private unnamed_addr constant [5 x i8] c"DIFF\00", section "llvm.metadata"
@.str.1 = private unnamed_addr constant [6 x i8] c"pin.c\00", section "llvm.metadata"

call void @llvm.var.annotation(i8* %diff,
                                                       i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0),
                                                       i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0),
                                                       i32 38)

So my question is, why don't we find any BitCast here, but a GEP?

Thanks for your help,

Son Tuan Vu

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] llvm.annotation arguments

韩玉 via llvm-dev
Pointer casts are considered less canonical. The GEP is the same as writing &array[0] in C to convert from a pointer to an array to a pointer to an array element, without relying on pointer decay.

On Wed, May 30, 2018 at 9:37 AM Son Tuan VU via llvm-dev <[hidden email]> wrote:
Hello all,

According to clang/lib/CodeGen/CodeGenFunction.cpp, a LLVM annotation intrinsic call has 4 arguments:

- llvm::Value *AnnotatedVal,        
- Builder.CreateBitCast(CGM.EmitAnnotationString(AnnotationStr), Int8PtrTy),
- Builder.CreateBitCast(CGM.EmitAnnotationUnit(Location), Int8PtrTy),
- CGM.EmitAnnotationLineNo(Location)

However, this is what an annotation intrinsic char __attribute__((annotate("DIFF"))) diff looks like in the IR:

@.str = private unnamed_addr constant [5 x i8] c"DIFF\00", section "llvm.metadata"
@.str.1 = private unnamed_addr constant [6 x i8] c"pin.c\00", section "llvm.metadata"

call void @llvm.var.annotation(i8* %diff,
                                                       i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0),
                                                       i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0),
                                                       i32 38)

So my question is, why don't we find any BitCast here, but a GEP?

Thanks for your help,

Son Tuan Vu
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev