@@ -315,25 +315,31 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
315315 std::optional<llvm::ArrayRef<int64_t >> lowerBounds =
316316 fir::getComponentLowerBoundsIfNonDefault (Ty, fieldName, module ,
317317 symbolTable);
318+ auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(fieldTy);
318319
319320 // For members of the derived types, the information about the shift in
320321 // lower bounds is not part of the declOp but has to be extracted from the
321- // TypeInfoOp (using getComponentLowerBoundsIfNonDefault). We then assign it
322- // temporarily to the declOp to propagate this information where it will be
323- // needed by the type conversion logic.
322+ // TypeInfoOp (using getComponentLowerBoundsIfNonDefault).
324323 mlir::LLVM::DITypeAttr elemTy;
325- if (declOp && lowerBounds) {
326- llvm::SmallVector<mlir::Value> shiftOpers;
327- for (int64_t bound : *lowerBounds) {
328- auto constOp = builder.create <mlir::arith::ConstantOp>(
329- module .getLoc (), builder.getIntegerAttr (intTy, bound));
330- shiftOpers.push_back (constOp);
324+ if (lowerBounds && seqTy &&
325+ lowerBounds->size () == seqTy.getShape ().size ()) {
326+ llvm::SmallVector<mlir::LLVM::DINodeAttr> elements;
327+ for (auto [bound, dim] :
328+ llvm::zip_equal (*lowerBounds, seqTy.getShape ())) {
329+ auto countAttr = mlir::IntegerAttr::get (intTy, llvm::APInt (64 , dim));
330+ auto lowerAttr = mlir::IntegerAttr::get (intTy, llvm::APInt (64 , bound));
331+ auto subrangeTy = mlir::LLVM::DISubrangeAttr::get (
332+ context, countAttr, lowerAttr, /* upperBound=*/ nullptr ,
333+ /* stride=*/ nullptr );
334+ elements.push_back (subrangeTy);
331335 }
332- mlir::OperandRange originalShift = declOp.getShift ();
333- mlir::MutableOperandRange mutableOpRange = declOp.getShiftMutable ();
334- mutableOpRange.assign (shiftOpers);
335- elemTy = convertType (fieldTy, fileAttr, scope, declOp);
336- mutableOpRange.assign (originalShift);
336+ elemTy = mlir::LLVM::DICompositeTypeAttr::get (
337+ context, llvm::dwarf::DW_TAG_array_type, /* name=*/ nullptr ,
338+ /* file=*/ nullptr , /* line=*/ 0 , /* scope=*/ nullptr ,
339+ convertType (seqTy.getEleTy (), fileAttr, scope, declOp),
340+ mlir::LLVM::DIFlags::Zero, /* sizeInBits=*/ 0 , /* alignInBits=*/ 0 ,
341+ elements, /* dataLocation=*/ nullptr , /* rank=*/ nullptr ,
342+ /* allocated=*/ nullptr , /* associated=*/ nullptr );
337343 } else
338344 elemTy = convertType (fieldTy, fileAttr, scope, /* declOp=*/ nullptr );
339345 offset = llvm::alignTo (offset, byteAlign);
0 commit comments