[flang-commits] [flang] [flang][debug] Support TupleType. (PR #113917)
Abid Qadeer via flang-commits
flang-commits at lists.llvm.org
Mon Oct 28 10:42:06 PDT 2024
================
@@ -368,6 +373,42 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
return finalAttr;
}
+mlir::LLVM::DITypeAttr DebugTypeGenerator::convertTupleType(
+ mlir::TupleType 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();
+
+ std::uint64_t offset = 0;
+ for (auto fieldTy : Ty.getTypes()) {
+ auto [byteSize, byteAlign] = getFieldSizeAndAlign(fieldTy);
+ mlir::LLVM::DITypeAttr elemTy =
+ convertType(fieldTy, fileAttr, scope, /*declOp=*/nullptr);
+ offset = llvm::alignTo(offset, byteAlign);
+ mlir::LLVM::DIDerivedTypeAttr tyAttr = mlir::LLVM::DIDerivedTypeAttr::get(
+ context, llvm::dwarf::DW_TAG_member, mlir::StringAttr::get(context, ""),
+ elemTy, byteSize * 8, byteAlign * 8, offset * 8,
+ /*optional<address space>=*/std::nullopt,
+ /*extra data=*/nullptr);
+ elements.push_back(tyAttr);
+ offset += llvm::alignTo(byteSize, byteAlign);
+ }
+
+ auto typeAttr = mlir::LLVM::DICompositeTypeAttr::get(
+ context, llvm::dwarf::DW_TAG_structure_type,
+ mlir::StringAttr::get(context, ""), fileAttr, /*line=*/0, scope,
----------------
abidh wrote:
Yes, that is correct understanding. I will add a comment here.
https://github.com/llvm/llvm-project/pull/113917
More information about the flang-commits
mailing list