Skip to content

[flang][Lower][OpenMP] Don't read moldarg for static sized array #125901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2025

Conversation

tblah
Copy link
Contributor

@tblah tblah commented Feb 5, 2025

This should further reduce the number of spurious barriers

@tblah tblah requested review from ergawy and luporl February 5, 2025 18:02
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir flang:openmp labels Feb 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 5, 2025

@llvm/pr-subscribers-flang-openmp

@llvm/pr-subscribers-flang-fir-hlfir

Author: Tom Eccles (tblah)

Changes

This should further reduce the number of spurious barriers


Full diff: https://github.com/llvm/llvm-project/pull/125901.diff

4 Files Affected:

  • (modified) flang/lib/Lower/OpenMP/DataSharingProcessor.cpp (+3-2)
  • (modified) flang/lib/Lower/OpenMP/PrivateReductionUtils.cpp (+41-20)
  • (modified) flang/lib/Lower/OpenMP/PrivateReductionUtils.h (+4-2)
  • (modified) flang/test/Lower/OpenMP/delayed-privatization-array.f90 (+3-4)
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index 55f543ca38178d..800d332b74e318 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -508,6 +508,8 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
 
   lower::SymbolBox hsb = converter.lookupOneLevelUpSymbol(*sym);
   assert(hsb && "Host symbol box not found");
+  hlfir::Entity entity{hsb.getAddr()};
+  bool cannotHaveNonDefaultLowerBounds = !entity.mayHaveNonDefaultLowerBounds();
 
   mlir::Location symLoc = hsb.getAddr().getLoc();
   std::string privatizerName = sym->name().ToString() + ".privatizer";
@@ -528,7 +530,6 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
   // an alloca for a fir.array type there. Get around this by boxing all
   // arrays.
   if (mlir::isa<fir::SequenceType>(allocType)) {
-    hlfir::Entity entity{hsb.getAddr()};
     entity = genVariableBox(symLoc, firOpBuilder, entity);
     privVal = entity.getBase();
     allocType = privVal.getType();
@@ -590,7 +591,7 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
           result.getDeallocRegion(),
           isFirstPrivate ? DeclOperationKind::FirstPrivate
                          : DeclOperationKind::Private,
-          sym);
+          sym, cannotHaveNonDefaultLowerBounds);
       // TODO: currently there are false positives from dead uses of the mold
       // arg
       if (!result.getInitMoldArg().getUses().empty())
diff --git a/flang/lib/Lower/OpenMP/PrivateReductionUtils.cpp b/flang/lib/Lower/OpenMP/PrivateReductionUtils.cpp
index 951293b133677d..e970968eb72887 100644
--- a/flang/lib/Lower/OpenMP/PrivateReductionUtils.cpp
+++ b/flang/lib/Lower/OpenMP/PrivateReductionUtils.cpp
@@ -122,25 +122,40 @@ static void createCleanupRegion(Fortran::lower::AbstractConverter &converter,
   typeError();
 }
 
-fir::ShapeShiftOp Fortran::lower::omp::getShapeShift(fir::FirOpBuilder &builder,
-                                                     mlir::Location loc,
-                                                     mlir::Value box) {
+fir::ShapeShiftOp
+Fortran::lower::omp::getShapeShift(fir::FirOpBuilder &builder,
+                                   mlir::Location loc, mlir::Value box,
+                                   bool cannotHaveNonDefaultLowerBounds) {
   fir::SequenceType sequenceType = mlir::cast<fir::SequenceType>(
       hlfir::getFortranElementOrSequenceType(box.getType()));
   const unsigned rank = sequenceType.getDimension();
+
   llvm::SmallVector<mlir::Value> lbAndExtents;
   lbAndExtents.reserve(rank * 2);
-
   mlir::Type idxTy = builder.getIndexType();
-  for (unsigned i = 0; i < rank; ++i) {
-    // TODO: ideally we want to hoist box reads out of the critical section.
-    // We could do this by having box dimensions in block arguments like
-    // OpenACC does
-    mlir::Value dim = builder.createIntegerConstant(loc, idxTy, i);
-    auto dimInfo =
-        builder.create<fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, box, dim);
-    lbAndExtents.push_back(dimInfo.getLowerBound());
-    lbAndExtents.push_back(dimInfo.getExtent());
+
+  if (cannotHaveNonDefaultLowerBounds && !sequenceType.hasDynamicExtents()) {
+    // We don't need fir::BoxDimsOp if all of the extents are statically known
+    // and we can assume default lower bounds. This helps avoids reads from the
+    // mold arg.
+    mlir::Value one = builder.createIntegerConstant(loc, idxTy, 1);
+    for (int64_t extent : sequenceType.getShape()) {
+      assert(extent != sequenceType.getUnknownExtent());
+      mlir::Value extentVal = builder.createIntegerConstant(loc, idxTy, extent);
+      lbAndExtents.push_back(one);
+      lbAndExtents.push_back(extentVal);
+    }
+  } else {
+    for (unsigned i = 0; i < rank; ++i) {
+      // TODO: ideally we want to hoist box reads out of the critical section.
+      // We could do this by having box dimensions in block arguments like
+      // OpenACC does
+      mlir::Value dim = builder.createIntegerConstant(loc, idxTy, i);
+      auto dimInfo =
+          builder.create<fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, box, dim);
+      lbAndExtents.push_back(dimInfo.getLowerBound());
+      lbAndExtents.push_back(dimInfo.getExtent());
+    }
   }
 
   auto shapeShiftTy = fir::ShapeShiftType::get(builder.getContext(), rank);
@@ -249,12 +264,13 @@ class PopulateInitAndCleanupRegionsHelper {
       mlir::Type argType, mlir::Value scalarInitValue,
       mlir::Value allocatedPrivVarArg, mlir::Value moldArg,
       mlir::Block *initBlock, mlir::Region &cleanupRegion,
-      DeclOperationKind kind, const Fortran::semantics::Symbol *sym)
+      DeclOperationKind kind, const Fortran::semantics::Symbol *sym,
+      bool cannotHaveLowerBounds)
       : converter{converter}, builder{converter.getFirOpBuilder()}, loc{loc},
         argType{argType}, scalarInitValue{scalarInitValue},
         allocatedPrivVarArg{allocatedPrivVarArg}, moldArg{moldArg},
         initBlock{initBlock}, cleanupRegion{cleanupRegion}, kind{kind},
-        sym{sym} {
+        sym{sym}, cannotHaveNonDefaultLowerBounds{cannotHaveLowerBounds} {
     valType = fir::unwrapRefType(argType);
   }
 
@@ -296,6 +312,10 @@ class PopulateInitAndCleanupRegionsHelper {
   /// Any length parameters which have been fetched for the type
   mlir::SmallVector<mlir::Value> lenParams;
 
+  /// If the source variable being privatized definately can't have non-default
+  /// lower bounds then we don't need to generate code to read them.
+  bool cannotHaveNonDefaultLowerBounds;
+
   void createYield(mlir::Value ret) {
     builder.create<mlir::omp::YieldOp>(loc, ret);
   }
@@ -433,7 +453,8 @@ void PopulateInitAndCleanupRegionsHelper::initAndCleanupBoxedArray(
   // Special case for (possibly allocatable) arrays of polymorphic types
   // e.g. !fir.class<!fir.heap<!fir.array<?x!fir.type<>>>>
   if (source.isPolymorphic()) {
-    fir::ShapeShiftOp shape = getShapeShift(builder, loc, source);
+    fir::ShapeShiftOp shape =
+        getShapeShift(builder, loc, source, cannotHaveNonDefaultLowerBounds);
     mlir::Type arrayType = source.getElementOrSequenceType();
     mlir::Value allocatedArray = builder.create<fir::AllocMemOp>(
         loc, arrayType, /*typeparams=*/mlir::ValueRange{}, shape.getExtents());
@@ -472,8 +493,8 @@ void PopulateInitAndCleanupRegionsHelper::initAndCleanupBoxedArray(
   // Put the temporary inside of a box:
   // hlfir::genVariableBox doesn't handle non-default lower bounds
   mlir::Value box;
-  fir::ShapeShiftOp shapeShift =
-      getShapeShift(builder, loc, getLoadedMoldArg());
+  fir::ShapeShiftOp shapeShift = getShapeShift(builder, loc, getLoadedMoldArg(),
+                                               cannotHaveNonDefaultLowerBounds);
   mlir::Type boxType = getLoadedMoldArg().getType();
   if (mlir::isa<fir::BaseBoxType>(temp.getType()))
     // the box created by the declare form createTempFromMold is missing
@@ -608,10 +629,10 @@ void Fortran::lower::omp::populateByRefInitAndCleanupRegions(
     mlir::Type argType, mlir::Value scalarInitValue, mlir::Block *initBlock,
     mlir::Value allocatedPrivVarArg, mlir::Value moldArg,
     mlir::Region &cleanupRegion, DeclOperationKind kind,
-    const Fortran::semantics::Symbol *sym) {
+    const Fortran::semantics::Symbol *sym, bool cannotHaveLowerBounds) {
   PopulateInitAndCleanupRegionsHelper helper(
       converter, loc, argType, scalarInitValue, allocatedPrivVarArg, moldArg,
-      initBlock, cleanupRegion, kind, sym);
+      initBlock, cleanupRegion, kind, sym, cannotHaveLowerBounds);
   helper.populateByRefInitAndCleanupRegions();
 
   // Often we load moldArg to check something (e.g. length parameters, shape)
diff --git a/flang/lib/Lower/OpenMP/PrivateReductionUtils.h b/flang/lib/Lower/OpenMP/PrivateReductionUtils.h
index fcd36392a29e0a..0a3513bff19b0c 100644
--- a/flang/lib/Lower/OpenMP/PrivateReductionUtils.h
+++ b/flang/lib/Lower/OpenMP/PrivateReductionUtils.h
@@ -55,11 +55,13 @@ void populateByRefInitAndCleanupRegions(
     mlir::Value scalarInitValue, mlir::Block *initBlock,
     mlir::Value allocatedPrivVarArg, mlir::Value moldArg,
     mlir::Region &cleanupRegion, DeclOperationKind kind,
-    const Fortran::semantics::Symbol *sym = nullptr);
+    const Fortran::semantics::Symbol *sym = nullptr,
+    bool cannotHaveNonDefaultLowerBounds = false);
 
 /// Generate a fir::ShapeShift op describing the provided boxed array.
 fir::ShapeShiftOp getShapeShift(fir::FirOpBuilder &builder, mlir::Location loc,
-                                mlir::Value box);
+                                mlir::Value box,
+                                bool cannotHaveNonDefaultLowerBounds = false);
 
 } // namespace omp
 } // namespace lower
diff --git a/flang/test/Lower/OpenMP/delayed-privatization-array.f90 b/flang/test/Lower/OpenMP/delayed-privatization-array.f90
index 95fa3f9e030527..c447fa6f27a759 100644
--- a/flang/test/Lower/OpenMP/delayed-privatization-array.f90
+++ b/flang/test/Lower/OpenMP/delayed-privatization-array.f90
@@ -108,15 +108,14 @@ program main
 ! ONE_DIM_DEFAULT_LB-SAME: @[[PRIVATIZER_SYM:.*]] : [[BOX_TYPE:!fir.box<!fir.array<10xi32>>]] init {
 
 ! ONE_DIM_DEFAULT_LB-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE:!fir.ref<!fir.box<!fir.array<10xi32>>>]], %[[PRIV_BOX_ALLOC:.*]]: [[TYPE]]):
-! ONE_DIM_DEFAULT_LB-NEXT:   %[[PRIV_ARG_VAL:.*]] = fir.load %[[PRIV_ARG]]
 ! ONE_DIM_DEFAULT_LB-NEXT:   %[[C10:.*]] = arith.constant 10 : index
 ! ONE_DIM_DEFAULT_LB-NEXT:   %[[SHAPE:.*]] = fir.shape %[[C10]]
 ! ONE_DIM_DEFAULT_LB-NEXT:   %[[ARRAY_ALLOC:.*]] = fir.allocmem !fir.array<10xi32>
 ! ONE_DIM_DEFAULT_LB-NEXT:   %[[TRUE:.*]] = arith.constant true
 ! ONE_DIM_DEFAULT_LB-NEXT:   %[[DECL:.*]]:2 = hlfir.declare %[[ARRAY_ALLOC]](%[[SHAPE]])
-! ONE_DIM_DEFAULT_LB-NEXT:   %[[C0_0:.*]] = arith.constant 0
-! ONE_DIM_DEFAULT_LB-NEXT:   %[[DIMS2:.*]]:3 = fir.box_dims %[[PRIV_ARG_VAL]], %[[C0_0]]
-! ONE_DIM_DEFAULT_LB-NEXT:   %[[SHAPE_SHIFT:.*]] = fir.shape_shift %[[DIMS2]]#0, %[[DIMS2]]#1
+! ONE_DIM_DEFAULT_LB-NEXT:   %[[ONE:.*]] = arith.constant 1 : index
+! ONE_DIM_DEFAULT_LB-NEXT:   %[[TEN:.*]] = arith.constant 10 : index
+! ONE_DIM_DEFAULT_LB-NEXT:   %[[SHAPE_SHIFT:.*]] = fir.shape_shift %[[ONE]], %[[TEN]]
 ! ONE_DIM_DEFAULT_LB-NEXT:   %[[EMBOX:.*]] = fir.embox %[[DECL]]#0(%[[SHAPE_SHIFT]])
 ! ONE_DIM_DEFAULT_LB-NEXT:   fir.store %[[EMBOX]] to %[[PRIV_BOX_ALLOC]]
 ! ONE_DIM_DEFAULT_LB-NEXT:   omp.yield(%[[PRIV_BOX_ALLOC]] : [[TYPE]])

@tblah tblah force-pushed the users/tblah/init-region-cleanup-1 branch from 5efc2c5 to 7dcea4c Compare February 6, 2025 10:26
@tblah tblah force-pushed the users/tblah/init-region-cleanup-2 branch from ebde37b to 8a7e449 Compare February 6, 2025 10:31
@@ -472,8 +493,8 @@ void PopulateInitAndCleanupRegionsHelper::initAndCleanupBoxedArray(
// Put the temporary inside of a box:
// hlfir::genVariableBox doesn't handle non-default lower bounds
mlir::Value box;
fir::ShapeShiftOp shapeShift =
getShapeShift(builder, loc, getLoadedMoldArg());
fir::ShapeShiftOp shapeShift = getShapeShift(builder, loc, getLoadedMoldArg(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does loading moldArg count as an use?
Or will we only insert a barrier if the loaded moldArg is referenced?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Judging by the code in #125900, if there is only a load of moldArg it will be removed and no barrier will be inserted.

Copy link
Contributor

@luporl luporl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the improvement.

Base automatically changed from users/tblah/init-region-cleanup-1 to main February 6, 2025 14:27
This should further reduce the number of spurious barriers
@tblah tblah force-pushed the users/tblah/init-region-cleanup-2 branch from 8a7e449 to 4b31b3f Compare February 6, 2025 14:28
Copy link
Member

@ergawy ergawy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tblah tblah merged commit 88dd372 into main Feb 18, 2025
8 checks passed
@tblah tblah deleted the users/tblah/init-region-cleanup-2 branch February 18, 2025 09:02
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 18, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-libcxx running on linaro-flang-aarch64-libcxx while building flang at step 6 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/89/builds/16821

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-flang) failure: test (failure)
******************** TEST 'Flang :: Lower/OpenMP/different_vars_lastprivate_barrier.f90' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/bin/flang -fc1 -fopenmp -mmlir --openmp-enable-delayed-privatization-staging=true -emit-hlfir /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90 -o - | /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90
+ /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/bin/flang -fc1 -fopenmp -mmlir --openmp-enable-delayed-privatization-staging=true -emit-hlfir /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90 -o -
+ /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90
/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90:16:10: error: CHECK: expected string not found in input
! CHECK: %[[BOX_DIMS:.*]]:3 = fir.box_dims %[[ORIG_VAL]], %{{.*}} : ([[BOX_TYPE]], index) -> (index, index, index)
         ^
<stdin>:17:21: note: scanning from here
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:17:21: note: with "ORIG_VAL" equal to "0"
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:17:21: note: with "BOX_TYPE" equal to "!fir\\.box<!fir\\.array<3xi32>>"
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:34:2: note: possible intended match here
 %3 = fir.shape %c3 : (index) -> !fir.shape<1>
 ^

Input file: <stdin>
Check file: /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           12:  %4 = fir.embox %2#0(%3) : (!fir.heap<!fir.array<3xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<3xi32>> 
           13:  fir.store %4 to %arg1 : !fir.ref<!fir.box<!fir.array<3xi32>>> 
           14:  omp.yield(%arg1 : !fir.ref<!fir.box<!fir.array<3xi32>>>) 
           15:  } dealloc { 
           16:  ^bb0(%arg0: !fir.ref<!fir.box<!fir.array<3xi32>>>): 
           17:  %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>> 
check:16'0                         X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:16'1                                                                   with "ORIG_VAL" equal to "0"
check:16'2                                                                   with "BOX_TYPE" equal to "!fir\\.box<!fir\\.array<3xi32>>"
           18:  %1 = fir.box_addr %0 : (!fir.box<!fir.array<3xi32>>) -> !fir.ref<!fir.array<3xi32>> 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           19:  %2 = fir.convert %1 : (!fir.ref<!fir.array<3xi32>>) -> i64 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           20:  %c0_i64 = arith.constant 0 : i64 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           21:  %3 = arith.cmpi ne, %2, %c0_i64 : i64 
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 18, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-flang-rhel-clang running on ppc64le-flang-rhel-test while building flang at step 6 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/20232

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-flang) failure: test (failure)
******************** TEST 'Flang :: Lower/OpenMP/different_vars_lastprivate_barrier.f90' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/flang -fc1 -fopenmp -mmlir --openmp-enable-delayed-privatization-staging=true -emit-hlfir /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90 -o - | /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/flang -fc1 -fopenmp -mmlir --openmp-enable-delayed-privatization-staging=true -emit-hlfir /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90 -o -
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90:16:10: error: CHECK: expected string not found in input
! CHECK: %[[BOX_DIMS:.*]]:3 = fir.box_dims %[[ORIG_VAL]], %{{.*}} : ([[BOX_TYPE]], index) -> (index, index, index)
         ^
<stdin>:17:21: note: scanning from here
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:17:21: note: with "ORIG_VAL" equal to "0"
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:17:21: note: with "BOX_TYPE" equal to "!fir\\.box<!fir\\.array<3xi32>>"
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:34:2: note: possible intended match here
 %3 = fir.shape %c3 : (index) -> !fir.shape<1>
 ^

Input file: <stdin>
Check file: /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           12:  %4 = fir.embox %2#0(%3) : (!fir.heap<!fir.array<3xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<3xi32>> 
           13:  fir.store %4 to %arg1 : !fir.ref<!fir.box<!fir.array<3xi32>>> 
           14:  omp.yield(%arg1 : !fir.ref<!fir.box<!fir.array<3xi32>>>) 
           15:  } dealloc { 
           16:  ^bb0(%arg0: !fir.ref<!fir.box<!fir.array<3xi32>>>): 
           17:  %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>> 
check:16'0                         X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:16'1                                                                   with "ORIG_VAL" equal to "0"
check:16'2                                                                   with "BOX_TYPE" equal to "!fir\\.box<!fir\\.array<3xi32>>"
           18:  %1 = fir.box_addr %0 : (!fir.box<!fir.array<3xi32>>) -> !fir.ref<!fir.array<3xi32>> 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           19:  %2 = fir.convert %1 : (!fir.ref<!fir.array<3xi32>>) -> i64 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           20:  %c0_i64 = arith.constant 0 : i64 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           21:  %3 = arith.cmpi ne, %2, %c0_i64 : i64 
...

tblah added a commit that referenced this pull request Feb 18, 2025
…ray" (#127596)

Reverts #125901

Revert until I have fixed bot failures
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 18, 2025

LLVM Buildbot has detected a new failure on builder openmp-offload-sles-build-only running on rocm-worker-hw-04-sles while building flang at step 7 "Add check check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/17178

Here is the relevant piece of the build log for the reference
Step 7 (Add check check-flang) failure: test (failure)
******************** TEST 'Flang :: Lower/OpenMP/different_vars_lastprivate_barrier.f90' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/flang -fc1 -fopenmp -mmlir --openmp-enable-delayed-privatization-staging=true -emit-hlfir /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90 -o - | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90
+ /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/flang -fc1 -fopenmp -mmlir --openmp-enable-delayed-privatization-staging=true -emit-hlfir /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90 -o -
+ /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90:16:10: error: CHECK: expected string not found in input
! CHECK: %[[BOX_DIMS:.*]]:3 = fir.box_dims %[[ORIG_VAL]], %{{.*}} : ([[BOX_TYPE]], index) -> (index, index, index)
         ^
<stdin>:17:21: note: scanning from here
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:17:21: note: with "ORIG_VAL" equal to "0"
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:17:21: note: with "BOX_TYPE" equal to "!fir\\.box<!fir\\.array<3xi32>>"
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:34:2: note: possible intended match here
 %3 = fir.shape %c3 : (index) -> !fir.shape<1>
 ^

Input file: <stdin>
Check file: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           12:  %4 = fir.embox %2#0(%3) : (!fir.heap<!fir.array<3xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<3xi32>> 
           13:  fir.store %4 to %arg1 : !fir.ref<!fir.box<!fir.array<3xi32>>> 
           14:  omp.yield(%arg1 : !fir.ref<!fir.box<!fir.array<3xi32>>>) 
           15:  } dealloc { 
           16:  ^bb0(%arg0: !fir.ref<!fir.box<!fir.array<3xi32>>>): 
           17:  %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>> 
check:16'0                         X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:16'1                                                                   with "ORIG_VAL" equal to "0"
check:16'2                                                                   with "BOX_TYPE" equal to "!fir\\.box<!fir\\.array<3xi32>>"
           18:  %1 = fir.box_addr %0 : (!fir.box<!fir.array<3xi32>>) -> !fir.ref<!fir.array<3xi32>> 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           19:  %2 = fir.convert %1 : (!fir.ref<!fir.array<3xi32>>) -> i64 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           20:  %c0_i64 = arith.constant 0 : i64 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           21:  %3 = arith.cmpi ne, %2, %c0_i64 : i64 
...

github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Feb 18, 2025
…ic sized array" (#127596)

Reverts llvm/llvm-project#125901

Revert until I have fixed bot failures
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 18, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building flang at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/23130

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Flang :: Lower/OpenMP/different_vars_lastprivate_barrier.f90' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /build/buildbot/premerge-monolithic-linux/build/bin/flang -fc1 -fopenmp -mmlir --openmp-enable-delayed-privatization-staging=true -emit-hlfir /build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90 -o - | /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90
+ /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90
+ /build/buildbot/premerge-monolithic-linux/build/bin/flang -fc1 -fopenmp -mmlir --openmp-enable-delayed-privatization-staging=true -emit-hlfir /build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90 -o -
/build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90:16:10: error: CHECK: expected string not found in input
! CHECK: %[[BOX_DIMS:.*]]:3 = fir.box_dims %[[ORIG_VAL]], %{{.*}} : ([[BOX_TYPE]], index) -> (index, index, index)
         ^
<stdin>:17:21: note: scanning from here
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:17:21: note: with "ORIG_VAL" equal to "0"
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:17:21: note: with "BOX_TYPE" equal to "!fir\\.box<!fir\\.array<3xi32>>"
 %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>>
                    ^
<stdin>:34:2: note: possible intended match here
 %3 = fir.shape %c3 : (index) -> !fir.shape<1>
 ^

Input file: <stdin>
Check file: /build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Lower/OpenMP/different_vars_lastprivate_barrier.f90

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           12:  %4 = fir.embox %2#0(%3) : (!fir.heap<!fir.array<3xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<3xi32>> 
           13:  fir.store %4 to %arg1 : !fir.ref<!fir.box<!fir.array<3xi32>>> 
           14:  omp.yield(%arg1 : !fir.ref<!fir.box<!fir.array<3xi32>>>) 
           15:  } dealloc { 
           16:  ^bb0(%arg0: !fir.ref<!fir.box<!fir.array<3xi32>>>): 
           17:  %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<3xi32>>> 
check:16'0                         X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:16'1                                                                   with "ORIG_VAL" equal to "0"
check:16'2                                                                   with "BOX_TYPE" equal to "!fir\\.box<!fir\\.array<3xi32>>"
           18:  %1 = fir.box_addr %0 : (!fir.box<!fir.array<3xi32>>) -> !fir.ref<!fir.array<3xi32>> 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           19:  %2 = fir.convert %1 : (!fir.ref<!fir.array<3xi32>>) -> i64 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           20:  %c0_i64 = arith.constant 0 : i64 
check:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           21:  %3 = arith.cmpi ne, %2, %c0_i64 : i64 
...

wldfngrs pushed a commit to wldfngrs/llvm-project that referenced this pull request Feb 19, 2025
…m#125901)

This should further reduce the number of spurious barriers
wldfngrs pushed a commit to wldfngrs/llvm-project that referenced this pull request Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang:openmp flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants