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: trunc i64 {{.*}} to i32 29 // CHECK-NEXT: call i32 @llvm.annotation.i32 30 // CHECK-NEXT: zext i32 {{.*}} to i64 31 32 int inta = __builtin_annotation(intfoo, "annotation_a"); 33 // CHECK: load i32* @intfoo 34 // CHECK-NEXT: call i32 @llvm.annotation.i32 35 // CHECK-NEXT: store 36 37 short shorta = __builtin_annotation(shortfoo, "annotation_a"); 38 // CHECK: sext i16 {{.*}} to i32 39 // CHECK-NEXT: call i32 @llvm.annotation.i32 40 // CHECK-NEXT: trunc i32 {{.*}} to i16 41 42 char chara = __builtin_annotation(charfoo, "annotation_a"); 43 // CHECK: sext i8 {{.*}} to i32 44 // CHECK-NEXT: call i32 @llvm.annotation.i32 45 // CHECK-NEXT: trunc i32 {{.*}} to i8 46 // 47 char **arg = (char**) __builtin_annotation((int) argv, "annotation_a"); 48 // CHECK: ptrtoint i8** {{.*}} to 49 // CHECK: call i32 @llvm.annotation.i32 50 // CHECK: inttoptr {{.*}} to i8** 51 return 0; 52 } 53