[Mlir-commits] [mlir] [MLIR][DebugInfo] Enable the use of DILocalVariable DIFlags (PR #100190)
Walter Erquinigo
llvmlistbot at llvm.org
Tue Jul 23 13:08:12 PDT 2024
https://github.com/walter-erquinigo created https://github.com/llvm/llvm-project/pull/100190
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.
>From 1f03bd04bf2d3fa9cced7293e1e4891128d90e18 Mon Sep 17 00:00:00 2001
From: walter erquinigo <walter at modular.com>
Date: Fri, 19 Jul 2024 22:31:01 -0400
Subject: [PATCH] [MLIR][DebugInfo] Enable the use of DILocalVariable DIFlags
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.
---
mlir/include/mlir-c/Dialect/LLVM.h | 2 +-
mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td | 7 ++++---
mlir/lib/CAPI/Dialect/LLVM.cpp | 11 +++++------
mlir/lib/Target/LLVMIR/DebugImporter.cpp | 3 ++-
mlir/lib/Target/LLVMIR/DebugTranslation.cpp | 4 ++--
5 files changed, 14 insertions(+), 13 deletions(-)
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);
}
More information about the Mlir-commits
mailing list