Skip to content

Commit ae3faea

Browse files
authored
[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.
1 parent b5045ae commit ae3faea

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,6 @@ class MlirOptMainConfig {
238238
/// Elide resources when generating bytecode.
239239
bool elideResourceDataFromBytecodeFlag = false;
240240

241-
/// Enable the Debugger action hook: Debugger can intercept MLIR Actions.
242-
bool enableDebuggerActionHookFlag = false;
243-
244241
/// IRDL file to register before processing the input.
245242
std::string irdlFileFlag = "";
246243

mlir/lib/Debug/CLOptionsSetup.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ struct DebugConfigCLOptions : public DebugConfig {
6464
auto [file, line, col] = *locBreakpoint;
6565
locBreakpointManager.addBreakpoint(file, line, col);
6666
}));
67+
68+
static cl::opt<bool, /*ExternalStorage=*/true> enableDebuggerHook(
69+
"mlir-enable-debugger-hook",
70+
cl::desc("Enable Debugger hook for debugging MLIR Actions"),
71+
cl::location(enableDebuggerActionHookFlag), cl::init(false));
6772
}
6873
tracing::FileLineColLocBreakpointManager locBreakpointManager;
6974
};

mlir/lib/Tools/mlir-opt/MlirOptMain.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ struct MlirOptMainConfigCLOptions : public MlirOptMainConfig {
126126
"mlir-disable-diagnostic-notes", cl::desc("Disable diagnostic notes."),
127127
cl::location(disableDiagnosticNotesFlag), cl::init(false));
128128

129-
static cl::opt<bool, /*ExternalStorage=*/true> enableDebuggerHook(
130-
"mlir-enable-debugger-hook",
131-
cl::desc("Enable Debugger hook for debugging MLIR Actions"),
132-
cl::location(enableDebuggerActionHookFlag), cl::init(false));
133-
134129
static cl::opt<bool, /*ExternalStorage=*/true> explicitModule(
135130
"no-implicit-module",
136131
cl::desc("Disable implicit addition of a top-level module op during "

mlir/test/mlir-opt/debuggerhook.mlir

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Checks that the debugger hook is enabled when called with the CLI option.
2+
// RUN: mlir-opt %s --mlir-enable-debugger-hook --pass-pipeline="builtin.module(func.func(canonicalize))" --mlir-disable-threading 2>&1 | FileCheck %s
3+
4+
func.func @foo() {
5+
return
6+
}
7+
8+
// CHECK: ExecutionContext registered on the context
9+
// CHECK-SAME: (with Debugger hook)

0 commit comments

Comments
 (0)