Skip to content

Commit c472c6f

Browse files
committed
fix BINARYEN_PASS_DEBUG=2, we must not infinitely recurse the pass printer pass while debugging
1 parent 89b1183 commit c472c6f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/pass.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,9 @@ class Printer : public Pass {
238238
std::ostream& o;
239239

240240
public:
241-
Printer() : o(std::cout) {}
242-
Printer(std::ostream* o) : o(*o) {}
241+
Printer(std::ostream* o = nullptr) : o(o ? *o : std::cout) {
242+
name = "printer";
243+
}
243244

244245
void run(PassRunner* runner, Module* module) override;
245246
};

src/passes/pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void PassRunner::run() {
150150
for (auto* pass : passes) {
151151
// ignoring the time, save a printout of the module before, in case this pass breaks it, so we can print the before and after
152152
std::stringstream moduleBefore;
153-
if (passDebug >= 2) {
153+
if (passDebug >= 2 && pass->name != "printer") { // the printer pass should not infinitely recurse
154154
WasmPrinter::printModule(wasm, moduleBefore);
155155
}
156156
// prepare to run

0 commit comments

Comments
 (0)