-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[MLIR][DebugInfo] Enable the use of DILocalVariable DIFlags #100190
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
[MLIR][DebugInfo] Enable the use of DILocalVariable DIFlags #100190
Conversation
@llvm/pr-subscribers-flang-fir-hlfir @llvm/pr-subscribers-mlir Author: Walter Erquinigo (walter-erquinigo) ChangesThis patch enables the use of flags for local variables in debug info. They were defaulted as always zero, but allowing them is pretty trivial. Full diff: https://github.com/llvm/llvm-project/pull/100190.diff 5 Files Affected:
diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h
index 902b45444d6c4..631b564618320 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -309,7 +309,7 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(
MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDILocalVariableAttrGet(
MlirContext ctx, MlirAttribute scope, MlirAttribute name,
MlirAttribute diFile, unsigned int line, unsigned int arg,
- unsigned int alignInBits, MlirAttribute diType);
+ unsigned int alignInBits, MlirAttribute diType, int64_t flags);
/// Creates a LLVM DISubprogramAttr attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDISubprogramAttrGet(
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
index aefc02bce40fb..695a962bcab9b 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
@@ -532,17 +532,18 @@ def LLVM_DILocalVariableAttr : LLVM_Attr<"DILocalVariable", "di_local_variable",
OptionalParameter<"unsigned">:$line,
OptionalParameter<"unsigned">:$arg,
OptionalParameter<"unsigned">:$alignInBits,
- OptionalParameter<"DITypeAttr">:$type
+ OptionalParameter<"DITypeAttr">:$type,
+ OptionalParameter<"DIFlags", "DIFlags::Zero">:$flags
);
let builders = [
AttrBuilderWithInferredContext<(ins
"DIScopeAttr":$scope, "StringRef":$name, "DIFileAttr":$file,
"unsigned":$line, "unsigned":$arg, "unsigned":$alignInBits,
- "DITypeAttr":$type
+ "DITypeAttr":$type, "DIFlags":$flags
), [{
MLIRContext *ctx = scope.getContext();
return $_get(ctx, scope, StringAttr::get(ctx, name), file, line,
- arg, alignInBits, type);
+ arg, alignInBits, type, flags);
}]>
];
let assemblyFormat = "`<` struct(params) `>`";
diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index 754c94511524d..03e2f2be2156a 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -266,15 +266,14 @@ MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(MlirContext ctx,
cast<DIFileAttr>(unwrap(file)), discriminator));
}
-MlirAttribute
-mlirLLVMDILocalVariableAttrGet(MlirContext ctx, MlirAttribute scope,
- MlirAttribute name, MlirAttribute diFile,
- unsigned int line, unsigned int arg,
- unsigned int alignInBits, MlirAttribute diType) {
+MlirAttribute mlirLLVMDILocalVariableAttrGet(
+ MlirContext ctx, MlirAttribute scope, MlirAttribute name,
+ MlirAttribute diFile, unsigned int line, unsigned int arg,
+ unsigned int alignInBits, MlirAttribute diType, int64_t flags) {
return wrap(DILocalVariableAttr::get(
unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
cast<StringAttr>(unwrap(name)), cast<DIFileAttr>(unwrap(diFile)), line,
- arg, alignInBits, cast<DITypeAttr>(unwrap(diType))));
+ arg, alignInBits, cast<DITypeAttr>(unwrap(diType)), DIFlags(flags)));
}
MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx,
diff --git a/mlir/lib/Target/LLVMIR/DebugImporter.cpp b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
index f104b72209c39..1817c1271b43e 100644
--- a/mlir/lib/Target/LLVMIR/DebugImporter.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
@@ -180,7 +180,8 @@ DILocalVariableAttr DebugImporter::translateImpl(llvm::DILocalVariable *node) {
return DILocalVariableAttr::get(
context, scope, getStringAttrOrNull(node->getRawName()),
translate(node->getFile()), node->getLine(), node->getArg(),
- node->getAlignInBits(), translate(node->getType()));
+ node->getAlignInBits(), translate(node->getType()),
+ symbolizeDIFlags(node->getFlags()).value_or(DIFlags::Zero));
}
DIVariableAttr DebugImporter::translateImpl(llvm::DIVariable *node) {
diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
index 35800e993d89d..9a248a6f06ddd 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
@@ -228,8 +228,8 @@ DebugTranslation::translateImpl(DILocalVariableAttr attr) {
return llvm::DILocalVariable::get(
llvmCtx, translate(attr.getScope()), getMDStringOrNull(attr.getName()),
translate(attr.getFile()), attr.getLine(), translate(attr.getType()),
- attr.getArg(),
- /*Flags=*/llvm::DINode::FlagZero, attr.getAlignInBits(),
+ attr.getArg(), (llvm::DINode::DIFlags)attr.getFlags(),
+ attr.getAlignInBits(),
/*Annotations=*/nullptr);
}
|
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.
Not my chunk of the codebase, but this looks like a trivial change that won't cause issues,so lgtm (unless someone comes by to have an opinion who knows this stuff)
@@ -228,8 +228,8 @@ DebugTranslation::translateImpl(DILocalVariableAttr attr) { | |||
return llvm::DILocalVariable::get( | |||
llvmCtx, translate(attr.getScope()), getMDStringOrNull(attr.getName()), | |||
translate(attr.getFile()), attr.getLine(), translate(attr.getType()), | |||
attr.getArg(), | |||
/*Flags=*/llvm::DINode::FlagZero, attr.getAlignInBits(), | |||
attr.getArg(), (llvm::DINode::DIFlags)attr.getFlags(), |
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.
static_cast
, maybe?
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.
good suggestion!
1f03bd0
to
b60fb5f
Compare
Added tests |
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.
LGTM!
This patch enables the use of flags for local variables in debug info. They were defaulted as always zero, but allowing them is pretty trivial.
b60fb5f
to
d66fe3b
Compare
Summary: This patch enables the use of flags for local variables in debug info. They were defaulted as always zero, but allowing them is pretty trivial. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250663
This patch enables the use of flags for local variables in debug info. They were defaulted as always zero, but allowing them is pretty trivial.