[flang-commits] [flang] d518f8e - [flang] fix assumed-size debug info after #164452 (#164772)

via flang-commits flang-commits at lists.llvm.org
Fri Oct 24 12:05:50 PDT 2025


Author: jeanPerier
Date: 2025-10-24T21:05:47+02:00
New Revision: d518f8e40e2b0318264ab45424e515862744b572

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

LOG: [flang] fix assumed-size debug info after #164452 (#164772)

I missed this case because the code was not explicitly looking for -1.

Added: 
    

Modified: 
    flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
    flang/test/Transforms/debug-assumed-size-array.fir

Removed: 
    


################################################################################
diff  --git a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
index 00fdb5a4516bd..e1e6125fc348b 100644
--- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
+++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
@@ -528,13 +528,10 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertSequenceType(
     if (dim == seqTy.getUnknownExtent()) {
       // This path is taken for both assumed size array or when the size of the
       // array is variable. In the case of variable size, we create a variable
-      // to use as countAttr. Note that fir has a constant size of -1 for
-      // assumed size array. So !optint check makes sure we don't generate
-      // variable in that case.
+      // to use as countAttr.
       if (declOp && declOp.getShape().size() > index) {
-        std::optional<std::int64_t> optint =
-            getIntIfConstant(declOp.getShape()[index]);
-        if (!optint)
+        if (!llvm::isa_and_nonnull<fir::AssumedSizeExtentOp>(
+                declOp.getShape()[index].getDefiningOp()))
           countAttr = generateArtificialVariable(
               context, declOp.getShape()[index], fileAttr, scope, declOp);
       }

diff  --git a/flang/test/Transforms/debug-assumed-size-array.fir b/flang/test/Transforms/debug-assumed-size-array.fir
index 40e57100fd9ff..2c915526e32bb 100644
--- a/flang/test/Transforms/debug-assumed-size-array.fir
+++ b/flang/test/Transforms/debug-assumed-size-array.fir
@@ -5,7 +5,7 @@ module {
     %c5 = arith.constant 5 : index
     %c1 = arith.constant 1 : index
     %c2 = arith.constant 2 : index
-    %c-1 = arith.constant -1 : index
+    %c-1 = fir.assumed_size_extent : index
     %0 = fir.undefined !fir.dscope
     %1 = fircg.ext_declare %arg0(%c5, %c-1) dummy_scope %0 {uniq_name = "_QMhelperFfnEa1"} : (!fir.ref<!fir.array<5x?xi32>>, index, index, !fir.dscope) -> !fir.ref<!fir.array<5x?xi32>> loc(#loc1)
     %2 = fircg.ext_declare %arg1(%c-1) origin %c2 dummy_scope %0 {uniq_name = "_QMhelperFfnEa2"} : (!fir.ref<!fir.array<?xi32>>, index, index, !fir.dscope) -> !fir.ref<!fir.array<?xi32>> loc(#loc2)


        


More information about the flang-commits mailing list