[flang-commits] [flang] [flang] fix assumed-size debug info after #164452 (PR #164772)
via flang-commits
flang-commits at lists.llvm.org
Thu Oct 23 01:24:38 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: None (jeanPerier)
<details>
<summary>Changes</summary>
I missed this case because the code was not explicitly looking for -1.
---
Full diff: https://github.com/llvm/llvm-project/pull/164772.diff
2 Files Affected:
- (modified) flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp (+3-6)
- (modified) flang/test/Transforms/debug-assumed-size-array.fir (+1-1)
``````````diff
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)
``````````
</details>
https://github.com/llvm/llvm-project/pull/164772
More information about the flang-commits
mailing list