Skip to content

Commit 03efc29

Browse files
Chris DoddChrisDodd
authored andcommitted
option to recursively add debug hooks to child pass managers
1 parent dc45e9e commit 03efc29

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

ir/pass_manager.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,18 @@ class PassManager : virtual public Visitor, virtual public Backtrack {
4949
bool backtrack(trigger &trig) override;
5050
bool never_backtracks() override;
5151
void setStopOnError(bool stop) { stop_on_error = stop; }
52-
void addDebugHook(DebugHook h) { debugHooks.push_back(h); }
53-
void addDebugHooks(std::vector<DebugHook> hooks)
54-
{ debugHooks.insert(debugHooks.end(), hooks.begin(), hooks.end()); }
52+
void addDebugHook(DebugHook h, bool recursive = false) {
53+
debugHooks.push_back(h);
54+
if (recursive)
55+
for (auto pass : passes)
56+
if (auto child = dynamic_cast<PassManager *>(pass))
57+
child->addDebugHook(h, recursive); }
58+
void addDebugHooks(std::vector<DebugHook> hooks, bool recursive = false) {
59+
debugHooks.insert(debugHooks.end(), hooks.begin(), hooks.end());
60+
if (recursive)
61+
for (auto pass : passes)
62+
if (auto child = dynamic_cast<PassManager *>(pass))
63+
child->addDebugHooks(hooks, recursive); }
5564
void early_exit() { early_exit_flag = true; }
5665
};
5766

0 commit comments

Comments
 (0)