[Mlir-commits] [mlir] [MLIR][LLVM] Make DISubprogramAttr cyclic (PR #106571)

Billy Zhu llvmlistbot at llvm.org
Thu Aug 29 11:48:12 PDT 2024


================
@@ -577,13 +579,28 @@ def LLVM_DISubprogramAttr : LLVM_Attr<"DISubprogram", "di_subprogram",
       "ArrayRef<DINodeAttr>":$retainedNodes
     ), [{
       MLIRContext *ctx = file.getContext();
-      return $_get(ctx, id, compileUnit, scope, StringAttr::get(ctx, name),
+      return $_get(ctx, id, /*recId=*/nullptr, compileUnit, scope,
+                   StringAttr::get(ctx, name),
                    StringAttr::get(ctx, linkageName), file, line,
                    scopeLine, subprogramFlags, type, retainedNodes);
     }]>
   ];
-
   let assemblyFormat = "`<` struct(params) `>`";
+  let extraClassDeclaration = [{
+    /// Requirements of DIRecursiveTypeAttrInterface.
+    /// @{
+
+    /// Get whether this attr describes a recursive self reference.
+    bool isRecSelf() { return !getScope(); }
----------------
zyx-billy wrote:

Yeah looking back it was pure luck we had a tag in DICompositeTypeAttr for this 😂 I guess adding an enum tag or a bool flag probably works the same. A tag certainly increases the textual IR a lot... Or, worst case we just make `recId` itself a dedicated attr with DistinctAttr + bool (may be handy if we need it for more nodes later).

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


More information about the Mlir-commits mailing list