[Mlir-commits] [mlir] [MLIR][LLVM] Recursion importer handle repeated self-references (PR #87295)

Billy Zhu llvmlistbot at llvm.org
Sun Apr 7 22:02:21 PDT 2024


================
@@ -423,3 +423,31 @@ llvm.mlir.global @global_variable() {dbg_expr = #di_global_variable_expression}
 // CHECK: ![[SCOPE]] = !DISubprogram({{.*}}type: ![[SUBROUTINE:[0-9]+]],
 // CHECK: ![[SUBROUTINE]] = !DISubroutineType(types: ![[SR_TYPES:[0-9]+]])
 // CHECK: ![[SR_TYPES]] = !{![[COMP]]}
+
+// -----
+
+// Ensures nested recursive decls work.
+// The output should be identical to if the inner composite type decl was
+// replaced with the recursive self reference.
+
+#di_file = #llvm.di_file<"test.mlir" in "/">
+#di_composite_type_self = #llvm.di_composite_type<tag = DW_TAG_null, recId = distinct[0]<>>
+
+#di_subroutine_type_inner = #llvm.di_subroutine_type<types = #di_composite_type_self>
+#di_subprogram_inner = #llvm.di_subprogram<scope = #di_file, file = #di_file, subprogramFlags = Optimized, type = #di_subroutine_type_inner>
+#di_composite_type_inner = #llvm.di_composite_type<tag = DW_TAG_class_type, recId = distinct[0]<>, scope = #di_subprogram_inner>
+
+#di_subroutine_type = #llvm.di_subroutine_type<types = #di_composite_type_inner>
----------------
zyx-billy wrote:

Yes for sure. It'd be a lot easier to re-prune this whole thing afterwards. We can just adapt [this function](https://github.com/llvm/llvm-project/pull/87295/commits/6f57bc1c1697cb10cb2f61485c476a0ede73bf77#diff-a0a1b003bb5227888d090b845ef0e3e52f9656793b0f8e9de89658c398ece8f5R325) that I deleted into a separate util. I can also add a DINodeAttr verifier that can be run after import to catch things.

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


More information about the Mlir-commits mailing list