-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[mlir][debug] Inherit DISubprogramAttr from DILocalScopeAttr. #156081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This better matches the hierarchy in llvm.
|
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-llvm Author: Abid Qadeer (abidh) ChangesAs mentioned in #154926, Full diff: https://github.com/llvm/llvm-project/pull/156081.diff 2 Files Affected:
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
index bfce904a18d4f..407078533ef5c 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
@@ -638,7 +638,7 @@ def LLVM_DILocalVariableAttr : LLVM_Attr<"DILocalVariable", "di_local_variable",
def LLVM_DISubprogramAttr : LLVM_Attr<"DISubprogram", "di_subprogram",
[LLVM_DIRecursiveTypeAttrInterface],
- "DIScopeAttr"> {
+ "DILocalScopeAttr"> {
let parameters = (ins
// DIRecursiveTypeAttrInterface specific parameters.
OptionalParameter<"DistinctAttr">:$recId,
diff --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
index 3b7e6eda0841d..fd8463ad1a8e2 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -362,7 +362,8 @@ static void convertModuleFlagsOp(ArrayAttr flags, llvm::IRBuilderBase &builder,
static llvm::DILocalScope *
getLocalScopeFromLoc(llvm::IRBuilderBase &builder, Location loc,
LLVM::ModuleTranslation &moduleTranslation) {
- if (auto scopeLoc = loc->findInstanceOf<FusedLocWith<LLVM::DIScopeAttr>>())
+ if (auto scopeLoc =
+ loc->findInstanceOf<FusedLocWith<LLVM::DILocalScopeAttr>>())
if (auto *localScope = llvm::dyn_cast<llvm::DILocalScope>(
moduleTranslation.translateDebugInfo(scopeLoc.getMetadata())))
return localScope;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the followup.
LGTM
Can you update the base class for DILexicalBlockAttr and DILexicalBlockFileAttr as well? It seems like this is an inconsistency from a previous refactor.
| def LLVM_DISubprogramAttr : LLVM_Attr<"DISubprogram", "di_subprogram", | ||
| [LLVM_DIRecursiveTypeAttrInterface], | ||
| "DIScopeAttr"> { | ||
| "DILocalScopeAttr"> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at:
| bool DILocalScopeAttr::classof(Attribute attr) { |
It seems like the base classes of DILexicalBlockAttr and DILexicalBlockFileAttr should also derive from DILocalScopeAttr rather than from DIScopeAttr. Can you update them as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the code a bit more, the DILexicalBlockAttr and DILexicalBlockFileAttr have scope parameters which are DIScopeAttr but probably needs to be DILocalScopeAttr. I tried a few quick changes but they soon became more invasive. I would leave them for later PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok 👍
The DILexicalBlockAttr and DILexicalBlockFileAttr also inherits from the DILocalScopeAttr.
As mentioned in #154926,
DISubprogramAttris inherited fromDIScopeAttrwhile in llvm, theDISubprograminherits fromDILocalScope. This change corrects the hierarchy.