From 90a2c3d33a317e095f641bb73cf59fd194d99b7f Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Wed, 16 May 2018 15:08:32 +0000 Subject: [PATCH] [OPENMP] DO not crash on combined constructs in declare target 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 | 2 +- test/OpenMP/declare_target_codegen.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/CGStmtOpenMP.cpp b/lib/CodeGen/CGStmtOpenMP.cpp index c207fb64a3..0d343f84c7 100644 --- a/lib/CodeGen/CGStmtOpenMP.cpp +++ b/lib/CodeGen/CGStmtOpenMP.cpp @@ -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; } diff --git a/test/OpenMP/declare_target_codegen.cpp b/test/OpenMP/declare_target_codegen.cpp index 02ac148e49..dfc65d8dda 100644 --- a/test/OpenMP/declare_target_codegen.cpp +++ b/test/OpenMP/declare_target_codegen.cpp @@ -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(); } -- 2.50.1