[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / metadirective_empty.cpp
blobb93ed722cb6e9044d9e74ce2c3a0401fb5d406c9
1 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
2 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple aarch64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
3 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
4 // expected-no-diagnostics
6 #ifndef HEADER
7 #define HEADER
9 #define N 1000
10 void func() {
11 // Test where a valid when clause contains empty directive.
12 // The directive will be ignored and code for a serial for loop will be generated.
13 #pragma omp metadirective when(implementation = {vendor(llvm)} \
14 :) default(parallel for)
15 for (int i = 0; i < N; i++)
18 #pragma omp metadirective when(implementation = {vendor(llvm)} \
19 :nothing) default(parallel for)
20 for (int i = 0; i < N; i++)
24 // CHECK-LABEL: void @_Z4funcv()
25 // CHECK: entry:
26 // CHECK: [[I:%.+]] = alloca i32,
27 // CHECK: [[I1:%.+]] = alloca i32,
28 // CHECK: store i32 0, ptr [[I]],
29 // CHECK: br label %[[FOR_COND:.+]]
30 // CHECK: [[FOR_COND]]:
31 // CHECK: [[ZERO:%.+]] = load i32, ptr [[I]],
32 // CHECK: [[CMP:%.+]] = icmp slt i32 [[ZERO]], 1000
33 // CHECK: br i1 [[CMP]], label %[[FOR_BODY:.+]], label %[[FOR_END:.+]]
34 // CHECK: [[FOR_BODY]]:
35 // CHECK: br label %[[FOR_INC:.+]]
36 // CHECK: [[FOR_INC]]:
37 // CHECK: [[ONE:%.+]] = load i32, ptr [[I]],
38 // CHECK: [[INC:%.+]] = add nsw i32 [[ONE]], 1
39 // CHECK: store i32 [[INC]], ptr [[I]],
40 // CHECK: br label %[[FOR_COND]],
41 // CHECK: [[FOR_END]]:
42 // CHECK: store i32 0, ptr [[I1]],
43 // CHECK: br label %[[FOR_COND1:.+]]
44 // CHECK: [[FOR_COND1]]:
45 // CHECK: [[TWO:%.+]] = load i32, ptr [[I1]],
46 // CHECK: [[CMP1:%.+]] = icmp slt i32 [[TWO]], 1000
47 // CHECK: br i1 [[CMP1]], label %[[FOR_BODY1:.+]], label %[[FOR_END1:.+]]
48 // CHECK: [[FOR_BODY1]]:
49 // CHECK: br label %[[FOR_INC1:.+]]
50 // CHECK: [[FOR_INC1]]:
51 // CHECK: [[THREE:%.+]] = load i32, ptr [[I1]],
52 // CHECK: [[INC1:%.+]] = add nsw i32 [[THREE]], 1
53 // CHECK: store i32 [[INC1]], ptr [[I1]],
54 // CHECK: br label %[[FOR_COND1]],
55 // CHECK: [[FOR_END1]]:
56 // CHECK: ret void
57 // CHECK: }
59 #endif