<div dir="ltr">LGTM.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 23, 2015 at 5:08 AM, Alexey Bataev <span dir="ltr"><<a href="mailto:a.bataev@hotmail.com" target="_blank">a.bataev@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi rjmccall, hfinkel,<br>
<br>
Runtime function for 'copyprivate' directive generates implicit barriers, so no need to emit it.<br>
<br>
<a href="http://reviews.llvm.org/D9215" target="_blank">http://reviews.llvm.org/D9215</a><br>
<br>
Files:<br>
  lib/CodeGen/CGStmtOpenMP.cpp<br>
  test/OpenMP/single_codegen.cpp<br>
<br>
Index: test/OpenMP/single_codegen.cpp<br>
===================================================================<br>
--- test/OpenMP/single_codegen.cpp<br>
+++ test/OpenMP/single_codegen.cpp<br>
@@ -51,13 +51,24 @@<br>
 // CHECK-NEXT:  call void @__kmpc_end_single([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])<br>
 // CHECK-NEXT:  br label {{%?}}[[EXIT]]<br>
 // CHECK:       [[EXIT]]<br>
-// CHECK-NOT:   __kmpc_cancel_barrier<br>
+// CHECK-NOT:   call {{.+}} @__kmpc_cancel_barrier<br>
 #pragma omp single nowait<br>
   a = 2;<br>
 // CHECK:       [[RES:%.+]] = call i32 @__kmpc_single([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])<br>
 // CHECK-NEXT:  [[IS_SINGLE:%.+]] = icmp ne i32 [[RES]], 0<br>
 // CHECK-NEXT:  br i1 [[IS_SINGLE]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]<br>
 // CHECK:       [[THEN]]<br>
+// CHECK-NEXT:  store i8 2, i8* [[A_ADDR]]<br>
+// CHECK-NEXT:  call void @__kmpc_end_single([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])<br>
+// CHECK-NEXT:  br label {{%?}}[[EXIT]]<br>
+// CHECK:       [[EXIT]]<br>
+// CHECK:       call{{.*}} @__kmpc_cancel_barrier([[IDENT_T_TY]]* [[IMPLICIT_BARRIER_SINGLE_LOC]], i32 [[GTID]])<br>
+#pragma omp single<br>
+  a = 2;<br>
+// CHECK:       [[RES:%.+]] = call i32 @__kmpc_single([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])<br>
+// CHECK-NEXT:  [[IS_SINGLE:%.+]] = icmp ne i32 [[RES]], 0<br>
+// CHECK-NEXT:  br i1 [[IS_SINGLE]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]<br>
+// CHECK:       [[THEN]]<br>
 // CHECK-NEXT:  invoke void [[FOO]]()<br>
 // CHECK:       to label {{%?}}[[CONT:.+]] unwind<br>
 // CHECK:       [[CONT]]<br>
@@ -86,7 +97,7 @@<br>
 // CHECK:       [[COPY_LIST_VOID_PTR:%.+]] = bitcast [5 x i8*]* [[COPY_LIST]] to i8*<br>
 // CHECK:       [[DID_IT_VAL:%.+]] = load i32, i32* [[DID_IT]],<br>
 // CHECK:       call void @__kmpc_copyprivate([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], i32 40, i8* [[COPY_LIST_VOID_PTR]], void (i8*, i8*)* [[COPY_FUNC:@.+]], i32 [[DID_IT_VAL]])<br>
-// CHECK:       call{{.*}} @__kmpc_cancel_barrier([[IDENT_T_TY]]* [[IMPLICIT_BARRIER_SINGLE_LOC]], i32 [[GTID]])<br>
+// CHECK-NOT:   call {{.+}} @__kmpc_cancel_barrier<br>
 #pragma omp single copyprivate(a, c, tc, a2, tc2)<br>
   foo();<br>
 // CHECK-NOT:   call i32 @__kmpc_single<br>
Index: lib/CodeGen/CGStmtOpenMP.cpp<br>
===================================================================<br>
--- lib/CodeGen/CGStmtOpenMP.cpp<br>
+++ lib/CodeGen/CGStmtOpenMP.cpp<br>
@@ -1251,8 +1251,9 @@<br>
   CGM.getOpenMPRuntime().emitSingleRegion(*this, CodeGen, S.getLocStart(),<br>
                                           CopyprivateVars, DestExprs, SrcExprs,<br>
                                           AssignmentOps);<br>
-  // Emit an implicit barrier at the end.<br>
-  if (!S.getSingleClause(OMPC_nowait)) {<br>
+  // Emit an implicit barrier at the end (if no 'nowait' clause and no<br>
+  // 'copyprivate' clause).<br>
+  if (!S.getSingleClause(OMPC_nowait) && CopyprivateVars.empty()) {<br>
     CGM.getOpenMPRuntime().emitBarrierCall(*this, S.getLocStart(), OMPD_single);<br>
   }<br>
 }<br>
<br>
EMAIL PREFERENCES<br>
  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">I suppose you'd like my real thoughts as well.</div>
</div>