2019-12-27 01:23:38 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,CHECK
|
2016-12-20 20:10:05 +08:00
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
|
2019-12-27 01:23:38 +08:00
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,CHECK
|
[OpenMP] Use the OpenMP-IR-Builder
This is a follow up patch to use the OpenMP-IR-Builder, as discussed on
the mailing list ([1] and later) and at the US Dev Meeting'19.
[1] http://lists.flang-compiler.org/pipermail/flang-dev_lists.flang-compiler.org/2019-May/000197.html
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: ppenzin, penzn, llvm-commits, cfe-commits, jfb, guansong, bollu, hiraditya, mgorny
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69922
2019-11-05 13:00:36 +08:00
|
|
|
|
2019-12-27 01:23:38 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,IRBUILDER
|
[OpenMP] Use the OpenMP-IR-Builder
This is a follow up patch to use the OpenMP-IR-Builder, as discussed on
the mailing list ([1] and later) and at the US Dev Meeting'19.
[1] http://lists.flang-compiler.org/pipermail/flang-dev_lists.flang-compiler.org/2019-May/000197.html
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: ppenzin, penzn, llvm-commits, cfe-commits, jfb, guansong, bollu, hiraditya, mgorny
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69922
2019-11-05 13:00:36 +08:00
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
|
2019-12-27 01:23:38 +08:00
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER
|
2017-12-30 02:07:07 +08:00
|
|
|
|
|
|
|
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
|
|
|
|
// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
|
2020-08-13 15:27:15 +08:00
|
|
|
|
|
|
|
// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,CHECK
|
|
|
|
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,CHECK
|
|
|
|
|
|
|
|
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,IRBUILDER
|
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER
|
|
|
|
|
|
|
|
// RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
|
|
|
|
// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
|
|
|
|
|
2015-07-06 13:50:32 +08:00
|
|
|
// expected-no-diagnostics
|
|
|
|
#ifndef HEADER
|
|
|
|
#define HEADER
|
|
|
|
|
2015-09-18 16:07:34 +08:00
|
|
|
float flag;
|
2015-07-06 13:50:32 +08:00
|
|
|
int main (int argc, char **argv) {
|
|
|
|
#pragma omp parallel
|
|
|
|
{
|
2015-09-18 16:07:34 +08:00
|
|
|
#pragma omp cancel parallel if(flag)
|
2015-07-06 13:50:32 +08:00
|
|
|
argv[0][0] = argc;
|
2017-02-18 02:32:51 +08:00
|
|
|
#pragma omp barrier
|
|
|
|
argv[0][0] += argc;
|
2015-07-06 13:50:32 +08:00
|
|
|
}
|
2019-12-27 01:23:38 +08:00
|
|
|
// ALL: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
|
2015-07-06 13:50:32 +08:00
|
|
|
#pragma omp sections
|
|
|
|
{
|
|
|
|
#pragma omp cancel sections
|
|
|
|
}
|
2019-12-27 01:23:38 +08:00
|
|
|
// ALL: call void @__kmpc_for_static_init_4(
|
|
|
|
// ALL: call i32 @__kmpc_cancel(
|
|
|
|
// ALL: call void @__kmpc_for_static_fini(
|
|
|
|
// ALL: call void @__kmpc_barrier(%struct.ident_t*
|
2015-07-06 13:50:32 +08:00
|
|
|
#pragma omp sections
|
|
|
|
{
|
|
|
|
#pragma omp cancel sections
|
|
|
|
#pragma omp section
|
|
|
|
{
|
|
|
|
#pragma omp cancel sections
|
|
|
|
}
|
|
|
|
}
|
2019-12-27 01:23:38 +08:00
|
|
|
// ALL: call void @__kmpc_for_static_init_4(
|
2020-06-30 02:14:46 +08:00
|
|
|
// ALL: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID:%.*]], i32 3)
|
2019-12-27 01:23:38 +08:00
|
|
|
// ALL: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
|
|
|
|
// ALL: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
|
|
|
|
// ALL: [[EXIT]]
|
|
|
|
// ALL: br label
|
|
|
|
// ALL: [[CONTINUE]]
|
|
|
|
// ALL: br label
|
2020-06-30 02:14:46 +08:00
|
|
|
// ALL: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID:%.*]], i32 3)
|
2019-12-27 01:23:38 +08:00
|
|
|
// ALL: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
|
|
|
|
// ALL: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
|
|
|
|
// ALL: [[EXIT]]
|
|
|
|
// ALL: br label
|
|
|
|
// ALL: [[CONTINUE]]
|
|
|
|
// ALL: br label
|
|
|
|
// ALL: call void @__kmpc_for_static_fini(
|
2015-07-06 13:50:32 +08:00
|
|
|
#pragma omp for
|
|
|
|
for (int i = 0; i < argc; ++i) {
|
2015-09-18 16:07:34 +08:00
|
|
|
#pragma omp cancel for if(cancel: flag)
|
2015-07-06 13:50:32 +08:00
|
|
|
}
|
2019-12-27 01:23:38 +08:00
|
|
|
// ALL: call void @__kmpc_for_static_init_4(
|
|
|
|
// ALL: [[FLAG:%.+]] = load float, float* @{{.+}},
|
|
|
|
// ALL: [[BOOL:%.+]] = fcmp une float [[FLAG]], 0.000000e+00
|
|
|
|
// ALL: br i1 [[BOOL]], label %[[THEN:[^,]+]], label %[[ELSE:[^,]+]]
|
|
|
|
// ALL: [[THEN]]
|
2020-06-30 02:14:46 +08:00
|
|
|
// ALL: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID:%.*]], i32 2)
|
2019-12-27 01:23:38 +08:00
|
|
|
// ALL: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
|
|
|
|
// ALL: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
|
|
|
|
// ALL: [[EXIT]]
|
|
|
|
// ALL: br label
|
|
|
|
// ALL: [[CONTINUE]]
|
|
|
|
// ALL: br label
|
|
|
|
// ALL: [[ELSE]]
|
|
|
|
// ALL: br label
|
|
|
|
// ALL: call void @__kmpc_for_static_fini(
|
|
|
|
// ALL: call void @__kmpc_barrier(%struct.ident_t*
|
2015-07-06 13:50:32 +08:00
|
|
|
#pragma omp task
|
|
|
|
{
|
|
|
|
#pragma omp cancel taskgroup
|
|
|
|
}
|
2019-12-27 01:23:38 +08:00
|
|
|
// ALL: call i8* @__kmpc_omp_task_alloc(
|
|
|
|
// ALL: call i32 @__kmpc_omp_task(
|
2015-09-15 20:52:43 +08:00
|
|
|
#pragma omp parallel sections
|
|
|
|
{
|
|
|
|
#pragma omp cancel sections
|
|
|
|
}
|
2019-12-27 01:23:38 +08:00
|
|
|
// ALL: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
|
2015-09-15 20:52:43 +08:00
|
|
|
#pragma omp parallel sections
|
|
|
|
{
|
|
|
|
#pragma omp cancel sections
|
|
|
|
#pragma omp section
|
|
|
|
{
|
|
|
|
#pragma omp cancel sections
|
|
|
|
}
|
|
|
|
}
|
2019-12-27 01:23:38 +08:00
|
|
|
// ALL: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
|
2016-11-17 23:12:05 +08:00
|
|
|
int r = 0;
|
|
|
|
#pragma omp parallel for reduction(+: r)
|
2015-09-15 20:52:43 +08:00
|
|
|
for (int i = 0; i < argc; ++i) {
|
|
|
|
#pragma omp cancel for
|
2016-11-17 23:12:05 +08:00
|
|
|
r += i;
|
2015-09-15 20:52:43 +08:00
|
|
|
}
|
2019-12-27 01:23:38 +08:00
|
|
|
// ALL: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
|
2015-07-06 13:50:32 +08:00
|
|
|
return argc;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}},
|
2015-09-18 16:07:34 +08:00
|
|
|
// CHECK: [[FLAG:%.+]] = load float, float* @{{.+}},
|
|
|
|
// CHECK: [[BOOL:%.+]] = fcmp une float [[FLAG]], 0.000000e+00
|
|
|
|
// CHECK: br i1 [[BOOL]], label %[[THEN:[^,]+]], label %[[ELSE:[^,]+]]
|
|
|
|
// CHECK: [[THEN]]
|
2018-04-17 01:59:34 +08:00
|
|
|
// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 {{[^,]+}}, i32 1)
|
2015-07-06 13:50:32 +08:00
|
|
|
// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
|
|
|
|
// CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
|
|
|
|
// CHECK: [[EXIT]]
|
|
|
|
// CHECK: br label %[[RETURN:.+]]
|
2015-09-18 16:07:34 +08:00
|
|
|
// CHECK: [[ELSE]]
|
2017-02-18 02:32:51 +08:00
|
|
|
// The barrier directive should now call __kmpc_cancel_barrier
|
2018-04-17 01:59:34 +08:00
|
|
|
// CHECK: call i32 @__kmpc_cancel_barrier(%struct.ident_t*
|
2015-09-18 16:07:34 +08:00
|
|
|
// CHECK: br label
|
2015-07-06 13:50:32 +08:00
|
|
|
// CHECK: [[RETURN]]
|
|
|
|
// CHECK: ret void
|
|
|
|
|
|
|
|
// CHECK: define internal i32 @{{[^(]+}}(i32
|
2018-04-17 01:59:34 +08:00
|
|
|
// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 {{[^,]+}}, i32 4)
|
2015-07-06 13:50:32 +08:00
|
|
|
// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
|
|
|
|
// CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
|
|
|
|
// CHECK: [[EXIT]]
|
|
|
|
// CHECK: br label %[[RETURN:.+]]
|
|
|
|
// CHECK: [[RETURN]]
|
|
|
|
// CHECK: ret i32 0
|
|
|
|
|
2015-09-15 20:52:43 +08:00
|
|
|
// CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
|
2016-01-22 16:56:50 +08:00
|
|
|
// CHECK: call void @__kmpc_for_static_init_4(
|
2016-01-20 20:29:47 +08:00
|
|
|
// CHECK: call i32 @__kmpc_cancel(
|
2016-01-22 16:56:50 +08:00
|
|
|
// CHECK: call void @__kmpc_for_static_fini(
|
2015-09-15 20:52:43 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
|
|
|
|
// CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
|
|
|
|
// CHECK: call void @__kmpc_for_static_init_4(
|
2018-04-17 01:59:34 +08:00
|
|
|
// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 3)
|
2015-09-15 20:52:43 +08:00
|
|
|
// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
|
|
|
|
// CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
|
|
|
|
// CHECK: [[EXIT]]
|
|
|
|
// CHECK: br label
|
|
|
|
// CHECK: [[CONTINUE]]
|
|
|
|
// CHECK: br label
|
2020-06-30 02:14:46 +08:00
|
|
|
// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID:%.*]], i32 3)
|
2015-09-15 20:52:43 +08:00
|
|
|
// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
|
|
|
|
// CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
|
|
|
|
// CHECK: [[EXIT]]
|
|
|
|
// CHECK: br label
|
|
|
|
// CHECK: [[CONTINUE]]
|
|
|
|
// CHECK: br label
|
|
|
|
// CHECK: call void @__kmpc_for_static_fini(
|
|
|
|
// CHECK: ret void
|
|
|
|
|
|
|
|
// CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}},
|
|
|
|
// CHECK: call void @__kmpc_for_static_init_4(
|
2018-04-17 01:59:34 +08:00
|
|
|
// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 2)
|
2015-09-15 20:52:43 +08:00
|
|
|
// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
|
|
|
|
// CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
|
|
|
|
// CHECK: [[EXIT]]
|
|
|
|
// CHECK: br label
|
|
|
|
// CHECK: [[CONTINUE]]
|
|
|
|
// CHECK: br label
|
|
|
|
// CHECK: call void @__kmpc_for_static_fini(
|
2016-11-17 23:12:05 +08:00
|
|
|
// CHECK: call i32 @__kmpc_reduce_nowait(
|
|
|
|
// CHECK: call void @__kmpc_end_reduce_nowait(
|
|
|
|
// CHECK: call void @__kmpc_for_static_fini(
|
2015-09-15 20:52:43 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
|
2019-12-27 01:23:38 +08:00
|
|
|
// IRBUILDER: define internal void @main
|
|
|
|
|
2020-06-29 02:41:33 +08:00
|
|
|
// IRBUILDER: [[RETURN:omp.par.outlined.exit[^:]*]]
|
2019-12-27 01:23:38 +08:00
|
|
|
// IRBUILDER-NEXT: ret void
|
|
|
|
// IRBUILDER: [[FLAG:%.+]] = load float, float* @{{.+}},
|
|
|
|
|
|
|
|
// IRBUILDER: [[BOOL:%.+]] = fcmp une float [[FLAG]], 0.000000e+00
|
|
|
|
// IRBUILDER: br i1 [[BOOL]], label %[[THEN:[^,]+]], label %[[ELSE:[^,]+]]
|
|
|
|
// IRBUILDER: [[ELSE]]
|
|
|
|
// IRBUILDER-NEXT: br label %[[ELSE2:.*]]
|
|
|
|
// IRBUILDER: [[ELSE2]]
|
|
|
|
// The barrier directive should now call __kmpc_cancel_barrier
|
|
|
|
// IRBUILDER: call i32 @__kmpc_cancel_barrier(%struct.ident_t*
|
|
|
|
// IRBUILDER: br label
|
|
|
|
// IRBUILDER: [[THEN]]
|
|
|
|
// IRBUILDER: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 {{[^,]+}}, i32 1)
|
|
|
|
// IRBUILDER: [[CMP:%.+]] = icmp eq i32 [[RES]], 0
|
|
|
|
// IRBUILDER: br i1 [[CMP]], label %[[CONTINUE:[^,].+]], label %[[EXIT:.+]]
|
|
|
|
// IRBUILDER: [[EXIT]]
|
2020-02-13 14:39:55 +08:00
|
|
|
// IRBUILDER: br label %[[RETURN]]
|
2020-06-29 02:41:33 +08:00
|
|
|
// IRBUILDER: [[CONTINUE]]
|
|
|
|
// IRBUILDER: br label %[[ELSE2:.+]]
|
2019-12-27 01:23:38 +08:00
|
|
|
|
2015-07-06 13:50:32 +08:00
|
|
|
#endif
|