[flang-commits] [flang] 0dd4fb0 - [flang] Fix for broken/degenerate forall case

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Fri Jul 1 01:37:23 PDT 2022


Author: Valentin Clement
Date: 2022-07-01T10:37:15+02:00
New Revision: 0dd4fb0408ed980de2c100905e68a4adf9987c61

URL: https://github.com/llvm/llvm-project/commit/0dd4fb0408ed980de2c100905e68a4adf9987c61
DIFF: https://github.com/llvm/llvm-project/commit/0dd4fb0408ed980de2c100905e68a4adf9987c61.diff

LOG: [flang] Fix for broken/degenerate forall case

Fix for broken/degenerate forall case where there is no assignment to an
array under the explicit iteration space. While this is a multiple
assignment, semantics only raises a warning.
The fix is to add a test that the explicit space has any sort of array
to be updated, and if not then the do_loop nest will not require a
terminator to forward array values to the next iteration.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D128973

Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>

Added: 
    

Modified: 
    flang/lib/Lower/Bridge.cpp
    flang/lib/Lower/ConvertExpr.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 05fbf3aa4c1e..a77a34913c98 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -1482,7 +1482,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
         auto lp = builder->create<fir::DoLoopOp>(
             loc, lb, ub, by, /*unordered=*/true,
             /*finalCount=*/false, explicitIterSpace.getInnerArgs());
-        if (!loops.empty() || !outermost)
+        if ((!loops.empty() || !outermost) && !lp.getRegionIterArgs().empty())
           builder->create<fir::ResultOp>(loc, lp.getResults());
         explicitIterSpace.setInnerArgs(lp.getRegionIterArgs());
         builder->setInsertionPointToStart(lp.getBody());
@@ -2198,7 +2198,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
                     lengthParams.push_back(charBox->getLen());
                   else if (fir::isDerivedWithLenParameters(rhs))
                     TODO(loc, "assignment to derived type allocatable with "
-                              "length parameters");
+                              "LEN parameters");
                   lhsRealloc = fir::factory::genReallocIfNeeded(
                       *builder, loc, *lhsMutableBox,
                       /*shape=*/llvm::None, lengthParams);

diff  --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index ebc2a3c62006..7f3bcc8a36ed 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -3661,7 +3661,7 @@ class ArrayExprLowering {
     // changed by concatenations).
     if ((mutableBox.isCharacter() && !mutableBox.hasNonDeferredLenParams()) ||
         mutableBox.isDerivedWithLenParameters())
-      TODO(loc, "gather rhs length parameters in assignment to allocatable");
+      TODO(loc, "gather rhs LEN parameters in assignment to allocatable");
 
     // The allocatable must take lower bounds from the expr if it is
     // reallocated and the right hand side is not a scalar.


        


More information about the flang-commits mailing list