[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 15 09:41:49 PST 2023


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 ec64af5994213cf7933e961a2b7fe07193a77b61 8710c48fb90373ebd2afe1afa7399a6643b52c37 -- clang/test/OpenMP/target_teams_generic_loop_codegen_as_distribute.cpp clang/test/OpenMP/target_teams_generic_loop_codegen_as_parallel_for.cpp clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/nvptx_target_teams_generic_loop_codegen.cpp clang/test/OpenMP/nvptx_target_teams_generic_loop_generic_mode_codegen.cpp clang/test/OpenMP/target_teams_generic_loop_codegen-1.cpp clang/test/OpenMP/target_teams_generic_loop_codegen.cpp clang/test/OpenMP/target_teams_generic_loop_collapse_codegen.cpp clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp clang/test/OpenMP/target_teams_generic_loop_private_codegen.cpp clang/test/OpenMP/target_teams_generic_loop_uses_allocators_codegen.cpp clang/test/OpenMP/teams_generic_loop_codegen-1.cpp clang/test/OpenMP/teams_generic_loop_codegen.cpp clang/test/OpenMP/teams_generic_loop_collapse_codegen.cpp clang/test/OpenMP/teams_generic_loop_private_codegen.cpp clang/test/OpenMP/teams_generic_loop_reduction_codegen.cpp
``````````

</details>

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

``````````diff
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 97f963df7a..9545a5e3bd 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2645,11 +2645,11 @@ void CGOpenMPRuntime::emitForStaticFinish(CodeGenFunction &CGF,
   llvm::Value *Args[] = {
       emitUpdateLocation(CGF, Loc,
                          isOpenMPDistributeDirective(DKind) ||
-                         (DKind == OMPD_target_teams_loop)
+                                 (DKind == OMPD_target_teams_loop)
                              ? OMP_IDENT_WORK_DISTRIBUTE
-                             : isOpenMPLoopDirective(DKind)
-                                   ? OMP_IDENT_WORK_LOOP
-                                   : OMP_IDENT_WORK_SECTIONS),
+                         : isOpenMPLoopDirective(DKind)
+                             ? OMP_IDENT_WORK_LOOP
+                             : OMP_IDENT_WORK_SECTIONS),
       getThreadID(CGF, Loc)};
   auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
   if (isOpenMPDistributeDirective(DKind) &&
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 16f84cab18..229f015e04 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -7924,9 +7924,9 @@ static void emitTargetTeamsGenericLoopRegionAsParallel(
     CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_teams);
   };
   DEBUG_WITH_TYPE(TTL_CODEGEN_TYPE,
-      CGF.CGM.emitTargetTeamsLoopCodegenStatus(
-          TTL_CODEGEN_TYPE " as parallel for", S,
-          CGF.CGM.getLangOpts().OpenMPIsTargetDevice));
+                  CGF.CGM.emitTargetTeamsLoopCodegenStatus(
+                      TTL_CODEGEN_TYPE " as parallel for", S,
+                      CGF.CGM.getLangOpts().OpenMPIsTargetDevice));
   emitCommonOMPTeamsDirective(CGF, S, OMPD_distribute_parallel_for,
                               CodeGenTeams);
   emitPostUpdateForReductionClause(CGF, S,
@@ -7954,9 +7954,9 @@ static void emitTargetTeamsGenericLoopRegionAsDistribute(
     CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_teams);
   };
   DEBUG_WITH_TYPE(TTL_CODEGEN_TYPE,
-      CGF.CGM.emitTargetTeamsLoopCodegenStatus(
-          TTL_CODEGEN_TYPE " as distribute", S,
-          CGF.CGM.getLangOpts().OpenMPIsTargetDevice));
+                  CGF.CGM.emitTargetTeamsLoopCodegenStatus(
+                      TTL_CODEGEN_TYPE " as distribute", S,
+                      CGF.CGM.getLangOpts().OpenMPIsTargetDevice));
   emitCommonOMPTeamsDirective(CGF, S, OMPD_distribute, CodeGen);
   emitPostUpdateForReductionClause(CGF, S,
                                    [](CodeGenFunction &) { return nullptr; });
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 0dd389b3a8..ae287c7c68 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -7492,9 +7492,7 @@ class TeamsLoopChecker final : public ConstStmtVisitor<TeamsLoopChecker> {
 public:
   TeamsLoopChecker(CodeGenModule &CGM)
       : CGM(CGM), TeamsLoopCanBeParallelFor{true} {}
-  bool teamsLoopCanBeParallelFor() const {
-    return TeamsLoopCanBeParallelFor;
-  }
+  bool teamsLoopCanBeParallelFor() const { return TeamsLoopCanBeParallelFor; }
   // Is there a nested OpenMP loop bind(parallel)
   void VisitOMPExecutableDirective(const OMPExecutableDirective *D) {
     if (D->getDirectiveKind() == llvm::omp::Directive::OMPD_loop) {
@@ -7557,7 +7555,7 @@ bool CodeGenModule::teamsLoopCanBeParallelFor(const OMPExecutableDirective &D) {
   if (D.getDirectiveKind() != llvm::omp::Directive::OMPD_target_teams_loop)
     return false;
   assert(D.hasAssociatedStmt() &&
-      "Loop directive must have associated statement.");
+         "Loop directive must have associated statement.");
   TeamsLoopChecker Checker(*this);
   Checker.Visit(D.getAssociatedStmt());
   return Checker.teamsLoopCanBeParallelFor();

``````````

</details>


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


More information about the cfe-commits mailing list