[clang] [clang][OpenMP] Move "loop" directive mapping from sema to codegen (PR #99905)
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 22 10:57:01 PDT 2024
================
@@ -3852,44 +3895,44 @@ static bool emitWorksharingDirective(CodeGenFunction &CGF,
OMPLoopScope LoopScope(CGF, S);
return CGF.EmitScalarExpr(S.getNumIterations());
};
- const auto &&FirstGen = [&S, HasCancel](CodeGenFunction &CGF) {
- CodeGenFunction::OMPCancelStackRAII CancelRegion(
- CGF, S.getDirectiveKind(), HasCancel);
+ const auto &&FirstGen = [&S, HasCancel, EKind](CodeGenFunction &CGF) {
+ CodeGenFunction::OMPCancelStackRAII CancelRegion(CGF, EKind, HasCancel);
(void)CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(),
emitForLoopBounds,
emitDispatchForLoopBounds);
// Emit an implicit barrier at the end.
CGF.CGM.getOpenMPRuntime().emitBarrierCall(CGF, S.getBeginLoc(),
OMPD_for);
};
- const auto &&SecondGen = [&S, HasCancel,
+ const auto &&SecondGen = [&S, HasCancel, EKind,
&HasLastprivates](CodeGenFunction &CGF) {
- CodeGenFunction::OMPCancelStackRAII CancelRegion(
- CGF, S.getDirectiveKind(), HasCancel);
+ CodeGenFunction::OMPCancelStackRAII CancelRegion(CGF, EKind, HasCancel);
HasLastprivates = CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(),
emitForLoopBounds,
emitDispatchForLoopBounds);
};
- if (!isOpenMPParallelDirective(S.getDirectiveKind()))
+ if (!isOpenMPParallelDirective(EKind))
emitScanBasedDirectiveDecls(CGF, S, NumIteratorsGen);
emitScanBasedDirective(CGF, S, NumIteratorsGen, FirstGen, SecondGen);
- if (!isOpenMPParallelDirective(S.getDirectiveKind()))
+ if (!isOpenMPParallelDirective(EKind))
emitScanBasedDirectiveFinals(CGF, S, NumIteratorsGen);
} else {
- CodeGenFunction::OMPCancelStackRAII CancelRegion(CGF, S.getDirectiveKind(),
- HasCancel);
+ CodeGenFunction::OMPCancelStackRAII CancelRegion(CGF, EKind, HasCancel);
HasLastprivates = CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(),
emitForLoopBounds,
emitDispatchForLoopBounds);
}
return HasLastprivates;
}
-static bool isSupportedByOpenMPIRBuilder(const OMPForDirective &S) {
- if (S.hasCancel())
+// Pass OMPLoopDirective (instead of OMPForDirective) to make this check
+// available for "loop bind(parallel)", which maps to "for".
+static bool isForSupportedByOpenMPIRBuilder(const OMPLoopDirective &S,
+ bool HasCancel) {
+ if (HasCancel)
return false;
for (OMPClause *C : S.clauses()) {
- if (isa<OMPNowaitClause>(C))
+ if (isa<OMPNowaitClause>(C) || isa<OMPBindClause>(C))
----------------
alexey-bataev wrote:
```suggestion
if (isa<OMPNowaitClause, OMPBindClause>(C))
```
https://github.com/llvm/llvm-project/pull/99905
More information about the cfe-commits
mailing list