[flang-commits] [flang] [flang][debug] Support derived types. (PR #99476)
Abid Qadeer via flang-commits
flang-commits at lists.llvm.org
Wed Jul 24 09:07:14 PDT 2024
================
@@ -154,6 +156,58 @@ 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());
+ }
+
+ llvm::SmallVector<mlir::LLVM::DINodeAttr> elements;
+ std::uint64_t offset = 0;
+ for (auto [fieldName, fieldTy] : Ty.getTypeList()) {
+ bool success = true;
+ auto [byteSize, byteAlign] =
+ fir::getTypeSizeAndAlignment(loc, fieldTy, *dl, kindMapping, &success);
+ if (!success)
+ return genPlaceholderType(context);
----------------
abidh wrote:
Ah, I understand your point now. I have updated the PR as per your suggestion.
https://github.com/llvm/llvm-project/pull/99476
More information about the flang-commits
mailing list