[flang-commits] [flang] [flang] improve DITypeAttr caching with recursive derived types (PR #146543)
via flang-commits
flang-commits at lists.llvm.org
Thu Jul 3 05:06:46 PDT 2025
================
@@ -272,31 +271,127 @@ DebugTypeGenerator::getFieldSizeAndAlign(mlir::Type fieldTy) {
return std::pair{byteSize, byteAlign};
}
+mlir::LLVM::DITypeAttr DerivedTypeCache::lookup(mlir::Type type) {
+ auto iter = typeCache.find(type);
+ if (iter != typeCache.end()) {
+ if (iter->second.first) {
+ componentActiveRecursionLevels = iter->second.second;
+ }
+ return iter->second.first;
+ }
+ return nullptr;
+}
+
+DerivedTypeCache::ActiveLevels
+DerivedTypeCache::startTranslating(mlir::Type type,
+ mlir::LLVM::DITypeAttr placeHolder) {
+ derivedTypeDepth++;
+ if (!placeHolder)
+ return {};
+ typeCache[type] = std::pair<mlir::LLVM::DITypeAttr, ActiveLevels>(
+ placeHolder, {derivedTypeDepth});
+ return {};
+}
----------------
jeanPerier wrote:
This is expected, at the starting point of the translation, it is not yet know which recursive references will be met directly or indirectly in components.
This list will be updated in postComponentVisitUpdate().
I added as a startTranslating results to enforce its creation at the right point.
https://github.com/llvm/llvm-project/pull/146543
More information about the flang-commits
mailing list