[Mlir-commits] [mlir] ae3faea - [MLIR][mlir-opt] move action debugger hook flag (#134842)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Apr 8 07:54:15 PDT 2025
Author: Christopher McGirr
Date: 2025-04-08T16:54:11+02:00
New Revision: ae3faea1f28f840bddd819d1c45e7f7d3e75703c
URL: https://github.com/llvm/llvm-project/commit/ae3faea1f28f840bddd819d1c45e7f7d3e75703c
DIFF: https://github.com/llvm/llvm-project/commit/ae3faea1f28f840bddd819d1c45e7f7d3e75703c.diff
LOG: [MLIR][mlir-opt] move action debugger hook flag (#134842)
Currently if a developer uses the flag `--mlir-enable-debugger-hook` the
debugger hook is not actually enabled. It seems the DebugConfig and the
MainMLIROptConfig are not connected.
To fix this we can move the `enableDebuggerHook` CL Option to the
DebugConfigCLOptions struct so that it can get registered and enabled
along with the other debugger flags. AFAICS there are no other uses of
the flag so this should be safe.
This also adds a small LIT test to check that the hook is enabled by
checking the std::cerr output for the log message.
Added:
mlir/test/mlir-opt/debuggerhook.mlir
Modified:
mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
mlir/lib/Debug/CLOptionsSetup.cpp
mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h b/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
index 09bd86b9581df..af379797fe865 100644
--- a/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
+++ b/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
@@ -238,9 +238,6 @@ class MlirOptMainConfig {
/// Elide resources when generating bytecode.
bool elideResourceDataFromBytecodeFlag = false;
- /// Enable the Debugger action hook: Debugger can intercept MLIR Actions.
- bool enableDebuggerActionHookFlag = false;
-
/// IRDL file to register before processing the input.
std::string irdlFileFlag = "";
diff --git a/mlir/lib/Debug/CLOptionsSetup.cpp b/mlir/lib/Debug/CLOptionsSetup.cpp
index 340055adf5aab..cb0b0e5c375e0 100644
--- a/mlir/lib/Debug/CLOptionsSetup.cpp
+++ b/mlir/lib/Debug/CLOptionsSetup.cpp
@@ -64,6 +64,11 @@ struct DebugConfigCLOptions : public DebugConfig {
auto [file, line, col] = *locBreakpoint;
locBreakpointManager.addBreakpoint(file, line, col);
}));
+
+ static cl::opt<bool, /*ExternalStorage=*/true> enableDebuggerHook(
+ "mlir-enable-debugger-hook",
+ cl::desc("Enable Debugger hook for debugging MLIR Actions"),
+ cl::location(enableDebuggerActionHookFlag), cl::init(false));
}
tracing::FileLineColLocBreakpointManager locBreakpointManager;
};
diff --git a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
index 9bbf91de18305..2924a1205f574 100644
--- a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
+++ b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
@@ -126,11 +126,6 @@ struct MlirOptMainConfigCLOptions : public MlirOptMainConfig {
"mlir-disable-diagnostic-notes", cl::desc("Disable diagnostic notes."),
cl::location(disableDiagnosticNotesFlag), cl::init(false));
- static cl::opt<bool, /*ExternalStorage=*/true> enableDebuggerHook(
- "mlir-enable-debugger-hook",
- cl::desc("Enable Debugger hook for debugging MLIR Actions"),
- cl::location(enableDebuggerActionHookFlag), cl::init(false));
-
static cl::opt<bool, /*ExternalStorage=*/true> explicitModule(
"no-implicit-module",
cl::desc("Disable implicit addition of a top-level module op during "
diff --git a/mlir/test/mlir-opt/debuggerhook.mlir b/mlir/test/mlir-opt/debuggerhook.mlir
new file mode 100644
index 0000000000000..54f1bf98d66df
--- /dev/null
+++ b/mlir/test/mlir-opt/debuggerhook.mlir
@@ -0,0 +1,9 @@
+// Checks that the debugger hook is enabled when called with the CLI option.
+// RUN: mlir-opt %s --mlir-enable-debugger-hook --pass-pipeline="builtin.module(func.func(canonicalize))" --mlir-disable-threading 2>&1 | FileCheck %s
+
+func.func @foo() {
+ return
+}
+
+// CHECK: ExecutionContext registered on the context
+// CHECK-SAME: (with Debugger hook)
More information about the Mlir-commits
mailing list