107 lines · c
1// RUN: %clang_cc1 -emit-llvm -o - -O2 -disable-llvm-passes %s | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK,O22// RUN: %clang_cc1 -emit-llvm -o - -O2 -disable-lifetime-markers %s | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK3// RUN: %clang_cc1 -emit-llvm -o - -O0 %s | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK 4 5extern int bar(char *A, int n);6 7// CHECK-LABEL: @foo8int foo (int n) {9 if (n) {10// O2: call void @llvm.lifetime.start.p0(11 char A[100];12 return bar(A, 1);13// O2: call void @llvm.lifetime.end.p0(14 } else {15// O2: call void @llvm.lifetime.start.p0(16 char A[100];17 return bar(A, 2);18// O2: call void @llvm.lifetime.end.p0(19 }20}21 22// CHECK-LABEL: @no_goto_bypass23void no_goto_bypass(void) {24 // O2: call void @llvm.lifetime.start.p0(25 char x;26l1:27 bar(&x, 1);28 char y[5];29 bar(y, 5);30 goto l1;31 // Infinite loop32}33 34// CHECK-LABEL: @goto_bypass35void goto_bypass(void) {36 {37 char x;38 l1:39 bar(&x, 1);40 }41 goto l1;42}43 44// CHECK-LABEL: @no_switch_bypass45void no_switch_bypass(int n) {46 switch (n) {47 case 1: {48 // O2: call void @llvm.lifetime.start.p0(49 // O2: call void @llvm.lifetime.end.p0(50 char x;51 bar(&x, 1);52 break;53 }54 case 2:55 n = n;56 // O2: call void @llvm.lifetime.start.p0(57 // O2: call void @llvm.lifetime.end.p0(58 char y[5];59 bar(y, 5);60 break;61 }62}63 64// CHECK-LABEL: @switch_bypass65void switch_bypass(int n) {66 switch (n) {67 case 1:68 n = n;69 char x;70 bar(&x, 1);71 break;72 case 2:73 bar(&x, 1);74 break;75 }76}77 78// CHECK-LABEL: @indirect_jump79void indirect_jump(int n) {80 char x;81 void *T[] = {&&L};82 goto *T[n];83L:84 bar(&x, 1);85}86 87extern void foo2(int p);88 89// O2-LABEL: @jump_backward_over_declaration(90int jump_backward_over_declaration(int a) {91 int *p = 0;92// O2: call void @llvm.lifetime.start.p0(93label1:94 if (p) {95 foo2(*p);96 return 0;97 }98 99 int i = 999;100 if (a != 2) {101 p = &i;102 goto label1;103 }104 return -1;105// O2: call void @llvm.lifetime.end.p0(106}107