<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hi,</p>
<p>Sorry for this mess. Fixed in r287033.<br>
</p>
<pre class="moz-signature" cols="72">Best regards,
Alexey Bataev</pre>
<div class="moz-cite-prefix">On 11/15/2016 09:58 PM, Vitaly Buka wrote:<br>
</div>
<blockquote cite="mid:CAPjTjwvLX=GJ_pOoCzaZDBW=TiqTL0bRfRWuLQMRKSRzs+ALTg@mail.gmail.com" type="cite">
<div dir="ltr">Alexey, this patch is likely the cause of <a moz-do-not-send="true" href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/197/steps/check-clang%20asan/logs/stdio">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/197/steps/check-clang%20asan/logs/stdio</a></div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Tue, Nov 15, 2016 at 8:59 AM Alexey Bataev via llvm-branch-commits <<a moz-do-not-send="true" href="mailto:llvm-branch-commits@lists.llvm.org">llvm-branch-commits@lists.llvm.org</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: abataev<br class="gmail_msg">
Date: Tue Nov 15 08:26:49 2016<br class="gmail_msg">
New Revision: 286968<br class="gmail_msg">
<br class="gmail_msg">
URL: <a moz-do-not-send="true" href="http://llvm.org/viewvc/llvm-project?rev=286968&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=286968&view=rev</a><br class="gmail_msg">
Log:<br class="gmail_msg">
Merging r286944:<br class="gmail_msg">
------------------------------------------------------------------------<br class="gmail_msg">
r286944 | abataev | 2016-11-15 09:11:50 +0000 (Tue, 15 Nov 2016) | 6 lines<br class="gmail_msg">
<br class="gmail_msg">
[OPENMP] Fixed codegen for 'omp cancel' construct.<br class="gmail_msg">
<br class="gmail_msg">
If 'omp cancel' construct is used in a worksharing construct it may cause<br class="gmail_msg">
hanging of the software in case if reduction clause is used. Patch fixes<br class="gmail_msg">
this problem by avoiding extra reduction processing for branches that<br class="gmail_msg">
were canceled.<br class="gmail_msg">
------------------------------------------------------------------------<br class="gmail_msg">
<br class="gmail_msg">
Modified:<br class="gmail_msg">
cfe/branches/release_39/ (props changed)<br class="gmail_msg">
cfe/branches/release_39/lib/CodeGen/CGStmtOpenMP.cpp<br class="gmail_msg">
cfe/branches/release_39/lib/CodeGen/CodeGenFunction.h<br class="gmail_msg">
cfe/branches/release_39/test/OpenMP/cancel_codegen.cpp<br class="gmail_msg">
<br class="gmail_msg">
Propchange: cfe/branches/release_39/<br class="gmail_msg">
------------------------------------------------------------------------------<br class="gmail_msg">
--- svn:mergeinfo (original)<br class="gmail_msg">
+++ svn:mergeinfo Tue Nov 15 08:26:49 2016<br class="gmail_msg">
@@ -1,4 +1,4 @@<br class="gmail_msg">
/cfe/branches/type-system-rewrite:134693-134817<br class="gmail_msg">
-/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277783,277796-277797,277852,277866,277889,277900,278139,278156,278234-278235,278393,278395,278763,278786,278988,284110,286103,286106,286129,286584<br class="gmail_msg">
+/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277783,277796-277797,277852,277866,277889,277900,278139,278156,278234-278235,278393,278395,278763,278786,278988,284110,286103,286106,286129,286584,286944<br class="gmail_msg">
/cfe/trunk/test:170344<br class="gmail_msg">
/cfe/trunk/test/SemaTemplate:126920<br class="gmail_msg">
<br class="gmail_msg">
Modified: cfe/branches/release_39/lib/CodeGen/CGStmtOpenMP.cpp<br class="gmail_msg">
URL: <a moz-do-not-send="true" href="http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/CodeGen/CGStmtOpenMP.cpp?rev=286968&r1=286967&r2=286968&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/CodeGen/CGStmtOpenMP.cpp?rev=286968&r1=286967&r2=286968&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- cfe/branches/release_39/lib/CodeGen/CGStmtOpenMP.cpp (original)<br class="gmail_msg">
+++ cfe/branches/release_39/lib/CodeGen/CGStmtOpenMP.cpp Tue Nov 15 08:26:49 2016<br class="gmail_msg">
@@ -1767,9 +1767,17 @@ void CodeGenFunction::EmitOMPOuterLoop(b<br class="gmail_msg">
EmitBlock(LoopExit.getBlock());<br class="gmail_msg">
<br class="gmail_msg">
// Tell the runtime we are done.<br class="gmail_msg">
- if (!DynamicOrOrdered)<br class="gmail_msg">
- RT.emitForStaticFinish(*this, S.getLocEnd());<br class="gmail_msg">
+ SourceLocation ELoc = S.getLocEnd();<br class="gmail_msg">
+ auto &&CodeGen = [DynamicOrOrdered, ELoc](CodeGenFunction &CGF) {<br class="gmail_msg">
+ if (!DynamicOrOrdered)<br class="gmail_msg">
+ CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, ELoc);<br class="gmail_msg">
+ };<br class="gmail_msg">
+ CodeGen(*this);<br class="gmail_msg">
<br class="gmail_msg">
+ OpenMPDirectiveKind DKind = S.getDirectiveKind();<br class="gmail_msg">
+ if (DKind == OMPD_for || DKind == OMPD_parallel_for ||<br class="gmail_msg">
+ DKind == OMPD_distribute_parallel_for)<br class="gmail_msg">
+ OMPCancelStack.back().CodeGen = CodeGen;<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
void CodeGenFunction::EmitOMPForOuterLoop(<br class="gmail_msg">
@@ -1881,6 +1889,7 @@ void CodeGenFunction::EmitOMPDistributeO<br class="gmail_msg">
void CodeGenFunction::EmitOMPDistributeParallelForDirective(<br class="gmail_msg">
const OMPDistributeParallelForDirective &S) {<br class="gmail_msg">
OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);<br class="gmail_msg">
+ OMPCancelStackRAII CancelRegion(*this);<br class="gmail_msg">
CGM.getOpenMPRuntime().emitInlinedDirective(<br class="gmail_msg">
*this, OMPD_distribute_parallel_for,<br class="gmail_msg">
[&S](CodeGenFunction &CGF, PrePostActionTy &) {<br class="gmail_msg">
@@ -2073,7 +2082,15 @@ bool CodeGenFunction::EmitOMPWorksharing<br class="gmail_msg">
[](CodeGenFunction &) {});<br class="gmail_msg">
EmitBlock(LoopExit.getBlock());<br class="gmail_msg">
// Tell the runtime we are done.<br class="gmail_msg">
- RT.emitForStaticFinish(*this, S.getLocStart());<br class="gmail_msg">
+ SourceLocation ELoc = S.getLocEnd();<br class="gmail_msg">
+ auto &&CodeGen = [ELoc](CodeGenFunction &CGF) {<br class="gmail_msg">
+ CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, ELoc);<br class="gmail_msg">
+ };<br class="gmail_msg">
+ CodeGen(*this);<br class="gmail_msg">
+ OpenMPDirectiveKind DKind = S.getDirectiveKind();<br class="gmail_msg">
+ if (DKind == OMPD_for || DKind == OMPD_parallel_for ||<br class="gmail_msg">
+ DKind == OMPD_distribute_parallel_for)<br class="gmail_msg">
+ OMPCancelStack.back().CodeGen = CodeGen;<br class="gmail_msg">
} else {<br class="gmail_msg">
const bool IsMonotonic =<br class="gmail_msg">
Ordered || ScheduleKind.Schedule == OMPC_SCHEDULE_static ||<br class="gmail_msg">
@@ -2127,6 +2144,7 @@ void CodeGenFunction::EmitOMPForDirectiv<br class="gmail_msg">
};<br class="gmail_msg">
{<br class="gmail_msg">
OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);<br class="gmail_msg">
+ OMPCancelStackRAII CancelRegion(*this);<br class="gmail_msg">
CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_for, CodeGen,<br class="gmail_msg">
S.hasCancel());<br class="gmail_msg">
}<br class="gmail_msg">
@@ -2263,7 +2281,12 @@ void CodeGenFunction::EmitSections(const<br class="gmail_msg">
CGF.EmitOMPInnerLoop(S, /*RequiresCleanup=*/false, &Cond, &Inc, BodyGen,<br class="gmail_msg">
[](CodeGenFunction &) {});<br class="gmail_msg">
// Tell the runtime we are done.<br class="gmail_msg">
- CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocStart());<br class="gmail_msg">
+ SourceLocation ELoc = S.getLocEnd();<br class="gmail_msg">
+ auto &&CodeGen = [ELoc](CodeGenFunction &CGF) {<br class="gmail_msg">
+ CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, ELoc);<br class="gmail_msg">
+ };<br class="gmail_msg">
+ CodeGen(CGF);<br class="gmail_msg">
+ CGF.OMPCancelStack.back().CodeGen = CodeGen;<br class="gmail_msg">
CGF.EmitOMPReductionClauseFinal(S);<br class="gmail_msg">
// Emit post-update of the reduction variables if IsLastIter != 0.<br class="gmail_msg">
emitPostUpdateForReductionClause(<br class="gmail_msg">
@@ -2301,6 +2324,7 @@ void CodeGenFunction::EmitSections(const<br class="gmail_msg">
void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) {<br class="gmail_msg">
{<br class="gmail_msg">
OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);<br class="gmail_msg">
+ OMPCancelStackRAII CancelRegion(*this);<br class="gmail_msg">
EmitSections(S);<br class="gmail_msg">
}<br class="gmail_msg">
// Emit an implicit barrier at the end.<br class="gmail_msg">
@@ -2388,6 +2412,7 @@ void CodeGenFunction::EmitOMPParallelFor<br class="gmail_msg">
// Emit directive as a combined directive that consists of two implicit<br class="gmail_msg">
// directives: 'parallel' with 'for' directive.<br class="gmail_msg">
auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &) {<br class="gmail_msg">
+ OMPCancelStackRAII CancelRegion(CGF);<br class="gmail_msg">
CGF.EmitOMPWorksharingLoop(S);<br class="gmail_msg">
};<br class="gmail_msg">
emitCommonOMPParallelDirective(*this, S, OMPD_for, CodeGen);<br class="gmail_msg">
@@ -2408,6 +2433,7 @@ void CodeGenFunction::EmitOMPParallelSec<br class="gmail_msg">
// Emit directive as a combined directive that consists of two implicit<br class="gmail_msg">
// directives: 'parallel' with 'sections' directive.<br class="gmail_msg">
auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &) {<br class="gmail_msg">
+ OMPCancelStackRAII CancelRegion(CGF);<br class="gmail_msg">
CGF.EmitSections(S);<br class="gmail_msg">
};<br class="gmail_msg">
emitCommonOMPParallelDirective(*this, S, OMPD_sections, CodeGen);<br class="gmail_msg">
@@ -3390,8 +3416,11 @@ CodeGenFunction::getOMPCancelDestination<br class="gmail_msg">
if (Kind == OMPD_parallel || Kind == OMPD_task)<br class="gmail_msg">
return ReturnBlock;<br class="gmail_msg">
assert(Kind == OMPD_for || Kind == OMPD_section || Kind == OMPD_sections ||<br class="gmail_msg">
- Kind == OMPD_parallel_sections || Kind == OMPD_parallel_for);<br class="gmail_msg">
- return BreakContinueStack.back().BreakBlock;<br class="gmail_msg">
+ Kind == OMPD_parallel_sections || Kind == OMPD_parallel_for ||<br class="gmail_msg">
+ Kind == OMPD_distribute_parallel_for);<br class="gmail_msg">
+ if (!OMPCancelStack.back().ExitBlock.isValid())<br class="gmail_msg">
+ OMPCancelStack.back().ExitBlock = getJumpDestInCurrentScope("cancel.exit");<br class="gmail_msg">
+ return OMPCancelStack.back().ExitBlock;<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
// Generate the instructions for '#pragma omp target data' directive.<br class="gmail_msg">
<br class="gmail_msg">
Modified: cfe/branches/release_39/lib/CodeGen/CodeGenFunction.h<br class="gmail_msg">
URL: <a moz-do-not-send="true" href="http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/CodeGen/CodeGenFunction.h?rev=286968&r1=286967&r2=286968&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/CodeGen/CodeGenFunction.h?rev=286968&r1=286967&r2=286968&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- cfe/branches/release_39/lib/CodeGen/CodeGenFunction.h (original)<br class="gmail_msg">
+++ cfe/branches/release_39/lib/CodeGen/CodeGenFunction.h Tue Nov 15 08:26:49 2016<br class="gmail_msg">
@@ -965,6 +965,35 @@ private:<br class="gmail_msg">
};<br class="gmail_msg">
SmallVector<BreakContinue, 8> BreakContinueStack;<br class="gmail_msg">
<br class="gmail_msg">
+ /// Data for exit block for proper support of OpenMP cancellation constructs.<br class="gmail_msg">
+ struct OMPCancel {<br class="gmail_msg">
+ JumpDest ExitBlock;<br class="gmail_msg">
+ llvm::function_ref<void(CodeGenFunction &CGF)> CodeGen;<br class="gmail_msg">
+ OMPCancel() : CodeGen([](CodeGenFunction &CGF) {}) {}<br class="gmail_msg">
+ };<br class="gmail_msg">
+ SmallVector<OMPCancel, 8> OMPCancelStack;<br class="gmail_msg">
+<br class="gmail_msg">
+ /// Controls insertion of cancellation exit blocks in worksharing constructs.<br class="gmail_msg">
+ class OMPCancelStackRAII {<br class="gmail_msg">
+ CodeGenFunction &CGF;<br class="gmail_msg">
+<br class="gmail_msg">
+ public:<br class="gmail_msg">
+ OMPCancelStackRAII(CodeGenFunction &CGF) : CGF(CGF) {<br class="gmail_msg">
+ CGF.OMPCancelStack.push_back({});<br class="gmail_msg">
+ }<br class="gmail_msg">
+ ~OMPCancelStackRAII() {<br class="gmail_msg">
+ if (CGF.HaveInsertPoint() &&<br class="gmail_msg">
+ CGF.OMPCancelStack.back().ExitBlock.isValid()) {<br class="gmail_msg">
+ auto CJD = CGF.getJumpDestInCurrentScope("cancel.cont");<br class="gmail_msg">
+ CGF.EmitBranchThroughCleanup(CJD);<br class="gmail_msg">
+ CGF.EmitBlock(CGF.OMPCancelStack.back().ExitBlock.getBlock());<br class="gmail_msg">
+ CGF.OMPCancelStack.back().CodeGen(CGF);<br class="gmail_msg">
+ CGF.EmitBranchThroughCleanup(CJD);<br class="gmail_msg">
+ CGF.EmitBlock(CJD.getBlock());<br class="gmail_msg">
+ }<br class="gmail_msg">
+ }<br class="gmail_msg">
+ };<br class="gmail_msg">
+<br class="gmail_msg">
CodeGenPGO PGO;<br class="gmail_msg">
<br class="gmail_msg">
/// Calculate branch weights appropriate for PGO data<br class="gmail_msg">
<br class="gmail_msg">
Modified: cfe/branches/release_39/test/OpenMP/cancel_codegen.cpp<br class="gmail_msg">
URL: <a moz-do-not-send="true" href="http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/OpenMP/cancel_codegen.cpp?rev=286968&r1=286967&r2=286968&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/OpenMP/cancel_codegen.cpp?rev=286968&r1=286967&r2=286968&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- cfe/branches/release_39/test/OpenMP/cancel_codegen.cpp (original)<br class="gmail_msg">
+++ cfe/branches/release_39/test/OpenMP/cancel_codegen.cpp Tue Nov 15 08:26:49 2016<br class="gmail_msg">
@@ -91,9 +91,11 @@ for (int i = 0; i < argc; ++i) {<br class="gmail_msg">
}<br class="gmail_msg">
}<br class="gmail_msg">
// CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(<br class="gmail_msg">
-#pragma omp parallel for<br class="gmail_msg">
+int r = 0;<br class="gmail_msg">
+#pragma omp parallel for reduction(+:r)<br class="gmail_msg">
for (int i = 0; i < argc; ++i) {<br class="gmail_msg">
#pragma omp cancel for<br class="gmail_msg">
+ r += i;<br class="gmail_msg">
}<br class="gmail_msg">
// CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(<br class="gmail_msg">
return argc;<br class="gmail_msg">
@@ -164,6 +166,9 @@ for (int i = 0; i < argc; ++i) {<br class="gmail_msg">
// CHECK: [[CONTINUE]]<br class="gmail_msg">
// CHECK: br label<br class="gmail_msg">
// CHECK: call void @__kmpc_for_static_fini(<br class="gmail_msg">
+// CHECK: call i32 @__kmpc_reduce_nowait(<br class="gmail_msg">
+// CHECK: call void @__kmpc_end_reduce_nowait(<br class="gmail_msg">
+// CHECK: call void @__kmpc_for_static_fini(<br class="gmail_msg">
// CHECK: ret void<br class="gmail_msg">
<br class="gmail_msg">
#endif<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
llvm-branch-commits mailing list<br class="gmail_msg">
<a moz-do-not-send="true" href="mailto:llvm-branch-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-branch-commits@lists.llvm.org</a><br class="gmail_msg">
<a moz-do-not-send="true" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits</a><br class="gmail_msg">
</blockquote>
</div>
</blockquote>
<br>
</body>
</html>