[Mlir-commits] [mlir] [mlir][debug] Add option `emissionKind` to DIScopeForLLVMFuncOp pass. (PR #106229)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Aug 27 07:15:46 PDT 2024
https://github.com/Observer007 created https://github.com/llvm/llvm-project/pull/106229
Master uses determined `DIEmissionKind::LineTablesOnly` in DIScopeForLLVMFuncOp pass. This mr add options to control this flag.
>From cdf116921f44c0394feb69468642e6b41ccb16f4 Mon Sep 17 00:00:00 2001
From: jingzec <jingzec at nvidia.com>
Date: Tue, 27 Aug 2024 02:43:40 -0700
Subject: [PATCH 1/2] add options for DIScopeforLLVMFuncOp pass
---
mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td | 4 ++++
mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
index 11d1b941107141..1ba61d2addfcb7 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
@@ -61,6 +61,10 @@ def DIScopeForLLVMFuncOp : Pass<"ensure-debug-info-scope-on-llvm-func", "::mlir:
}];
let constructor = "mlir::LLVM::createDIScopeForLLVMFuncOpPass()";
+ let options = [
+ Option<"emissionKind", "emission-kind", "mlir::LLVM::DIEmissionKind",
+ /*default=*/"mlir::LLVM::DIEmissionKind::LineTablesOnly", "Emission kind to generate debug info.">,
+ ];
}
#endif // MLIR_DIALECT_LLVMIR_TRANSFORMS_PASSES
diff --git a/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp b/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp
index 395ff6ed1e48ea..43e0820a5ed1a3 100644
--- a/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp
+++ b/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp
@@ -117,7 +117,7 @@ struct DIScopeForLLVMFuncOp
compileUnitAttr = LLVM::DICompileUnitAttr::get(
DistinctAttr::create(UnitAttr::get(context)), llvm::dwarf::DW_LANG_C,
fileAttr, StringAttr::get(context, "MLIR"),
- /*isOptimized=*/true, LLVM::DIEmissionKind::LineTablesOnly);
+ /*isOptimized=*/true, emissionKind);
}
// Create subprograms for each function with the same distinct compile unit.
>From c34f0c258967fa1c68ba8c38b134c06b766f5081 Mon Sep 17 00:00:00 2001
From: jingzec <jingzec at nvidia.com>
Date: Tue, 27 Aug 2024 07:10:30 -0700
Subject: [PATCH 2/2] add tests
---
mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h | 2 ++
mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td | 8 +++++++-
mlir/test/Dialect/LLVMIR/add-debuginfo-func-scope.mlir | 2 ++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h
index a7bf8796c0277f..078c7d12f6f22b 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h
@@ -9,6 +9,7 @@
#ifndef MLIR_DIALECT_LLVMIR_TRANSFORMS_PASSES_H
#define MLIR_DIALECT_LLVMIR_TRANSFORMS_PASSES_H
+#include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
#include "mlir/Dialect/LLVMIR/Transforms/AddComdats.h"
#include "mlir/Dialect/LLVMIR/Transforms/LegalizeForExport.h"
#include "mlir/Dialect/LLVMIR/Transforms/OptimizeForNVVM.h"
@@ -23,6 +24,7 @@ namespace LLVM {
std::unique_ptr<Pass> createDIScopeForLLVMFuncOpPass();
/// Generate the code for registering conversion passes.
+#define GEN_PASS_DECL
#define GEN_PASS_REGISTRATION
#include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc"
diff --git a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
index 1ba61d2addfcb7..d54bc55c9edaab 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
@@ -63,7 +63,13 @@ def DIScopeForLLVMFuncOp : Pass<"ensure-debug-info-scope-on-llvm-func", "::mlir:
let constructor = "mlir::LLVM::createDIScopeForLLVMFuncOpPass()";
let options = [
Option<"emissionKind", "emission-kind", "mlir::LLVM::DIEmissionKind",
- /*default=*/"mlir::LLVM::DIEmissionKind::LineTablesOnly", "Emission kind to generate debug info.">,
+ /*default=*/"mlir::LLVM::DIEmissionKind::LineTablesOnly", "Emission kind to generate debug info.",
+ [{::llvm::cl::values(
+ clEnumValN(::mlir::LLVM::DIEmissionKind::None, "None", "None"),
+ clEnumValN(::mlir::LLVM::DIEmissionKind::Full, "Full", "Full"),
+ clEnumValN(::mlir::LLVM::DIEmissionKind::LineTablesOnly, "LineTablesOnly", "LineTablesOnly (default)"),
+ clEnumValN(::mlir::LLVM::DIEmissionKind::DebugDirectivesOnly, "DebugDirectivesOnly", "DebugDirectivesOnly")
+ )}]>,
];
}
diff --git a/mlir/test/Dialect/LLVMIR/add-debuginfo-func-scope.mlir b/mlir/test/Dialect/LLVMIR/add-debuginfo-func-scope.mlir
index f63132d42ab713..df7fe2c5c615a1 100644
--- a/mlir/test/Dialect/LLVMIR/add-debuginfo-func-scope.mlir
+++ b/mlir/test/Dialect/LLVMIR/add-debuginfo-func-scope.mlir
@@ -1,4 +1,5 @@
// RUN: mlir-opt %s --pass-pipeline="builtin.module(ensure-debug-info-scope-on-llvm-func)" --split-input-file --mlir-print-debuginfo | FileCheck %s
+// RUN: mlir-opt %s --pass-pipeline="builtin.module(ensure-debug-info-scope-on-llvm-func{emission-kind=DebugDirectivesOnly})" --split-input-file --mlir-print-debuginfo | FileCheck --check-prefix=CHECK_OTHER_KIND %s
// CHECK-LABEL: llvm.func @func_no_debug()
// CHECK: llvm.return loc(#loc
@@ -31,6 +32,7 @@ module {
// CHECK: #di_file = #llvm.di_file<"<unknown>" in "">
// CHECK: #di_subprogram = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #di_compile_unit, scope = #di_file, name = "func_with_debug", linkageName = "func_with_debug", file = #di_file, line = 42, scopeLine = 42, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type>
// CHECK: #loc[[LOC]] = loc(fused<#di_subprogram>
+// CHECK_OTHER_KIND: emissionKind = DebugDirectivesOnly
module {
llvm.func @func_with_debug() {
llvm.return loc(#loc1)
More information about the Mlir-commits
mailing list