[flang-commits] [flang] [flang][debug] Handle allocatable strings. (PR #95906)
Abid Qadeer via flang-commits
flang-commits at lists.llvm.org
Wed Jun 19 03:34:54 PDT 2024
================
@@ -205,16 +205,38 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertCharacterType(
if (charTy.getFKind() != 1)
encoding = llvm::dwarf::DW_ATE_UCS;
+ uint64_t sizeInBits = 0;
+ mlir::LLVM::DIExpressionAttr lenExpr = nullptr;
+ mlir::LLVM::DIExpressionAttr locExpr = nullptr;
+
+ if (allocatable) {
+ llvm::SmallVector<mlir::LLVM::DIExpressionElemAttr> ops;
+ auto addOp = [&](unsigned opc, llvm::ArrayRef<uint64_t> vals) {
+ ops.push_back(mlir::LLVM::DIExpressionElemAttr::get(context, opc, vals));
+ };
+ addOp(llvm::dwarf::DW_OP_push_object_address, {});
+ addOp(llvm::dwarf::DW_OP_plus_uconst, {lenOffset});
+ lenExpr = mlir::LLVM::DIExpressionAttr::get(context, ops);
+ ops.clear();
+
+ addOp(llvm::dwarf::DW_OP_push_object_address, {});
+ addOp(llvm::dwarf::DW_OP_deref, {});
+ locExpr = mlir::LLVM::DIExpressionAttr::get(context, ops);
+ } else if (charTy.hasConstantLen()) {
----------------
abidh wrote:
When descriptor is in use, we have to use the dwarf expression approach even if the length is fixed. This is because the location of the array content is *(object_address). If we try to treat it as fixed size array here, the debugger will treat descriptor bytes as array contents.
https://github.com/llvm/llvm-project/pull/95906
More information about the flang-commits
mailing list