[clang] [llvm] [OpenMP] Add support for '#pragma omp stripe'. (PR #119891)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 13 07:53:12 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff bc28be0a428020ea803c94adb4df48ee4972e9f1 378bc7a1929930b5741b5ed2d37895d439b2c9e7 --extensions cpp,h -- clang/test/OpenMP/stripe_ast_print.cpp clang/test/OpenMP/stripe_codegen.cpp clang/test/OpenMP/stripe_codegen_for_dependent.cpp clang/test/OpenMP/stripe_messages.cpp clang/include/clang-c/Index.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/AST/StmtOpenMP.h clang/include/clang/Sema/SemaOpenMP.h clang/include/clang/Serialization/ASTBitCodes.h clang/lib/AST/StmtOpenMP.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/Basic/OpenMPKinds.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaExceptionSpec.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/lib/StaticAnalyzer/Core/ExprEngine.cpp clang/tools/libclang/CIndex.cpp clang/tools/libclang/CXCursor.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp
index 26da214f38..ad067d8fd3 100644
--- a/clang/lib/Sema/SemaExceptionSpec.cpp
+++ b/clang/lib/Sema/SemaExceptionSpec.cpp
@@ -1467,7 +1467,8 @@ CanThrowResult Sema::canThrow(const Stmt *S) {
   case Stmt::OMPSectionDirectiveClass:
   case Stmt::OMPSectionsDirectiveClass:
   case Stmt::OMPSimdDirectiveClass:
-  case Stmt::OMPTileDirectiveClass:OMPStripeDirectiveClass:
+  case Stmt::OMPTileDirectiveClass:
+  OMPStripeDirectiveClass:
   case Stmt::OMPUnrollDirectiveClass:
   case Stmt::OMPReverseDirectiveClass:
   case Stmt::OMPInterchangeDirectiveClass:
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 762b20465f..58a9df589a 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -14485,9 +14485,9 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses,
 }
 
 StmtResult SemaOpenMP::ActOnOpenMPStripeDirective(ArrayRef<OMPClause *> Clauses,
-                                                Stmt *AStmt,
-                                                SourceLocation StartLoc,
-                                                SourceLocation EndLoc) {
+                                                  Stmt *AStmt,
+                                                  SourceLocation StartLoc,
+                                                  SourceLocation EndLoc) {
   ASTContext &Context = getASTContext();
   Scope *CurScope = SemaRef.getCurScope();
 
@@ -14506,14 +14506,14 @@ StmtResult SemaOpenMP::ActOnOpenMPStripeDirective(ArrayRef<OMPClause *> Clauses,
   SmallVector<OMPLoopBasedDirective::HelperExprs, 4> LoopHelpers(NumLoops);
   Stmt *Body = nullptr;
   SmallVector<SmallVector<Stmt *, 0>, 4> OriginalInits;
-  if (!checkTransformableLoopNest(OMPD_stripe, AStmt, NumLoops, LoopHelpers, Body,
-                                  OriginalInits))
+  if (!checkTransformableLoopNest(OMPD_stripe, AStmt, NumLoops, LoopHelpers,
+                                  Body, OriginalInits))
     return StmtError();
 
   // Delay tiling to when template is completely instantiated.
   if (SemaRef.CurContext->isDependentContext())
     return OMPStripeDirective::Create(Context, StartLoc, EndLoc, Clauses,
-                                    NumLoops, AStmt, nullptr, nullptr);
+                                      NumLoops, AStmt, nullptr, nullptr);
 
   assert(LoopHelpers.size() == NumLoops &&
          "Expecting loop iteration space dimensionality to match number of "
@@ -14574,8 +14574,8 @@ StmtResult SemaOpenMP::ActOnOpenMPStripeDirective(ArrayRef<OMPClause *> Clauses,
   // Once the original iteration values are set, append the innermost body.
   Stmt *Inner = Body;
 
-  auto MakeDimStripeSize = [&SemaRef = this->SemaRef, &CopyTransformer, &Context,
-                          SizesClause, CurScope](int I) -> Expr * {
+  auto MakeDimStripeSize = [&SemaRef = this->SemaRef, &CopyTransformer,
+                            &Context, SizesClause, CurScope](int I) -> Expr * {
     Expr *DimStripeSizeExpr = SizesClause->getSizesRefs()[I];
     if (isa<ConstantExpr>(DimStripeSizeExpr))
       return AssertSuccess(CopyTransformer.TransformExpr(DimStripeSizeExpr));
@@ -14588,9 +14588,9 @@ StmtResult SemaOpenMP::ActOnOpenMPStripeDirective(ArrayRef<OMPClause *> Clauses,
     //   for (int i = 0; i < 42; ++i)
     //     body(i);
     // \endcode
-    // Although there is no meaningful interpretation of the stripe size, the body
-    // should still be executed 42 times to avoid surprises. To preserve the
-    // invariant that every loop iteration is executed exactly once and not
+    // Although there is no meaningful interpretation of the stripe size, the
+    // body should still be executed 42 times to avoid surprises. To preserve
+    // the invariant that every loop iteration is executed exactly once and not
     // cause an infinite loop, apply a minimum stripe size of one.
     // Build expr:
     // \code{c}
@@ -14624,7 +14624,7 @@ StmtResult SemaOpenMP::ActOnOpenMPStripeDirective(ArrayRef<OMPClause *> Clauses,
     // node object must appear at most once, hence we define lamdas that create
     // a new AST node at every use.
     auto MakeStripeIVRef = [&SemaRef = this->SemaRef, &StripeIndVars, I, IVTy,
-                          OrigCntVar]() {
+                            OrigCntVar]() {
       return buildDeclRefExpr(SemaRef, StripeIndVars[I], IVTy,
                               OrigCntVar->getExprLoc());
     };
@@ -14636,7 +14636,8 @@ StmtResult SemaOpenMP::ActOnOpenMPStripeDirective(ArrayRef<OMPClause *> Clauses,
 
     // For init-statement: auto .stripe.iv = .floor.iv
     SemaRef.AddInitializerToDecl(
-        StripeIndVars[I], SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(),
+        StripeIndVars[I],
+        SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(),
         /*DirectInit=*/false);
     Decl *CounterDecl = StripeIndVars[I];
     StmtResult InitStmt = new (Context)
@@ -14751,9 +14752,9 @@ StmtResult SemaOpenMP::ActOnOpenMPStripeDirective(ArrayRef<OMPClause *> Clauses,
                 LoopHelper.Init->getBeginLoc(), LoopHelper.Inc->getEndLoc());
   }
 
-  return OMPStripeDirective::Create(Context, StartLoc, EndLoc, Clauses, NumLoops,
-                                  AStmt, Inner,
-                                  buildPreInits(Context, PreInits));
+  return OMPStripeDirective::Create(Context, StartLoc, EndLoc, Clauses,
+                                    NumLoops, AStmt, Inner,
+                                    buildPreInits(Context, PreInits));
 }
 
 StmtResult SemaOpenMP::ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses,

``````````

</details>


https://github.com/llvm/llvm-project/pull/119891


More information about the llvm-commits mailing list