| 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t1 %s |
| 2 | // RUN: FileCheck --check-prefix=LOCAL %s < %t1 |
| 3 | // RUN: FileCheck --check-prefix=UNDEF %s < %t1 |
| 4 | // RUN: FileCheck --check-prefix=PARAM %s < %t1 |
| 5 | // END. |
| 6 | |
| 7 | // LOCAL: private unnamed_addr constant [15 x i8] c"localvar_ann_{{.}}\00", section "llvm.metadata" |
| 8 | // LOCAL: private unnamed_addr constant [15 x i8] c"localvar_ann_{{.}}\00", section "llvm.metadata" |
| 9 | |
| 10 | // UNDEF: private unnamed_addr constant [15 x i8] c"undefvar_ann_0\00", section "llvm.metadata" |
| 11 | |
| 12 | // PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" |
| 13 | // PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" |
| 14 | // PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" |
| 15 | // PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" |
| 16 | |
| 17 | int foo(int v __attribute__((annotate("param_ann_2"))) __attribute__((annotate("param_ann_3")))); |
| 18 | int foo(int v __attribute__((annotate("param_ann_0"))) __attribute__((annotate("param_ann_1")))) { |
| 19 | return v + 1; |
| 20 | // PARAM: define {{.*}}@foo |
| 21 | // PARAM: [[V:%.*]] = alloca i32 |
| 22 | // PARAM: bitcast i32* [[V]] to i8* |
| 23 | // PARAM-NEXT: call void @llvm.var.annotation( |
| 24 | // PARAM-NEXT: bitcast i32* [[V]] to i8* |
| 25 | // PARAM-NEXT: call void @llvm.var.annotation( |
| 26 | // PARAM-NEXT: bitcast i32* [[V]] to i8* |
| 27 | // PARAM-NEXT: call void @llvm.var.annotation( |
| 28 | // PARAM-NEXT: bitcast i32* [[V]] to i8* |
| 29 | // PARAM-NEXT: call void @llvm.var.annotation( |
| 30 | } |
| 31 | |
| 32 | void local(void) { |
| 33 | int localvar __attribute__((annotate("localvar_ann_0"))) __attribute__((annotate("localvar_ann_1"))) = 3; |
| 34 | // LOCAL-LABEL: define void @local() |
| 35 | // LOCAL: [[LOCALVAR:%.*]] = alloca i32, |
| 36 | // LOCAL-NEXT: [[T0:%.*]] = bitcast i32* [[LOCALVAR]] to i8* |
| 37 | // LOCAL-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 33) |
| 38 | // LOCAL-NEXT: [[T0:%.*]] = bitcast i32* [[LOCALVAR]] to i8* |
| 39 | // LOCAL-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 33) |
| 40 | } |
| 41 | |
| 42 | void local_after_return(void) { |
| 43 | return; |
| 44 | int localvar __attribute__((annotate("localvar_after_return"))) = 3; |
| 45 | // Test we are not emitting instructions like bitcast or call outside of a basic block. |
| 46 | // LOCAL-LABEL: define void @local_after_return() |
| 47 | // LOCAL: [[LOCALVAR:%.*]] = alloca i32, |
| 48 | // LOCAL-NEXT: ret void |
| 49 | } |
| 50 | |
| 51 | void undef(void) { |
| 52 | int undefvar __attribute__((annotate("undefvar_ann_0"))); |
| 53 | // UNDEF-LABEL: define void @undef() |
| 54 | // UNDEF: [[UNDEFVAR:%.*]] = alloca i32, |
| 55 | // UNDEF-NEXT: [[T0:%.*]] = bitcast i32* [[UNDEFVAR]] to i8* |
| 56 | // UNDEF-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 52) |
| 57 | } |
| 58 | |