diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2015-04-30 04:23:23 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2015-04-30 04:23:23 +0000 |
commit | 9c821037434dc106543d6905f5519b1129eb904f (patch) | |
tree | 606d74503746bf46ee86c1491b27b1cc190dfb05 /clang/test/OpenMP | |
parent | f8a16a952dddaf1d38d6f596b78b1041ce5ea2eb (diff) | |
download | bcm5719-llvm-9c821037434dc106543d6905f5519b1129eb904f.tar.gz bcm5719-llvm-9c821037434dc106543d6905f5519b1129eb904f.zip |
[OPENMP] Allow to use global variables as lcv in loop-based directives.
For proper codegen we need to capture variable in the OpenMP region. In loop-based directives loop control variables are private by default and they must be captured in this region. There was a problem with capturing of globals, used as lcv, as they was not marked as private by default.
Differential Revision: http://reviews.llvm.org/D9336
llvm-svn: 236201
Diffstat (limited to 'clang/test/OpenMP')
-rw-r--r-- | clang/test/OpenMP/for_codegen.cpp | 42 | ||||
-rw-r--r-- | clang/test/OpenMP/for_loop_messages.cpp | 2 | ||||
-rw-r--r-- | clang/test/OpenMP/for_simd_loop_messages.cpp | 2 | ||||
-rw-r--r-- | clang/test/OpenMP/parallel_for_loop_messages.cpp | 2 | ||||
-rw-r--r-- | clang/test/OpenMP/parallel_for_simd_loop_messages.cpp | 2 | ||||
-rw-r--r-- | clang/test/OpenMP/simd_loop_messages.cpp | 2 |
6 files changed, 41 insertions, 11 deletions
diff --git a/clang/test/OpenMP/for_codegen.cpp b/clang/test/OpenMP/for_codegen.cpp index 41cc4c0143c..31161e26e1e 100644 --- a/clang/test/OpenMP/for_codegen.cpp +++ b/clang/test/OpenMP/for_codegen.cpp @@ -8,7 +8,11 @@ #define HEADER // CHECK: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* } -// CHECK: [[IMPLICIT_BARRIER_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 66, i32 0, i32 0, i8* +// CHECK-DAG: [[IMPLICIT_BARRIER_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 66, i32 0, i32 0, i8* +// CHECK-DAG: [[I:@.+]] = global i8 1, +// CHECK-DAG: [[J:@.+]] = global i8 2, +// CHECK-DAG: [[K:@.+]] = global i8 3, + // CHECK-LABEL: define {{.*void}} @{{.*}}without_schedule_clause{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}}) void without_schedule_clause(float *a, float *b, float *c, float *d) { // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:[@%].+]]) @@ -365,5 +369,41 @@ void parallel_for(float *a) { // TERM_DEBUG-DAG: [[DBG_LOC_END]] = !DILocation(line: [[@LINE-16]], // TERM_DEBUG-DAG: [[DBG_LOC_CANCEL]] = !DILocation(line: [[@LINE-17]], +char i = 1, j = 2, k = 3; +// CHECK-LABEL: for_with_global_lcv +void for_with_global_lcv() { +// CHECK: [[I_ADDR:%.+]] = alloca i8, +// CHECK: [[J_ADDR:%.+]] = alloca i8, + +// CHECK: call void @__kmpc_for_static_init_4( +// CHECK-NOT: [[I]] +// CHECK: store i8 %{{.+}}, i8* [[I_ADDR]] +// CHECK-NOT: [[I]] +// CHECK: [[I_VAL:%.+]] = load i8, i8* [[I_ADDR]], +// CHECK-NOT: [[I]] +// CHECK: store i8 [[I_VAL]], i8* [[K]] +// CHECK-NOT: [[I]] +// CHECK: call void @__kmpc_for_static_fini( +#pragma omp for + for (i = 0; i < 2; ++i) { + k = i; + } +// CHECK: call void @__kmpc_for_static_init_4( +// CHECK-NOT: [[J]] +// CHECK: store i8 %{{.+}}, i8* [[J_ADDR]] +// CHECK-NOT: [[J]] +// CHECK: [[J_VAL:%.+]] = load i8, i8* [[J_ADDR]], +// CHECK-NOT: [[J]] +// CHECK: store i8 [[J_VAL]], i8* [[K]] +// CHECK-NOT: [[J]] +// CHECK: call void @__kmpc_for_static_fini( +#pragma omp for collapse(2) + for (int i = 0; i < 2; ++i) + for (j = 0; j < 2; ++j) { + k = i; + k = j; + } +} + #endif // HEADER diff --git a/clang/test/OpenMP/for_loop_messages.cpp b/clang/test/OpenMP/for_loop_messages.cpp index cb32484e43f..0b2fa9bbc17 100644 --- a/clang/test/OpenMP/for_loop_messages.cpp +++ b/clang/test/OpenMP/for_loop_messages.cpp @@ -313,7 +313,6 @@ int test_iteration_spaces() { #pragma omp parallel { -// expected-error@+2 {{loop iteration variable in the associated loop of 'omp for' directive may not be a variable with global storage without being explicitly marked as private}} #pragma omp for for (globalii = 0; globalii < 10; globalii += 1) c[globalii] = a[globalii]; @@ -321,7 +320,6 @@ int test_iteration_spaces() { #pragma omp parallel { -// expected-error@+3 {{loop iteration variable in the associated loop of 'omp for' directive may not be a variable with global storage without being explicitly marked as private}} #pragma omp for collapse(2) for (ii = 0; ii < 10; ii += 1) for (globalii = 0; globalii < 10; globalii += 1) diff --git a/clang/test/OpenMP/for_simd_loop_messages.cpp b/clang/test/OpenMP/for_simd_loop_messages.cpp index 403709f3453..db59d9d22ee 100644 --- a/clang/test/OpenMP/for_simd_loop_messages.cpp +++ b/clang/test/OpenMP/for_simd_loop_messages.cpp @@ -314,7 +314,6 @@ int test_iteration_spaces() { #pragma omp parallel { -// expected-error@+2 {{loop iteration variable in the associated loop of 'omp for simd' directive may not be a variable with global storage without being explicitly marked as linear}} #pragma omp for simd for (globalii = 0; globalii < 10; globalii += 1) c[globalii] = a[globalii]; @@ -322,7 +321,6 @@ int test_iteration_spaces() { #pragma omp parallel { -// expected-error@+3 {{loop iteration variable in the associated loop of 'omp for simd' directive may not be a variable with global storage without being explicitly marked as lastprivate}} #pragma omp for simd collapse(2) for (ii = 0; ii < 10; ii += 1) for (globalii = 0; globalii < 10; globalii += 1) diff --git a/clang/test/OpenMP/parallel_for_loop_messages.cpp b/clang/test/OpenMP/parallel_for_loop_messages.cpp index c3299976bd0..318f0e6d9ec 100644 --- a/clang/test/OpenMP/parallel_for_loop_messages.cpp +++ b/clang/test/OpenMP/parallel_for_loop_messages.cpp @@ -265,14 +265,12 @@ int test_iteration_spaces() { } { -// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be a variable with global storage without being explicitly marked as private}} #pragma omp parallel for for (globalii = 0; globalii < 10; globalii += 1) c[globalii] = a[globalii]; } { -// expected-error@+3 {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be a variable with global storage without being explicitly marked as private}} #pragma omp parallel for collapse(2) for (ii = 0; ii < 10; ii += 1) for (globalii = 0; globalii < 10; globalii += 1) diff --git a/clang/test/OpenMP/parallel_for_simd_loop_messages.cpp b/clang/test/OpenMP/parallel_for_simd_loop_messages.cpp index 50acb10feed..43dbbe089bb 100644 --- a/clang/test/OpenMP/parallel_for_simd_loop_messages.cpp +++ b/clang/test/OpenMP/parallel_for_simd_loop_messages.cpp @@ -266,14 +266,12 @@ int test_iteration_spaces() { } { -// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be a variable with global storage without being explicitly marked as linear}} #pragma omp parallel for simd for (globalii = 0; globalii < 10; globalii += 1) c[globalii] = a[globalii]; } { -// expected-error@+3 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be a variable with global storage without being explicitly marked as lastprivate}} #pragma omp parallel for simd collapse(2) for (ii = 0; ii < 10; ii += 1) for (globalii = 0; globalii < 10; globalii += 1) diff --git a/clang/test/OpenMP/simd_loop_messages.cpp b/clang/test/OpenMP/simd_loop_messages.cpp index ce64842d68a..b2c804c93e5 100644 --- a/clang/test/OpenMP/simd_loop_messages.cpp +++ b/clang/test/OpenMP/simd_loop_messages.cpp @@ -260,7 +260,6 @@ int test_iteration_spaces() { #pragma omp parallel { - // expected-error@+2 {{loop iteration variable in the associated loop of 'omp simd' directive may not be a variable with global storage without being explicitly marked as linear}} #pragma omp simd for (globalii = 0; globalii < 10; globalii+=1) c[globalii] = a[globalii]; @@ -268,7 +267,6 @@ int test_iteration_spaces() { #pragma omp parallel { -// expected-error@+3 {{loop iteration variable in the associated loop of 'omp simd' directive may not be a variable with global storage without being explicitly marked as lastprivate}} #pragma omp simd collapse(2) for (ii = 0; ii < 10; ii += 1) for (globalii = 0; globalii < 10; globalii += 1) |