[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / bug56913.c
blobcc7231626878cc63c3c2ceb3094b7d2d4429e001
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --prefix-filecheck-ir-name _
2 // RUN: %clang_cc1 -fopenmp-simd -O1 -x c -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
4 int j;
5 int *u;
7 void loop(int n) {
8 int i;
9 #pragma omp parallel master taskloop simd linear(j)
10 for (i = 0; i < n; ++i) {
11 ++j;
12 u = &j;
15 // CHECK-LABEL: define {{[^@]+}}@loop
16 // CHECK-SAME: (i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
17 // CHECK-NEXT: entry:
18 // CHECK-NEXT: [[J:%.*]] = alloca i32, align 4
19 // CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N]], 0
20 // CHECK-NEXT: br i1 [[CMP]], label [[SIMD_IF_THEN:%.*]], label [[SIMD_IF_END:%.*]]
21 // CHECK: simd.if.then:
22 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @j, align 4, !tbaa [[TBAA2:![0-9]+]]
23 // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nonnull [[J]]) #[[ATTR2:[0-9]+]]
24 // CHECK-NEXT: store ptr [[J]], ptr @u, align 8, !tbaa [[TBAA6:![0-9]+]], !llvm.access.group [[ACC_GRP8:![0-9]+]]
25 // CHECK-NEXT: [[INC_LE:%.*]] = add i32 [[TMP0]], [[N]]
26 // CHECK-NEXT: store i32 [[INC_LE]], ptr [[J]], align 4, !tbaa [[TBAA2]]
27 // CHECK-NEXT: store i32 [[INC_LE]], ptr @j, align 4, !tbaa [[TBAA2]]
28 // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr nonnull [[J]]) #[[ATTR2]]
29 // CHECK-NEXT: br label [[SIMD_IF_END]]
30 // CHECK: simd.if.end:
31 // CHECK-NEXT: ret void