summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorCarlo Bertolli <cbertol@us.ibm.com>2016-04-29 01:37:30 +0000
committerCarlo Bertolli <cbertol@us.ibm.com>2016-04-29 01:37:30 +0000
commit6eee9061ac1ce26c7a882faf6bb69c73ad332fa0 (patch)
treef293d254cfa332a86396836abd6f414632e82fe3 /clang/lib
parent78b8bc29db8177ad133a4d04de45fe14bcf220bd (diff)
downloadbcm5719-llvm-6eee9061ac1ce26c7a882faf6bb69c73ad332fa0.tar.gz
bcm5719-llvm-6eee9061ac1ce26c7a882faf6bb69c73ad332fa0.zip
[OPENMP] Enable correct generation of runtime call when target directive is separated from teams directive by multiple curly brackets
http://reviews.llvm.org/D18474 This patch fixes a bug in code generation of the correct OpenMP runtime library call in presence of target and teams, when target is separated by teams with multiple curly brackets. The current implementation will not be able to see the teams directive inside target and issue a call to tgt_target instead of the correct one tgt_target_teams. llvm-svn: 267972
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 70057551d91..b280d53dd39 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4556,6 +4556,14 @@ void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
DeviceID, FileID, ParentName, Line, OutlinedFn, OutlinedFnID);
}
+/// discard all CompoundStmts intervening between two constructs
+static const Stmt *ignoreCompoundStmts(const Stmt *Body) {
+ while (auto *CS = dyn_cast_or_null<CompoundStmt>(Body))
+ Body = CS->body_front();
+
+ return Body;
+}
+
/// \brief Emit the num_teams clause of an enclosed teams directive at the
/// target region scope. If there is no teams directive associated with the
/// target directive, or if there is no num_teams clause associated with the
@@ -4586,7 +4594,8 @@ emitNumTeamsClauseForTargetDirective(CGOpenMPRuntime &OMPRuntime,
// FIXME: Accommodate other combined directives with teams when they become
// available.
- if (auto *TeamsDir = dyn_cast<OMPTeamsDirective>(CS.getCapturedStmt())) {
+ if (auto *TeamsDir = dyn_cast_or_null<OMPTeamsDirective>(
+ ignoreCompoundStmts(CS.getCapturedStmt()))) {
if (auto *NTE = TeamsDir->getSingleClause<OMPNumTeamsClause>()) {
CGOpenMPInnerExprInfo CGInfo(CGF, CS);
CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
@@ -4634,7 +4643,8 @@ emitThreadLimitClauseForTargetDirective(CGOpenMPRuntime &OMPRuntime,
// FIXME: Accommodate other combined directives with teams when they become
// available.
- if (auto *TeamsDir = dyn_cast<OMPTeamsDirective>(CS.getCapturedStmt())) {
+ if (auto *TeamsDir = dyn_cast_or_null<OMPTeamsDirective>(
+ ignoreCompoundStmts(CS.getCapturedStmt()))) {
if (auto *TLE = TeamsDir->getSingleClause<OMPThreadLimitClause>()) {
CGOpenMPInnerExprInfo CGInfo(CGF, CS);
CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
OpenPOWER on IntegriCloud