Skip to content

Commit d518f8e

Browse files
authored
[flang] fix assumed-size debug info after llvm#164452 (llvm#164772)
I missed this case because the code was not explicitly looking for -1.
1 parent f7b4018 commit d518f8e

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,10 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertSequenceType(
528528
if (dim == seqTy.getUnknownExtent()) {
529529
// This path is taken for both assumed size array or when the size of the
530530
// array is variable. In the case of variable size, we create a variable
531-
// to use as countAttr. Note that fir has a constant size of -1 for
532-
// assumed size array. So !optint check makes sure we don't generate
533-
// variable in that case.
531+
// to use as countAttr.
534532
if (declOp && declOp.getShape().size() > index) {
535-
std::optional<std::int64_t> optint =
536-
getIntIfConstant(declOp.getShape()[index]);
537-
if (!optint)
533+
if (!llvm::isa_and_nonnull<fir::AssumedSizeExtentOp>(
534+
declOp.getShape()[index].getDefiningOp()))
538535
countAttr = generateArtificialVariable(
539536
context, declOp.getShape()[index], fileAttr, scope, declOp);
540537
}

flang/test/Transforms/debug-assumed-size-array.fir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module {
55
%c5 = arith.constant 5 : index
66
%c1 = arith.constant 1 : index
77
%c2 = arith.constant 2 : index
8-
%c-1 = arith.constant -1 : index
8+
%c-1 = fir.assumed_size_extent : index
99
%0 = fir.undefined !fir.dscope
1010
%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)
1111
%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)

0 commit comments

Comments
 (0)