@@ -295,23 +295,24 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertCharacterType(
295
295
// variable that will contain that length. This variable is used as
296
296
// 'stringLength' in DIStringTypeAttr.
297
297
if (declOp && !declOp.getTypeparams ().empty ()) {
298
- mlir::Operation *op = declOp.getTypeparams ()[0 ].getDefiningOp ();
299
- if (auto unbox = mlir::dyn_cast_or_null<fir::UnboxCharOp>(op)) {
300
- auto name =
301
- mlir::StringAttr::get (context, " ." + declOp.getUniqName ().str ());
302
- mlir::OpBuilder builder (context);
303
- builder.setInsertionPoint (declOp);
304
- mlir::Type i64Ty = builder.getIntegerType (64 );
305
- auto convOp = builder.create <fir::ConvertOp>(unbox.getLoc (), i64Ty,
306
- unbox.getResult (1 ));
307
- mlir::LLVM::DITypeAttr Ty = convertType (i64Ty, fileAttr, scope, declOp);
308
- auto lvAttr = mlir::LLVM::DILocalVariableAttr::get (
309
- context, scope, name, fileAttr, /* line=*/ 0 , /* argNo=*/ 0 ,
310
- /* alignInBits=*/ 0 , Ty, mlir::LLVM::DIFlags::Artificial);
311
- builder.create <mlir::LLVM::DbgValueOp>(convOp.getLoc (), convOp, lvAttr,
312
- nullptr );
313
- varAttr = mlir::cast<mlir::LLVM::DIVariableAttr>(lvAttr);
298
+ auto name =
299
+ mlir::StringAttr::get (context, " ." + declOp.getUniqName ().str ());
300
+ mlir::OpBuilder builder (context);
301
+ builder.setInsertionPoint (declOp);
302
+ mlir::Value sizeVal = declOp.getTypeparams ()[0 ];
303
+ mlir::Type type = sizeVal.getType ();
304
+ if (!mlir::isa<mlir::IntegerType>(type) || !type.isSignlessInteger ()) {
305
+ type = builder.getIntegerType (64 );
306
+ sizeVal =
307
+ builder.create <fir::ConvertOp>(declOp.getLoc (), type, sizeVal);
314
308
}
309
+ mlir::LLVM::DITypeAttr Ty = convertType (type, fileAttr, scope, declOp);
310
+ auto lvAttr = mlir::LLVM::DILocalVariableAttr::get (
311
+ context, scope, name, fileAttr, /* line=*/ 0 , /* argNo=*/ 0 ,
312
+ /* alignInBits=*/ 0 , Ty, mlir::LLVM::DIFlags::Artificial);
313
+ builder.create <mlir::LLVM::DbgValueOp>(declOp.getLoc (), sizeVal, lvAttr,
314
+ nullptr );
315
+ varAttr = mlir::cast<mlir::LLVM::DIVariableAttr>(lvAttr);
315
316
}
316
317
}
317
318
0 commit comments