Skip to content

Commit d7c69c2

Browse files
authored
[clang][OpenMP] Add codegen for scope directive (#109197)
Added codegen for scope directive, enabled allocate and firstprivate clauses, and added scope directive LIT test. Testing - LIT tests (including new scope test). - OpenMP scope example test from 5.2 OpenMP API examples document. - Three executable scope tests from OpenMP_VV/sollve_vv suite.
1 parent 02d34d8 commit d7c69c2

File tree

6 files changed

+2297
-9
lines changed

6 files changed

+2297
-9
lines changed

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs) {
420420
CGM.ErrorUnsupported(S, "OpenMP dispatch directive");
421421
break;
422422
case Stmt::OMPScopeDirectiveClass:
423-
CGM.ErrorUnsupported(S, "scope with FE outlining");
423+
EmitOMPScopeDirective(cast<OMPScopeDirective>(*S));
424424
break;
425425
case Stmt::OMPMaskedDirectiveClass:
426426
EmitOMPMaskedDirective(cast<OMPMaskedDirective>(*S));

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4223,6 +4223,32 @@ void CodeGenFunction::EmitSections(const OMPExecutableDirective &S) {
42234223
}
42244224
}
42254225

4226+
void CodeGenFunction::EmitOMPScopeDirective(const OMPScopeDirective &S) {
4227+
{
4228+
// Emit code for 'scope' region
4229+
auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
4230+
Action.Enter(CGF);
4231+
OMPPrivateScope PrivateScope(CGF);
4232+
(void)CGF.EmitOMPFirstprivateClause(S, PrivateScope);
4233+
CGF.EmitOMPPrivateClause(S, PrivateScope);
4234+
CGF.EmitOMPReductionClauseInit(S, PrivateScope);
4235+
(void)PrivateScope.Privatize();
4236+
CGF.EmitStmt(S.getInnermostCapturedStmt()->getCapturedStmt());
4237+
CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_parallel);
4238+
};
4239+
auto LPCRegion =
4240+
CGOpenMPRuntime::LastprivateConditionalRAII::disable(*this, S);
4241+
OMPLexicalScope Scope(*this, S, OMPD_unknown);
4242+
CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_scope, CodeGen);
4243+
}
4244+
// Emit an implicit barrier at the end.
4245+
if (!S.getSingleClause<OMPNowaitClause>()) {
4246+
CGM.getOpenMPRuntime().emitBarrierCall(*this, S.getBeginLoc(), OMPD_scope);
4247+
}
4248+
// Check for outer lastprivate conditional update.
4249+
checkForLastprivateConditionalUpdate(*this, S);
4250+
}
4251+
42264252
void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) {
42274253
if (CGM.getLangOpts().OpenMPIRBuilder) {
42284254
llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3823,6 +3823,7 @@ class CodeGenFunction : public CodeGenTypeCache {
38233823
void EmitOMPInterchangeDirective(const OMPInterchangeDirective &S);
38243824
void EmitOMPForDirective(const OMPForDirective &S);
38253825
void EmitOMPForSimdDirective(const OMPForSimdDirective &S);
3826+
void EmitOMPScopeDirective(const OMPScopeDirective &S);
38263827
void EmitOMPSectionsDirective(const OMPSectionsDirective &S);
38273828
void EmitOMPSectionDirective(const OMPSectionDirective &S);
38283829
void EmitOMPSingleDirective(const OMPSingleDirective &S);

clang/test/OpenMP/error_unsupport_feature.c

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)