[flang-commits] [flang] 2502c3a - [flang] Add TODOs for some FORALL assignments with Pointers and Allocatables

Jean Perier via flang-commits flang-commits at lists.llvm.org
Fri Sep 23 01:12:46 PDT 2022


Author: Jean Perier
Date: 2022-09-23T10:11:00+02:00
New Revision: 2502c3afe0beafb90e447ec69d0891930557d494

URL: https://github.com/llvm/llvm-project/commit/2502c3afe0beafb90e447ec69d0891930557d494
DIFF: https://github.com/llvm/llvm-project/commit/2502c3afe0beafb90e447ec69d0891930557d494.diff

LOG: [flang] Add TODOs for some FORALL assignments with Pointers and Allocatables

Add TODO for whole array allocatable assignment inside FORALL
Whole allocatable array assignment inside FORALL are otherwise currently
hitting more cryptic asserts.

Add TODO in FORALL assignment when a designator appear with a part ref
that is an allocatable or pointer component (a(i)%pointer%k). The lowering
code does not handle this case well because of the pointer dereference.

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

Added: 
    

Modified: 
    flang/lib/Lower/ConvertExpr.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 51f77ffa26c50..27503a70dd2ee 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -3856,6 +3856,9 @@ class ArrayExprLowering {
     // FIXME: If the lhs is in an explicit iteration space, the assignment may
     // be to an array of allocatable arrays rather than a single allocatable
     // array.
+    if (explicitSpaceIsActive() && lhs.Rank() > 0)
+      TODO(loc, "assignment to whole allocatable array inside FORALL");
+
     fir::MutableBoxValue mutableBox =
         Fortran::lower::createMutableBox(loc, converter, lhs, symMap);
     if (rhs.Rank() > 0)
@@ -7174,7 +7177,9 @@ class ArrayExprLowering {
         if (components.hasExtendCoorRef()) {
           auto eleBoxTy =
               fir::applyPathToType(innerArg.getType(), iters.iterVec());
-          assert(eleBoxTy && eleBoxTy.isa<fir::BoxType>());
+          if (!eleBoxTy || !eleBoxTy.isa<fir::BoxType>())
+            TODO(loc, "assignment in a FORALL involving a designator with a "
+                      "POINTER or ALLOCATABLE component part-ref");
           auto arrayOp = builder.create<fir::ArrayAccessOp>(
               loc, builder.getRefType(eleBoxTy), innerArg, iters.iterVec(),
               fir::factory::getTypeParams(loc, builder, load));
@@ -7245,7 +7250,9 @@ class ArrayExprLowering {
       }
       if (components.hasExtendCoorRef()) {
         auto eleBoxTy = fir::applyPathToType(load.getType(), iters.iterVec());
-        assert(eleBoxTy && eleBoxTy.isa<fir::BoxType>());
+        if (!eleBoxTy || !eleBoxTy.isa<fir::BoxType>())
+          TODO(loc, "assignment in a FORALL involving a designator with a "
+                    "POINTER or ALLOCATABLE component part-ref");
         auto access = builder.create<fir::ArrayAccessOp>(
             loc, builder.getRefType(eleBoxTy), load, iters.iterVec(),
             fir::factory::getTypeParams(loc, builder, load));


        


More information about the flang-commits mailing list