summaryrefslogtreecommitdiff
path: root/src/passes/pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/pass.cpp')
-rw-r--r--src/passes/pass.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp
index df98590c5..081164d90 100644
--- a/src/passes/pass.cpp
+++ b/src/passes/pass.cpp
@@ -142,7 +142,12 @@ void PassRunner::addDefaultGlobalOptimizationPasses() {
}
void PassRunner::run() {
- if (options.debug) {
+ // BINARYEN_PASS_DEBUG is a convenient commandline way to log out the toplevel passes, their times,
+ // and validate between each pass.
+ // (we don't recurse pass debug into sub-passes, as it doesn't help anyhow and
+ // also is bad for e.g. printing which is a pass)
+ static const int passDebug = getenv("BINARYEN_PASS_DEBUG") ? atoi(getenv("BINARYEN_PASS_DEBUG")) : 0;
+ if (!isNested && (options.debug || passDebug)) {
// for debug logging purposes, run each pass in full before running the other
auto totalTime = std::chrono::duration<double>(0);
size_t padding = 0;
@@ -150,11 +155,10 @@ void PassRunner::run() {
for (auto pass : passes) {
padding = std::max(padding, pass->name.size());
}
- bool passDebug = getenv("BINARYEN_PASS_DEBUG") && getenv("BINARYEN_PASS_DEBUG")[0] != '0';
for (auto* pass : passes) {
// ignoring the time, save a printout of the module before, in case this pass breaks it, so we can print the before and after
std::stringstream moduleBefore;
- if (passDebug) {
+ if (passDebug == 2) {
WasmPrinter::printModule(wasm, moduleBefore);
}
// prepare to run
@@ -178,10 +182,10 @@ void PassRunner::run() {
// validate, ignoring the time
std::cerr << "[PassRunner] (validating)\n";
if (!WasmValidator().validate(*wasm, false, options.validateGlobally)) {
- if (passDebug) {
+ if (passDebug >= 2) {
std::cerr << "Last pass (" << pass->name << ") broke validation. Here is the module before: \n" << moduleBefore.str() << "\n";
} else {
- std::cerr << "Last pass (" << pass->name << ") broke validation. Run with BINARYEN_PASS_DEBUG=1 in the env to see the earlier state\n";
+ std::cerr << "Last pass (" << pass->name << ") broke validation. Run with BINARYEN_PASS_DEBUG=2 in the env to see the earlier state (FIXME: this is broken, need to prevent recursion of the print pass\n";
}
abort();
}