Skip to content

Commit c2cdff6

Browse files
committed
[OPENMP]Fix PR40513: lastprivate taskloop counter.
We don't need to use the predetermined data-sharing attributes for the loop counters if the user explicitly specified correct data-sharing attributes for such variables. llvm-svn: 352543
1 parent 33c9d9a commit c2cdff6

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4866,10 +4866,7 @@ static bool checkOpenMPIterationSpace(
48664866
// lastprivate (for simd directives with several collapsed or ordered
48674867
// loops).
48684868
if (DVar.CKind == OMPC_unknown)
4869-
DVar = DSA.hasDSA(LCDecl, isOpenMPPrivate,
4870-
[](OpenMPDirectiveKind) -> bool { return true; },
4871-
/*FromParent=*/false);
4872-
DSA.addDSA(LCDecl, LoopDeclRefExpr, PredeterminedCKind);
4869+
DSA.addDSA(LCDecl, LoopDeclRefExpr, PredeterminedCKind);
48734870
}
48744871

48754872
assert(isOpenMPLoopDirective(DKind) && "DSA for non-loop vars");

clang/test/OpenMP/taskloop_lastprivate_codegen.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=LAMBDA %s
55
// RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=BLOCKS %s
66
// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DARRAY -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=ARRAY %s
7+
// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLOOP -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=LOOP %s
78

89
// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
910
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-apple-darwin10 -emit-pch -o %t %s
1011
// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
1112
// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DLAMBDA -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
1213
// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -fblocks -DBLOCKS -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
1314
// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DARRAY -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
15+
// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DLOOP -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=SIMD-ONLY0 %s
1416
// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
1517
// expected-no-diagnostics
1618
// It doesn't pass on win32.
1719
// REQUIRES: shell
18-
#ifndef ARRAY
20+
#if !defined(ARRAY) && !defined(LOOP)
1921
#ifndef HEADER
2022
#define HEADER
2123

@@ -501,7 +503,7 @@ int main() {
501503
// CHECK: ret i32
502504

503505
#endif
504-
#else
506+
#elif defined(ARRAY)
505507
// ARRAY-LABEL: array_func
506508
struct St {
507509
int a, b;
@@ -522,5 +524,16 @@ void array_func(int n, float a[n], St s[2]) {
522524
for (int i = 0; i < 10; ++i)
523525
;
524526
}
527+
#else
528+
529+
// LOOP-LABEL: loop
530+
void loop() {
531+
// LOOP: call i8* @__kmpc_omp_task_alloc(
532+
// LOOP: call void @__kmpc_taskloop(
533+
int i;
534+
#pragma omp taskloop lastprivate(i)
535+
for (i = 0; i < 10; ++i)
536+
;
537+
}
525538
#endif
526539

0 commit comments

Comments
 (0)