[Mlir-commits] [mlir] [MLIR][LLVM] Make DISubprogramAttr cyclic (PR #106571)
Billy Zhu
llvmlistbot at llvm.org
Thu Aug 29 10:54:07 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:
My only slight concern is if it's possible to see a DISubprogram without a scope naturally (it looks like it's allowed to be null [here](https://github.com/llvm/llvm-project/blob/9ce4af5cadc24060f3c3674e01902d374afea983/llvm/lib/IR/Verifier.cpp#L1443) but I'm not sure if it's illegal/impractical elsewhere...). If it's not supposed to happen, can we enforce during import that all llvm's DISubprograms have a scope?
The concern is if we categorize a node as RecSelf when it isn't, we won't be able to tell the outer real node from the inner recursive reference (which triggers an assertion during export).
https://github.com/llvm/llvm-project/pull/106571
More information about the Mlir-commits
mailing list