From 33b353e8771aeb46b3c4907ff3ac3b899395083c Mon Sep 17 00:00:00 2001 From: Jean Perier Date: Thu, 23 Oct 2025 01:18:34 -0700 Subject: [PATCH] [flang] fix assumed-size debug info after #164452 --- flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp | 9 +++------ flang/test/Transforms/debug-assumed-size-array.fir | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) 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 optint = - getIntIfConstant(declOp.getShape()[index]); - if (!optint) + if (!llvm::isa_and_nonnull( + 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>, index, index, !fir.dscope) -> !fir.ref> loc(#loc1) %2 = fircg.ext_declare %arg1(%c-1) origin %c2 dummy_scope %0 {uniq_name = "_QMhelperFfnEa2"} : (!fir.ref>, index, index, !fir.dscope) -> !fir.ref> loc(#loc2)