[flang-commits] [flang] [flang][debug] Support derived types. (PR #99476)
Abid Qadeer via flang-commits
flang-commits at lists.llvm.org
Fri Jul 26 03:40:49 PDT 2024
================
@@ -154,6 +156,56 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertBoxedSequenceType(
dataLocation, /*rank=*/nullptr, allocated, associated);
}
+mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
+ fir::RecordType Ty, mlir::LLVM::DIFileAttr fileAttr,
+ mlir::LLVM::DIScopeAttr scope, mlir::Location loc) {
+ mlir::MLIRContext *context = module.getContext();
+ auto result = fir::NameUniquer::deconstruct(Ty.getName());
+ if (result.first != fir::NameUniquer::NameKind::DERIVED_TYPE)
+ return genPlaceholderType(context);
+
+ std::optional<mlir::DataLayout> dl =
+ fir::support::getOrSetDataLayout(module, /*allowDefaultLayout=*/true);
+ if (!dl) {
+ mlir::emitError(module.getLoc(), "Missing data layout attribute in module");
+ return genPlaceholderType(context);
+ }
+ unsigned line = 1;
+ mlir::LLVM::DITypeAttr parentTypeAttr = nullptr;
+ fir::TypeInfoOp tiOp = symbolTable->lookup<fir::TypeInfoOp>(Ty.getName());
+ if (tiOp) {
+ line = getLineFromLoc(tiOp.getLoc());
+ if (fir::RecordType parentTy = tiOp.getIfParentType())
+ parentTypeAttr =
+ convertRecordType(parentTy, fileAttr, scope, tiOp.getLoc());
----------------
abidh wrote:
Yes the base as first argument works. The `DWARF` output is same as generated by classic flang and gfortran. The testcase I added has 3 level of parent-child relationship.
While looking at this, I noticed that I was also setting `base_type` field of the `DICompositeTypeAttr` in this case which is really not needed. That field is for situation where `DICompositeTypeAttr` is representing an array. I will fix it.
https://github.com/llvm/llvm-project/pull/99476
More information about the flang-commits
mailing list