[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
================
@@ -2534,21 +2563,24 @@ static void emitCommonSimdLoop(CodeGenFunction &CGF, const OMPLoopDirective &S,
static void emitOMPSimdRegion(CodeGenFunction &CGF, const OMPLoopDirective &S,
PrePostActionTy &Action) {
Action.Enter(CGF);
- assert(isOpenMPSimdDirective(S.getDirectiveKind()) &&
- "Expected simd directive");
OMPLoopScope PreInitScope(CGF, S);
// if (PreCond) {
// for (IV in 0..LastIteration) BODY;
// <Final counter/linear vars updates>;
// }
- //
- if (isOpenMPDistributeDirective(S.getDirectiveKind()) ||
- isOpenMPWorksharingDirective(S.getDirectiveKind()) ||
- isOpenMPTaskLoopDirective(S.getDirectiveKind())) {
- (void)EmitOMPHelperVar(CGF, cast<DeclRefExpr>(S.getLowerBoundVariable()));
- (void)EmitOMPHelperVar(CGF, cast<DeclRefExpr>(S.getUpperBoundVariable()));
+
+ // The presence of lower/upper bound variable depends on the actual directive
+ // kind in the AST node. The variables must be emitted because some of the
+ // expressions associated with the loop will use them.
+ OpenMPDirectiveKind DKind = S.getDirectiveKind();
+ if (isOpenMPDistributeDirective(DKind) ||
+ isOpenMPWorksharingDirective(DKind) || isOpenMPTaskLoopDirective(DKind) ||
+ isOpenMPGenericLoopDirective(DKind)) {
+ EmitOMPHelperVar(CGF, cast<DeclRefExpr>(S.getLowerBoundVariable()));
+ EmitOMPHelperVar(CGF, cast<DeclRefExpr>(S.getUpperBoundVariable()));
----------------
alexey-bataev wrote:
```suggestion
(void)EmitOMPHelperVar(CGF, cast<DeclRefExpr>(S.getLowerBoundVariable()));
(void)EmitOMPHelperVar(CGF, cast<DeclRefExpr>(S.getUpperBoundVariable()));
```
https://github.com/llvm/llvm-project/pull/99905
More information about the cfe-commits
mailing list