summaryrefslogtreecommitdiff
path: root/test/CodeGen/lifetime2.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGen/lifetime2.c')
-rw-r--r--test/CodeGen/lifetime2.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/test/CodeGen/lifetime2.c b/test/CodeGen/lifetime2.c
index 4374b3c279c70..fcdcff36017e8 100644
--- a/test/CodeGen/lifetime2.c
+++ b/test/CodeGen/lifetime2.c
@@ -1,7 +1,7 @@
-// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2
-// RUN: %clang -S -emit-llvm -o - -O2 -Xclang -disable-lifetime-markers %s \
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-llvm-passes %s | FileCheck %s -check-prefixes=CHECK,O2
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-lifetime-markers %s \
// RUN: | FileCheck %s -check-prefixes=CHECK,O0
-// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
+// RUN: %clang_cc1 -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
extern int bar(char *A, int n);
@@ -21,24 +21,22 @@ int foo (int n) {
// CHECK-LABEL: @no_goto_bypass
void no_goto_bypass() {
- // O2: @llvm.lifetime.start(i64 1
+ // O2: @llvm.lifetime.start.p0i8(i64 1
char x;
l1:
bar(&x, 1);
- // O2: @llvm.lifetime.start(i64 5
- // O2: @llvm.lifetime.end(i64 5
char y[5];
bar(y, 5);
goto l1;
// Infinite loop
- // O2-NOT: @llvm.lifetime.end(i64 1
+ // O2-NOT: @llvm.lifetime.end.p0i8(
}
// CHECK-LABEL: @goto_bypass
void goto_bypass() {
{
- // O2-NOT: @llvm.lifetime.start(i64 1
- // O2-NOT: @llvm.lifetime.end(i64 1
+ // O2-NOT: @llvm.lifetime.start.p0i8(i64 1
+ // O2-NOT: @llvm.lifetime.end.p0i8(i64 1
char x;
l1:
bar(&x, 1);
@@ -50,16 +48,16 @@ void goto_bypass() {
void no_switch_bypass(int n) {
switch (n) {
case 1: {
- // O2: @llvm.lifetime.start(i64 1
- // O2: @llvm.lifetime.end(i64 1
+ // O2: @llvm.lifetime.start.p0i8(i64 1
+ // O2: @llvm.lifetime.end.p0i8(i64 1
char x;
bar(&x, 1);
break;
}
case 2:
n = n;
- // O2: @llvm.lifetime.start(i64 5
- // O2: @llvm.lifetime.end(i64 5
+ // O2: @llvm.lifetime.start.p0i8(i64 5
+ // O2: @llvm.lifetime.end.p0i8(i64 5
char y[5];
bar(y, 5);
break;
@@ -71,8 +69,8 @@ void switch_bypass(int n) {
switch (n) {
case 1:
n = n;
- // O2-NOT: @llvm.lifetime.start(i64 1
- // O2-NOT: @llvm.lifetime.end(i64 1
+ // O2-NOT: @llvm.lifetime.start.p0i8(i64 1
+ // O2-NOT: @llvm.lifetime.end.p0i8(i64 1
char x;
bar(&x, 1);
break;
@@ -91,3 +89,27 @@ void indirect_jump(int n) {
L:
bar(&x, 1);
}
+
+// O2-LABEL: @jump_backward_over_declaration(
+// O2: %[[p:.*]] = alloca i32*
+// O2: %[[v0:.*]] = bitcast i32** %[[p]] to i8*
+// O2: call void @llvm.lifetime.start.p0i8(i64 {{.*}}, i8* %[[v0]])
+// O2-NOT: call void @llvm.lifetime.start.p0i8(
+
+extern void foo2(int p);
+
+int jump_backward_over_declaration(int a) {
+ int *p = 0;
+label1:
+ if (p) {
+ foo2(*p);
+ return 0;
+ }
+
+ int i = 999;
+ if (a != 2) {
+ p = &i;
+ goto label1;
+ }
+ return -1;
+}