summaryrefslogtreecommitdiff
path: root/src/passes/pass.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-05-18 10:47:23 -0700
committerGitHub <noreply@github.com>2017-05-18 10:47:23 -0700
commit9c6b8e0f626ade30cee113294019edbdbf29dd36 (patch)
treeda088ba8eef1d3d20f1f0e9fa3b5af2c8dbeba1d /src/passes/pass.cpp
parentbb1c44a3f975bf8fb72216b9c04bcd34e31bd815 (diff)
downloadbinaryen-9c6b8e0f626ade30cee113294019edbdbf29dd36.tar.gz
binaryen-9c6b8e0f626ade30cee113294019edbdbf29dd36.tar.bz2
binaryen-9c6b8e0f626ade30cee113294019edbdbf29dd36.zip
Validate finalization (#1014)
* validate that types are properly finalized, when in pass-debug mode (BINARYEN_PASS_DEBUG env var): check after each pass is run that the type of each node is equal to the proper type (when finalizing it, i.e., fully recomputing the type). * fix many fuzz bugs found by that. * in particular, fix dce bugs with type changes not being fully updated during code removal. add a new TypeUpdater helper class that lets a pass update types efficiently, by the helper tracking deps between blocks and branches etc., and updating/propagating type changes only as necessary.
Diffstat (limited to 'src/passes/pass.cpp')
-rw-r--r--src/passes/pass.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp
index 7b4a896eb..2fb0d5c3b 100644
--- a/src/passes/pass.cpp
+++ b/src/passes/pass.cpp
@@ -166,11 +166,7 @@ static void dumpWast(Name name, Module* wasm) {
}
void PassRunner::run() {
- // 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;
+ static const int passDebug = getPassDebug();
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);
@@ -212,7 +208,7 @@ void PassRunner::run() {
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=2 in the env to see the earlier state (FIXME: this is broken, need to prevent recursion of the print pass\n";
+ std::cerr << "Last pass (" << pass->name << ") broke validation. Run with BINARYEN_PASS_DEBUG=2 in the env to see the earlier state, or 3 to dump byn-* files for each pass\n";
}
abort();
}
@@ -300,4 +296,9 @@ void PassRunner::runPassOnFunction(Pass* pass, Function* func) {
instance->runFunction(this, wasm, func);
}
+int PassRunner::getPassDebug() {
+ static const int passDebug = getenv("BINARYEN_PASS_DEBUG") ? atoi(getenv("BINARYEN_PASS_DEBUG")) : 0;
+ return passDebug;
+}
+
} // namespace wasm