[Mlir-commits] [mlir] [MLIR][LLVM] Support Recursive DITypes (PR #80251)
Billy Zhu
llvmlistbot at llvm.org
Fri Mar 29 17:17:14 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:
Oh thank you so much for the example. I see now that caching on the set of unbound self-refs doesn't solve the compile time problem... It probably does make sense to instead just create a new cache for each level of the translation stack like you said. Every time we put something that is potentially recursive onto the stack, we start a new cache. And one trick we can play is every time we finish a recursive type, we go into the current layer cache, replace all instances of its rec-self with the just-finished recursive type, and insert into the outer layer cache. This way `translate` never walks into a recursive type twice. Let me try to make something like this that's efficient 🤔
https://github.com/llvm/llvm-project/pull/80251
More information about the Mlir-commits
mailing list