[Mlir-commits] [mlir] [MLIR][LLVM] Support Recursive DITypes (PR #80251)
Billy Zhu
llvmlistbot at llvm.org
Mon Apr 1 16:57:03 PDT 2024
================
@@ -289,7 +316,19 @@ DINodeAttr DebugImporter::translate(llvm::DINode *node) {
return nullptr;
};
if (DINodeAttr attr = translateNode(node)) {
- nodeToAttr.insert({node, attr});
+ // If this node was marked as recursive, set its recId.
+ if (auto recType = dyn_cast<DIRecursiveTypeAttrInterface>(attr)) {
+ if (DistinctAttr recId = translationStack.lookup(node)) {
+ attr = cast<DINodeAttr>(recType.withRecId(recId));
+ // Remove the unbound recursive ID from the set of unbound self
+ // references in the translation stack.
+ unboundRecursiveSelfRefs.back().erase(recId);
+ }
+ }
+
+ // Only cache fully self-contained nodes.
+ if (unboundRecursiveSelfRefs.back().empty())
----------------
zyx-billy wrote:
@gysit I have a solution here that should work: https://github.com/llvm/llvm-project/pull/87295. For your example, it only creates one copy of the B type declaration.
In addition to caching every translated result, the unbound self-ref replacement is lazy so that it's only triggered on use. Interested to see how this works for your cases. Hoping that both compile time and result IR is smaller 🙏. I can open it up for review if it works, otherwise we can see where to further optimize. Thanks!
https://github.com/llvm/llvm-project/pull/80251
More information about the Mlir-commits
mailing list