[flang-commits] [flang] [flang][debug] Support derived type components with box types. (PR #109424)
via flang-commits
flang-commits at lists.llvm.org
Wed Sep 25 02:54:17 PDT 2024
================
@@ -163,26 +163,45 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertBoxedSequenceType(
mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
fir::RecordType Ty, mlir::LLVM::DIFileAttr fileAttr,
mlir::LLVM::DIScopeAttr scope, fir::cg::XDeclareOp declOp) {
+ // Check if this type has already been converted.
+ auto iter = typeCache.find(Ty);
+ if (iter != typeCache.end())
+ return iter->second;
+
+ llvm::SmallVector<mlir::LLVM::DINodeAttr> elements;
mlir::MLIRContext *context = module.getContext();
+ auto recId = mlir::DistinctAttr::create(mlir::UnitAttr::get(context));
+ // Generate a place holder TypeAttr which will be used if a member
+ // references the parent type.
+ auto comAttr = mlir::LLVM::DICompositeTypeAttr::get(
+ context, recId, /*isRecSelf=*/true, llvm::dwarf::DW_TAG_structure_type,
+ mlir::StringAttr::get(context, ""), fileAttr, /*line=*/0, scope,
+ /*baseType=*/nullptr, mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0,
+ /*alignInBits=*/0, elements, /*dataLocation=*/nullptr, /*rank=*/nullptr,
+ /*allocated=*/nullptr, /*associated=*/nullptr);
+ typeCache[Ty] = comAttr;
+
auto result = fir::NameUniquer::deconstruct(Ty.getName());
if (result.first != fir::NameUniquer::NameKind::DERIVED_TYPE)
return genPlaceholderType(context);
fir::TypeInfoOp tiOp = symbolTable->lookup<fir::TypeInfoOp>(Ty.getName());
unsigned line = (tiOp) ? getLineFromLoc(tiOp.getLoc()) : 1;
- llvm::SmallVector<mlir::LLVM::DINodeAttr> elements;
std::uint64_t offset = 0;
+ LLVMTypeConverter llvmTypeConverter(module, false, false, *dataLayout);
----------------
jeanPerier wrote:
This is likely not a trivial class/ctor, and I would not be surprised if it did caching somewhere. Probably best to keep it at the same level as the dataLayout.
https://github.com/llvm/llvm-project/pull/109424
More information about the flang-commits
mailing list