Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
      2 // END.
      3 
      4 static long long llfoo;
      5 static int intfoo;
      6 static short shortfoo;
      7 static char charfoo;
      8 
      9 // CHECK: private unnamed_addr constant [13 x i8] {{.*}}annotation_a{{.*}} section "llvm.metadata"
     10 // CHECK-NOT: {{.*}}annotation_a{{.*}}
     11 
     12 static int foo(int a) {
     13     return a + 1;
     14 }
     15 
     16 int main(int argc, char **argv) {
     17     char barray[16];
     18     char *b = (char *) __builtin_annotation((int)barray, "annotation_a");
     19 // CHECK: ptrtoint i8* {{.*}} to i32
     20 // CHECK-NEXT: call i32 @llvm.annotation.i32
     21 // CHECK: inttoptr {{.*}} to i8*
     22 
     23     int call = __builtin_annotation(foo(argc), "annotation_a");
     24 // CHECK: call {{.*}} @foo
     25 // CHECK: call i32 @llvm.annotation.i32
     26 
     27     long long lla = __builtin_annotation(llfoo, "annotation_a");
     28 // CHECK: call i64 @llvm.annotation.i64
     29 
     30     int inta = __builtin_annotation(intfoo, "annotation_a");
     31 // CHECK: load i32* @intfoo
     32 // CHECK-NEXT: call i32 @llvm.annotation.i32
     33 // CHECK-NEXT: store
     34 
     35     short shorta =  __builtin_annotation(shortfoo, "annotation_a");
     36 // CHECK: call i16 @llvm.annotation.i16
     37 
     38     char chara = __builtin_annotation(charfoo, "annotation_a");
     39 // CHECK: call i8 @llvm.annotation.i8
     40 
     41     char **arg = (char**) __builtin_annotation((int) argv, "annotation_a");
     42 // CHECK: ptrtoint i8** {{.*}} to
     43 // CHECK: call i32 @llvm.annotation.i32
     44 // CHECK: inttoptr {{.*}} to i8**
     45     return 0;
     46 }
     47