|
| 1 | +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s |
| 2 | +// expected-no-diagnostics |
| 3 | + |
| 4 | +#ifndef HEADER |
| 5 | +#define HEADER |
| 6 | + |
| 7 | +void func1() { |
| 8 | +#pragma omp metadirective when(user = {condition(0)} \ |
| 9 | + : parallel for) otherwise() |
| 10 | + for (int i = 0; i < 100; i++) |
| 11 | + ; |
| 12 | + |
| 13 | +#pragma omp metadirective when(user = {condition(0)} \ |
| 14 | + : parallel for) |
| 15 | + for (int i = 0; i < 100; i++) |
| 16 | + ; |
| 17 | +} |
| 18 | + |
| 19 | +// CHECK-LABEL: define dso_local void @_Z5func1v() |
| 20 | +// CHECK: entry |
| 21 | +// CHECK-NEXT: [[I:%.*]] = alloca i32, align 4 |
| 22 | +// CHECK-NEXT: [[I1:%.*]] = alloca i32, align 4 |
| 23 | +// CHECK-NEXT: store i32 0, ptr [[I]], align 4 |
| 24 | +// CHECK-NEXT: br label %[[FOR_COND:.*]] |
| 25 | +// CHECK: [[FOR_COND]]: |
| 26 | +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[I]], align 4 |
| 27 | +// CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP0]], 100 |
| 28 | +// CHECK-NEXT: br i1 [[CMP]], label %[[FOR_BODY:.*]], label %[[FOR_END:.*]] |
| 29 | +// CHECK: [[FOR_BODY]]: |
| 30 | +// CHECK-NEXT: br label %[[FOR_INC:.*]] |
| 31 | +// CHECK: [[FOR_INC]]: |
| 32 | +// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[I]], align 4 |
| 33 | +// CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP1]], 1 |
| 34 | +// CHECK-NEXT: store i32 [[INC]], ptr [[I]], align 4 |
| 35 | +// CHECK-NEXT: br label %[[FOR_COND]], !llvm.loop [[LOOP3:![0-9]+]] |
| 36 | +// CHECK: [[FOR_END]]: |
| 37 | +// CHECK-NEXT: store i32 0, ptr [[I1]], align 4 |
| 38 | +// CHECK-NEXT: br label %[[FOR_COND2:.*]] |
| 39 | +// CHECK: [[FOR_COND2]]: |
| 40 | +// CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[I1]], align 4 |
| 41 | +// CHECK-NEXT: [[CMP3:%.*]] = icmp slt i32 [[TMP2]], 100 |
| 42 | +// CHECK-NEXT: br i1 [[CMP3]], label %[[FOR_BODY4:.*]], label %[[FOR_END7:.*]] |
| 43 | +// CHECK: [[FOR_BODY4]]: |
| 44 | +// CHECK-NEXT: br label %[[FOR_INC5:.*]] |
| 45 | +// CHECK: [[FOR_INC5]]: |
| 46 | +// CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[I1]], align 4 |
| 47 | +// CHECK-NEXT: [[INC6:%.*]] = add nsw i32 [[TMP3]], 1 |
| 48 | +// CHECK-NEXT: store i32 [[INC6]], ptr [[I1]], align 4 |
| 49 | +// CHECK-NEXT: br label %[[FOR_COND2]], !llvm.loop [[LOOP5:![0-9]+]] |
| 50 | +// CHECK: [[FOR_END7]]: |
| 51 | +// CHECK-NEXT: ret void |
| 52 | + |
| 53 | +void func2() { |
| 54 | +#pragma omp metadirective when(user = {condition(1)} \ |
| 55 | + : parallel for) otherwise() |
| 56 | + for (int i = 0; i < 100; i++) |
| 57 | + ; |
| 58 | + |
| 59 | +#pragma omp metadirective when(user = {condition(1)} \ |
| 60 | + : parallel for) |
| 61 | + for (int i = 0; i < 100; i++) |
| 62 | + ; |
| 63 | +} |
| 64 | + |
| 65 | +// CHECK-LABEL: define dso_local void @_Z5func2v() |
| 66 | +// CHECK: entry |
| 67 | +// CHECK-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB2:[0-9]+]], i32 0, ptr @_Z5func2v.omp_outlined) |
| 68 | +// CHECK-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB2]], i32 0, ptr @_Z5func2v.omp_outlined.1) |
| 69 | +// CHECK-NEXT: ret void |
| 70 | + |
| 71 | + |
| 72 | +#endif |
0 commit comments