[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / annotations-builtin.c
blob2f6e9106c7a7c7d6868d61111a8c60a18bb1d327
1 // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
2 // END.
4 static long long llfoo;
5 static int intfoo;
6 static short shortfoo;
7 static char charfoo;
9 // CHECK: private unnamed_addr constant [13 x i8] {{.*}}annotation_a{{.*}} section "llvm.metadata"
10 // CHECK-NOT: {{.*}}annotation_a{{.*}}
12 static int foo(int a) {
13 return a + 1;
16 int main(int argc, char **argv) {
17 char barray[16];
18 char *b = (char *) __builtin_annotation((int)barray, "annotation_a");
19 // CHECK: ptrtoint ptr {{.*}} to i32
20 // CHECK-NEXT: call i32 @llvm.annotation.i32
21 // CHECK: inttoptr {{.*}} to ptr
23 int call = __builtin_annotation(foo(argc), "annotation_a");
24 // CHECK: call {{.*}} @foo
25 // CHECK: call i32 @llvm.annotation.i32
27 long long lla = __builtin_annotation(llfoo, "annotation_a");
28 // CHECK: call i64 @llvm.annotation.i64
30 int inta = __builtin_annotation(intfoo, "annotation_a");
31 // CHECK: load i32, ptr @intfoo
32 // CHECK-NEXT: call i32 @llvm.annotation.i32
33 // CHECK-NEXT: store
35 short shorta = __builtin_annotation(shortfoo, "annotation_a");
36 // CHECK: call i16 @llvm.annotation.i16
38 char chara = __builtin_annotation(charfoo, "annotation_a");
39 // CHECK: call i8 @llvm.annotation.i8
41 char **arg = (char**) __builtin_annotation((int) argv, "annotation_a");
42 // CHECK: ptrtoint ptr {{.*}} to
43 // CHECK: call i32 @llvm.annotation.i32
44 // CHECK: inttoptr {{.*}} to ptr
45 return 0;
47 int after_return = __builtin_annotation(argc, "annotation_a");
48 // CHECK-NOT: call i32 @llvm.annotation.i32