From cc5beee3ed391ed50ce1208c100e6806f6b49f28 Mon Sep 17 00:00:00 2001
From: Alexey Bataev <a.bataev@hotmail.com>
Date: Mon, 27 Nov 2017 19:38:52 +0000
Subject: [PATCH] [OPENMP] Codegen for `distribute parallel for simd`
 directive.

Added proper codegen for `distribute parallel for simd` directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319078 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Basic/OpenMPKinds.cpp |  2 +-
 lib/Sema/SemaOpenMP.cpp   | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/lib/Basic/OpenMPKinds.cpp b/lib/Basic/OpenMPKinds.cpp
index b318f7e034a..41978625ff0 100644
--- a/lib/Basic/OpenMPKinds.cpp
+++ b/lib/Basic/OpenMPKinds.cpp
@@ -885,6 +885,7 @@ void clang::getOpenMPCaptureRegions(
   case OMPD_parallel_for_simd:
   case OMPD_parallel_sections:
   case OMPD_distribute_parallel_for:
+  case OMPD_distribute_parallel_for_simd:
     CaptureRegions.push_back(OMPD_parallel);
     break;
   case OMPD_target_teams:
@@ -930,7 +931,6 @@ void clang::getOpenMPCaptureRegions(
   case OMPD_task:
   case OMPD_taskloop:
   case OMPD_taskloop_simd:
-  case OMPD_distribute_parallel_for_simd:
   case OMPD_distribute_simd:
   case OMPD_teams_distribute_simd:
   case OMPD_teams_distribute_parallel_for_simd:
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp
index 985cc62df09..bd70ca29ce4 100644
--- a/lib/Sema/SemaOpenMP.cpp
+++ b/lib/Sema/SemaOpenMP.cpp
@@ -6838,13 +6838,24 @@ StmtResult Sema::ActOnOpenMPDistributeParallelForSimdDirective(
   // The point of exit cannot be a branch out of the structured block.
   // longjmp() and throw() must not violate the entry/exit criteria.
   CS->getCapturedDecl()->setNothrow();
+  for (int ThisCaptureLevel =
+           getOpenMPCaptureLevels(OMPD_distribute_parallel_for_simd);
+       ThisCaptureLevel > 1; --ThisCaptureLevel) {
+    CS = cast<CapturedStmt>(CS->getCapturedStmt());
+    // 1.2.2 OpenMP Language Terminology
+    // Structured block - An executable statement with a single entry at the
+    // top and a single exit at the bottom.
+    // The point of exit cannot be a branch out of the structured block.
+    // longjmp() and throw() must not violate the entry/exit criteria.
+    CS->getCapturedDecl()->setNothrow();
+  }
 
   OMPLoopDirective::HelperExprs B;
   // In presence of clause 'collapse' with number of loops, it will
   // define the nested loops number.
   unsigned NestedLoopCount = CheckOpenMPLoop(
       OMPD_distribute_parallel_for_simd, getCollapseNumberExpr(Clauses),
-      nullptr /*ordered not a clause on distribute*/, AStmt, *this, *DSAStack,
+      nullptr /*ordered not a clause on distribute*/, CS, *this, *DSAStack,
       VarsWithImplicitDSA, B);
   if (NestedLoopCount == 0)
     return StmtError();
@@ -7793,6 +7804,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
       CaptureRegion = OMPD_teams;
       break;
     case OMPD_distribute_parallel_for:
+    case OMPD_distribute_parallel_for_simd:
       CaptureRegion = OMPD_parallel;
       break;
     case OMPD_parallel_for:
@@ -7800,7 +7812,6 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
     case OMPD_target_teams_distribute_parallel_for:
     case OMPD_target_teams_distribute_parallel_for_simd:
     case OMPD_teams_distribute_parallel_for_simd:
-    case OMPD_distribute_parallel_for_simd:
       // Do not capture schedule clause expressions.
       break;
     case OMPD_task:
-- 
GitLab