r332477 - [OPENMP] DO not crash on combined constructs in declare target
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Wed May 16 08:08:32 PDT 2018
Author: abataev
Date: Wed May 16 08:08:32 2018
New Revision: 332477
URL: http://llvm.org/viewvc/llvm-project?rev=332477&view=rev
Log:
[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.
Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp
Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=332477&r1=332476&r2=332477&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed May 16 08:08:32 2018
@@ -3935,7 +3935,7 @@ static void emitCommonOMPTargetDirective
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;
}
Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=332477&r1=332476&r2=332477&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Wed May 16 08:08:32 2018
@@ -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();
}
More information about the cfe-commits
mailing list