@@ -456,7 +456,7 @@ void CodeGenFunction::EmitCilkSyncStmt(const CilkSyncStmt &S) {
456
456
void CodeGenFunction::EmitCilkScopeStmt (const CilkScopeStmt &S) {
457
457
LexicalScope CilkScope (*this , S.getSourceRange ());
458
458
459
- // If this _Cilk_scope is outermost in the function, emit
459
+ // If this cilk_scope is outermost in the function, emit
460
460
// tapir_runtime_{start,end} intrinsics around the scope.
461
461
bool ThisScopeIsOutermost = false ;
462
462
if (!WithinCilkScope) {
@@ -471,22 +471,24 @@ void CodeGenFunction::EmitCilkScopeStmt(const CilkScopeStmt &S) {
471
471
if (ThisScopeIsOutermost && !CurSyncRegion) {
472
472
llvm::Instruction *TapirRTStart = Builder.CreateCall (
473
473
CGM.getIntrinsic (llvm::Intrinsic::tapir_runtime_start));
474
- // Mark the end of the _Cilk_scope with tapir_runtime_end.
474
+ // Mark the end of the cilk_scope with tapir_runtime_end.
475
475
EHStack.pushCleanup <TapirRuntimeEndCleanup>(NormalAndEHCleanup,
476
476
TapirRTStart);
477
477
}
478
478
// Create a nested synced scope.
479
- SyncRegionRAII SyncReg (*this );
480
- bool BodyIsCompoundStmt = isa<CompoundStmt>(S.getBody ());
481
- if (BodyIsCompoundStmt)
479
+ if (isa<CompoundStmt>(S.getBody ())) {
480
+ SyncRegionRAII SyncReg (*this );
482
481
ScopeIsSynced = true ;
483
-
484
- // Emit the spawned statement.
485
- EmitStmt (S.getBody ());
482
+ EmitStmt (S.getBody ());
483
+ } else {
484
+ PushSyncRegion ()->addImplicitSync ();
485
+ EmitStmt (S.getBody ());
486
+ PopSyncRegion ();
487
+ }
486
488
}
487
489
488
- // If this _Cilk_scope is outermost in the function, mark that CodeGen is no
489
- // longer emitting within a _Cilk_scope .
490
+ // If this cilk_scope is outermost in the function, mark that CodeGen is no
491
+ // longer emitting within a cilk_scope .
490
492
if (ThisScopeIsOutermost)
491
493
WithinCilkScope = false ;
492
494
}
0 commit comments