From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/CodeGen/annotations-var.c | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 clang/test/CodeGen/annotations-var.c (limited to 'clang/test/CodeGen/annotations-var.c') diff --git a/clang/test/CodeGen/annotations-var.c b/clang/test/CodeGen/annotations-var.c new file mode 100644 index 0000000..b8ada9f --- /dev/null +++ b/clang/test/CodeGen/annotations-var.c @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t1 %s +// RUN: FileCheck --check-prefix=LOCAL %s < %t1 +// RUN: FileCheck --check-prefix=UNDEF %s < %t1 +// RUN: FileCheck --check-prefix=PARAM %s < %t1 +// END. + +// LOCAL: private unnamed_addr constant [15 x i8] c"localvar_ann_{{.}}\00", section "llvm.metadata" +// LOCAL: private unnamed_addr constant [15 x i8] c"localvar_ann_{{.}}\00", section "llvm.metadata" + +// UNDEF: private unnamed_addr constant [15 x i8] c"undefvar_ann_0\00", section "llvm.metadata" + +// PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" +// PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" +// PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" +// PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" + +int foo(int v __attribute__((annotate("param_ann_2"))) __attribute__((annotate("param_ann_3")))); +int foo(int v __attribute__((annotate("param_ann_0"))) __attribute__((annotate("param_ann_1")))) { + return v + 1; +// PARAM: define {{.*}}@foo +// PARAM: [[V:%.*]] = alloca i32 +// PARAM: bitcast i32* [[V]] to i8* +// PARAM-NEXT: call void @llvm.var.annotation( +// PARAM-NEXT: bitcast i32* [[V]] to i8* +// PARAM-NEXT: call void @llvm.var.annotation( +// PARAM-NEXT: bitcast i32* [[V]] to i8* +// PARAM-NEXT: call void @llvm.var.annotation( +// PARAM-NEXT: bitcast i32* [[V]] to i8* +// PARAM-NEXT: call void @llvm.var.annotation( +} + +void local(void) { + int localvar __attribute__((annotate("localvar_ann_0"))) __attribute__((annotate("localvar_ann_1"))) = 3; +// LOCAL: define void @local() +// LOCAL: [[LOCALVAR:%.*]] = alloca i32, +// LOCAL-NEXT: [[T0:%.*]] = bitcast i32* [[LOCALVAR]] to i8* +// LOCAL-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 33) +// LOCAL-NEXT: [[T0:%.*]] = bitcast i32* [[LOCALVAR]] to i8* +// LOCAL-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 33) +} + +void undef(void) { + int undefvar __attribute__((annotate("undefvar_ann_0"))); +// UNDEF: define void @undef() +// UNDEF: [[UNDEFVAR:%.*]] = alloca i32, +// UNDEF-NEXT: [[T0:%.*]] = bitcast i32* [[UNDEFVAR]] to i8* +// UNDEF-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 43) +} -- cgit v1.2.3