r258307 - [OPENMP 4.0] Fix for codegen of 'cancel' directive within 'sections' directive.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 20 04:29:47 PST 2016
Author: abataev
Date: Wed Jan 20 06:29:47 2016
New Revision: 258307
URL: http://llvm.org/viewvc/llvm-project?rev=258307&view=rev
Log:
[OPENMP 4.0] Fix for codegen of 'cancel' directive within 'sections' directive.
Allow to emit code for 'cancel' directive within 'sections' directive with single sub-section.
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/cancel_codegen.cpp
Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=258307&r1=258306&r2=258307&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Jan 20 06:29:47 2016
@@ -3685,8 +3685,6 @@ void CGOpenMPRuntime::emitCancelCall(Cod
// kmp_int32 cncl_kind);
if (auto *OMPRegionInfo =
dyn_cast_or_null<CGOpenMPRegionInfo>(CGF.CapturedStmtInfo)) {
- if (OMPRegionInfo->getDirectiveKind() == OMPD_single)
- return;
auto &&ThenGen = [this, Loc, CancelRegion,
OMPRegionInfo](CodeGenFunction &CGF) {
llvm::Value *Args[] = {
Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=258307&r1=258306&r2=258307&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Jan 20 06:29:47 2016
@@ -1786,7 +1786,11 @@ CodeGenFunction::EmitSections(const OMPE
CGF.EmitOMPPrivateClause(S, SingleScope);
(void)SingleScope.Privatize();
+ auto Exit = CGF.getJumpDestInCurrentScope("omp.sections.exit");
+ CGF.BreakContinueStack.push_back(BreakContinue(Exit, Exit));
CGF.EmitStmt(Stmt);
+ CGF.EmitBlock(Exit.getBlock());
+ CGF.BreakContinueStack.pop_back();
};
CGM.getOpenMPRuntime().emitSingleRegion(*this, CodeGen, S.getLocStart(),
llvm::None, llvm::None, llvm::None,
@@ -2647,7 +2651,8 @@ CodeGenFunction::getOMPCancelDestination
if (Kind == OMPD_parallel || Kind == OMPD_task)
return ReturnBlock;
assert(Kind == OMPD_for || Kind == OMPD_section || Kind == OMPD_sections ||
- Kind == OMPD_parallel_sections || Kind == OMPD_parallel_for);
+ Kind == OMPD_parallel_sections || Kind == OMPD_parallel_for ||
+ Kind == OMPD_single);
return BreakContinueStack.back().BreakBlock;
}
Modified: cfe/trunk/test/OpenMP/cancel_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/cancel_codegen.cpp?rev=258307&r1=258306&r2=258307&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/cancel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/cancel_codegen.cpp Wed Jan 20 06:29:47 2016
@@ -20,7 +20,7 @@ int main (int argc, char **argv) {
#pragma omp cancel sections
}
// CHECK: call i32 @__kmpc_single(
-// CHECK-NOT: @__kmpc_cancel
+// CHECK: call i32 @__kmpc_cancel(
// CHECK: call void @__kmpc_end_single(
// CHECK: call void @__kmpc_barrier(%ident_t*
#pragma omp sections
@@ -126,7 +126,7 @@ for (int i = 0; i < argc; ++i) {
// CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
// CHECK: call i32 @__kmpc_single(
-// CHECK-NOT: @__kmpc_cancel
+// CHECK: call i32 @__kmpc_cancel(
// CHECK: call void @__kmpc_end_single(
// CHECK: ret void
More information about the cfe-commits
mailing list