[Mlir-commits] [mlir] [MLIR][LLVM] Support Recursive DITypes (PR #80251)

Tobias Gysi llvmlistbot at llvm.org
Tue Apr 2 02:04:18 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())
----------------
gysit wrote:

Very nice!

I see a massive reduction in size and it is comparable to llvm now:
```
-rw-r--r-- 1 tobiasg tobiasg  196553791 Apr  2 10:59 sparta-input.ll
-rw-r--r-- 1 tobiasg tobiasg  162484418 Apr  2 10:47 sparta-with-fix.mlir
-rw-r--r-- 1 tobiasg tobiasg 1817219645 Apr  2 10:59 sparta-without-fix.mlir
```
Additionally compilation time drops by factor 10x as well. I have a debug build only though. However, I expect this reproduce in release build.

So I think we should probably go ahead with your solution! 

https://github.com/llvm/llvm-project/pull/80251


More information about the Mlir-commits mailing list