]> granicus.if.org Git - clang/commitdiff
[OPENMP] DO not crash on combined constructs in declare target
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 16 May 2018 15:08:32 +0000 (15:08 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Wed, 16 May 2018 15:08:32 +0000 (15:08 +0000)
functions.

If the combined construct is specified in the declare target function
and the device code is emitted, the compiler crashes because of the
incorrectly chosen captured stmt. We should choose the innermost
captured statement, not the outermost.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332477 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGStmtOpenMP.cpp
test/OpenMP/declare_target_codegen.cpp

index c207fb64a36bd7f5e947d74df49e74769b7e1ba9..0d343f84c71f35f3098a71383442be2fe5493ebc 100644 (file)
@@ -3935,7 +3935,7 @@ static void emitCommonOMPTargetDirective(CodeGenFunction &CGF,
     OMPLexicalScope Scope(CGF, S, OMPD_target);
     CGM.getOpenMPRuntime().emitInlinedDirective(
         CGF, OMPD_target, [&S](CodeGenFunction &CGF, PrePostActionTy &) {
-          CGF.EmitStmt(S.getCapturedStmt(OMPD_target)->getCapturedStmt());
+          CGF.EmitStmt(S.getInnermostCapturedStmt()->getCapturedStmt());
         });
     return;
   }
index 02ac148e491960561cddac1a8ecfe5e3456c1bc7..dfc65d8ddade3fc523b10bfdfd0df620aa723911 100644 (file)
@@ -82,7 +82,7 @@ int maini1() {
 int baz3() { return 2 + baz2(); }
 int baz2() {
 // CHECK-DAG: define weak void @__omp_offloading_{{.*}}baz2{{.*}}_l[[@LINE+1]](i64 {{.*}})
-#pragma omp target
+#pragma omp target parallel
   ++c;
   return 2 + baz3();
 }