@@ -157,28 +157,35 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertSequenceType(
157
157
fir::SequenceType seqTy, mlir::LLVM::DIFileAttr fileAttr,
158
158
mlir::LLVM::DIScopeAttr scope, mlir::Location loc) {
159
159
mlir::MLIRContext *context = module.getContext ();
160
- // FIXME: Only fixed sizes arrays handled at the moment.
161
- if (seqTy.hasDynamicExtents ())
162
- return genPlaceholderType (context);
163
160
164
161
llvm::SmallVector<mlir::LLVM::DINodeAttr> elements;
165
162
mlir::LLVM::DITypeAttr elemTy =
166
163
convertType (seqTy.getEleTy (), fileAttr, scope, loc);
167
164
168
165
for (fir::SequenceType::Extent dim : seqTy.getShape ()) {
169
- auto intTy = mlir::IntegerType::get (context, 64 );
170
- // FIXME: Only supporting lower bound of 1 at the moment. The
171
- // 'SequenceType' has information about the shape but not the shift. In
172
- // cases where the conversion originated during the processing of
173
- // 'DeclareOp', it may be possible to pass on this information. But the
174
- // type conversion should ideally be based on what information present in
175
- // the type class so that it works from everywhere (e.g. when it is part
176
- // of a module or a derived type.)
177
- auto countAttr = mlir::IntegerAttr::get (intTy, llvm::APInt (64 , dim));
178
- auto lowerAttr = mlir::IntegerAttr::get (intTy, llvm::APInt (64 , 1 ));
179
- auto subrangeTy = mlir::LLVM::DISubrangeAttr::get (
180
- context, countAttr, lowerAttr, nullptr , nullptr );
181
- elements.push_back (subrangeTy);
166
+ if (dim == seqTy.getUnknownExtent ()) {
167
+ // FIXME: This path is taken for assumed size arrays but also for arrays
168
+ // with non constant extent. For the latter case, the DISubrangeAttr
169
+ // should point to a variable which will have the extent at runtime.
170
+ auto subrangeTy = mlir::LLVM::DISubrangeAttr::get (
171
+ context, /* count=*/ nullptr , /* lowerBound=*/ nullptr ,
172
+ /* upperBound*/ nullptr , /* stride*/ nullptr );
173
+ elements.push_back (subrangeTy);
174
+ } else {
175
+ auto intTy = mlir::IntegerType::get (context, 64 );
176
+ // FIXME: Only supporting lower bound of 1 at the moment. The
177
+ // 'SequenceType' has information about the shape but not the shift. In
178
+ // cases where the conversion originated during the processing of
179
+ // 'DeclareOp', it may be possible to pass on this information. But the
180
+ // type conversion should ideally be based on what information present in
181
+ // the type class so that it works from everywhere (e.g. when it is part
182
+ // of a module or a derived type.)
183
+ auto countAttr = mlir::IntegerAttr::get (intTy, llvm::APInt (64 , dim));
184
+ auto lowerAttr = mlir::IntegerAttr::get (intTy, llvm::APInt (64 , 1 ));
185
+ auto subrangeTy = mlir::LLVM::DISubrangeAttr::get (
186
+ context, countAttr, lowerAttr, nullptr , nullptr );
187
+ elements.push_back (subrangeTy);
188
+ }
182
189
}
183
190
// Apart from arrays, the `DICompositeTypeAttr` is used for other things like
184
191
// structure types. Many of its fields which are not applicable to arrays
0 commit comments