diff options
Diffstat (limited to 'clang/lib/CodeGen/CGStmtOpenMP.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 245fed01e52..c83dfa17064 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -23,20 +23,6 @@ using namespace CodeGen; //===----------------------------------------------------------------------===// // OpenMP Directive Emission //===----------------------------------------------------------------------===// -namespace { -/// \brief RAII for inlined OpenMP regions (like 'omp for', 'omp simd', 'omp -/// critical' etc.). Helps to generate proper debug info and provides correct -/// code generation for such constructs. -class InlinedOpenMPRegionScopeRAII { - InlinedOpenMPRegionRAII Region; - CodeGenFunction::LexicalScope DirectiveScope; - -public: - InlinedOpenMPRegionScopeRAII(CodeGenFunction &CGF, - const OMPExecutableDirective &D) - : Region(CGF, D), DirectiveScope(CGF, D.getSourceRange()) {} -}; -} // namespace /// \brief Emits code for OpenMP 'if' clause using specified \a CodeGen /// function. Here is the logic: @@ -431,7 +417,12 @@ void CodeGenFunction::EmitOMPSimdDirective(const OMPSimdDirective &S) { } } - InlinedOpenMPRegionScopeRAII Region(*this, S); + InlinedOpenMPRegionRAII Region(*this, S); + RunCleanupsScope DirectiveScope(*this); + + CGDebugInfo *DI = getDebugInfo(); + if (DI) + DI->EmitLexicalBlockStart(Builder, S.getSourceRange().getBegin()); // Emit the loop iteration variable. const Expr *IVExpr = S.getIterationVariable(); @@ -475,6 +466,9 @@ void CodeGenFunction::EmitOMPSimdDirective(const OMPSimdDirective &S) { } EmitOMPSimdFinal(S); } + + if (DI) + DI->EmitLexicalBlockEnd(Builder, S.getSourceRange().getEnd()); } void CodeGenFunction::EmitOMPForOuterLoop(OpenMPScheduleClauseKind ScheduleKind, @@ -656,13 +650,20 @@ void CodeGenFunction::EmitOMPWorksharingLoop(const OMPLoopDirective &S) { } void CodeGenFunction::EmitOMPForDirective(const OMPForDirective &S) { - InlinedOpenMPRegionScopeRAII Region(*this, S); + InlinedOpenMPRegionRAII Region(*this, S); + RunCleanupsScope DirectiveScope(*this); + + CGDebugInfo *DI = getDebugInfo(); + if (DI) + DI->EmitLexicalBlockStart(Builder, S.getSourceRange().getBegin()); EmitOMPWorksharingLoop(S); // Emit an implicit barrier at the end. CGM.getOpenMPRuntime().emitBarrierCall(*this, S.getLocStart(), /*IsExplicit*/ false); + if (DI) + DI->EmitLexicalBlockEnd(Builder, S.getSourceRange().getEnd()); } void CodeGenFunction::EmitOMPForSimdDirective(const OMPForSimdDirective &) { @@ -679,7 +680,8 @@ void CodeGenFunction::EmitOMPSectionDirective(const OMPSectionDirective &) { void CodeGenFunction::EmitOMPSingleDirective(const OMPSingleDirective &S) { CGM.getOpenMPRuntime().emitSingleRegion(*this, [&]() -> void { - InlinedOpenMPRegionScopeRAII Region(*this, S); + InlinedOpenMPRegionRAII Region(*this, S); + RunCleanupsScope Scope(*this); EmitStmt(cast<CapturedStmt>(S.getAssociatedStmt())->getCapturedStmt()); EnsureInsertPoint(); }, S.getLocStart()); @@ -687,7 +689,8 @@ void CodeGenFunction::EmitOMPSingleDirective(const OMPSingleDirective &S) { void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { CGM.getOpenMPRuntime().emitMasterRegion(*this, [&]() -> void { - InlinedOpenMPRegionScopeRAII Region(*this, S); + InlinedOpenMPRegionRAII Region(*this, S); + RunCleanupsScope Scope(*this); EmitStmt(cast<CapturedStmt>(S.getAssociatedStmt())->getCapturedStmt()); EnsureInsertPoint(); }, S.getLocStart()); @@ -696,7 +699,8 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { void CodeGenFunction::EmitOMPCriticalDirective(const OMPCriticalDirective &S) { CGM.getOpenMPRuntime().emitCriticalRegion( *this, S.getDirectiveName().getAsString(), [&]() -> void { - InlinedOpenMPRegionScopeRAII Region(*this, S); + InlinedOpenMPRegionRAII Region(*this, S); + RunCleanupsScope Scope(*this); EmitStmt(cast<CapturedStmt>(S.getAssociatedStmt())->getCapturedStmt()); EnsureInsertPoint(); }, S.getLocStart()); @@ -894,7 +898,6 @@ void CodeGenFunction::EmitOMPAtomicDirective(const OMPAtomicDirective &S) { break; } } - InlinedOpenMPRegionScopeRAII Region(*this, S); EmitOMPAtomicExpr(*this, Kind, IsSeqCst, S.getX(), S.getV(), S.getExpr(), S.getLocStart()); } |