Skip to content

Commit 18789bf

Browse files
committed
[OPENMP50]Fix handling of clauses in parallel master taskloop directive.
We need to capture correctly the value of num_tasks clause and should not try to emit the if clause at all in the task region.
1 parent 715783d commit 18789bf

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,12 +2018,14 @@ static void emitCommonSimdLoop(CodeGenFunction &CGF, const OMPLoopDirective &S,
20182018
BodyCodeGen(CGF);
20192019
};
20202020
const Expr *IfCond = nullptr;
2021-
for (const auto *C : S.getClausesOfKind<OMPIfClause>()) {
2022-
if (CGF.getLangOpts().OpenMP >= 50 &&
2023-
(C->getNameModifier() == OMPD_unknown ||
2024-
C->getNameModifier() == OMPD_simd)) {
2025-
IfCond = C->getCondition();
2026-
break;
2021+
if (isOpenMPSimdDirective(S.getDirectiveKind())) {
2022+
for (const auto *C : S.getClausesOfKind<OMPIfClause>()) {
2023+
if (CGF.getLangOpts().OpenMP >= 50 &&
2024+
(C->getNameModifier() == OMPD_unknown ||
2025+
C->getNameModifier() == OMPD_simd)) {
2026+
IfCond = C->getCondition();
2027+
break;
2028+
}
20272029
}
20282030
}
20292031
if (IfCond) {
@@ -5682,7 +5684,7 @@ void CodeGenFunction::EmitOMPParallelMasterTaskLoopDirective(
56825684
Action.Enter(CGF);
56835685
CGF.EmitOMPTaskLoopBasedDirective(S);
56845686
};
5685-
OMPLexicalScope Scope(CGF, S, llvm::None, /*EmitPreInitStmt=*/false);
5687+
OMPLexicalScope Scope(CGF, S, OMPD_parallel, /*EmitPreInitStmt=*/false);
56865688
CGM.getOpenMPRuntime().emitMasterRegion(CGF, TaskLoopCodeGen,
56875689
S.getBeginLoc());
56885690
};

clang/test/OpenMP/parallel_master_taskloop_codegen.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - -femit-all-decls | FileCheck %s
2-
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
3-
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - -femit-all-decls | FileCheck %s
1+
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-version=50 -x c++ -emit-llvm %s -o - | FileCheck %s
2+
// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
3+
// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
44

5-
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ -emit-llvm %s -o - -femit-all-decls | FileCheck --check-prefix SIMD-ONLY0 %s
6-
// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
7-
// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - -femit-all-decls | FileCheck --check-prefix SIMD-ONLY0 %s
5+
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -fopenmp-version=50 -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
6+
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
7+
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
88
// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
99
// expected-no-diagnostics
1010
#ifndef HEADER

0 commit comments

Comments
 (0)