[Mlir-commits] [mlir] [MLIR][LLVM] Support Recursive DITypes (PR #80251)
Billy Zhu
llvmlistbot at llvm.org
Fri Mar 22 16:44:31 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 very interesting... Is it something like this
```
// LLVM
+---> B ----+
| v
A <-------- D
| ^
+---> C ----+
// MLIR
A -> B -> D -> A'
+--> C -> D -> A'
```
So now in MLIR you have two copies of the subgraph `D -> A'`, but they're different because we don't cache it?
I like your idea of a temporary cache that keys on the set of unbounded references. This way repeated subgraphs can be merged too. I can get started on something for this. Please let me know if this is not what you were looking for though 😂.
https://github.com/llvm/llvm-project/pull/80251
More information about the Mlir-commits
mailing list