diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-07-16 15:51:20 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-07-16 15:51:20 -0700 |
commit | 8597c85a6066bb2f814f5ab821d307d415493c58 (patch) | |
tree | c7f27fe4d342737516edf752f8b98b043c65d2ef | |
parent | ce8ee20462a465f00520dbe0dd2aa3e1601f4ca1 (diff) | |
download | binaryen-8597c85a6066bb2f814f5ab821d307d415493c58.tar.gz binaryen-8597c85a6066bb2f814f5ab821d307d415493c58.tar.bz2 binaryen-8597c85a6066bb2f814f5ab821d307d415493c58.zip |
fix dce bug in non-parallel mode, which happens in debug mode, and add debug testing
-rwxr-xr-x | check.py | 3 | ||||
-rw-r--r-- | src/passes/DeadCodeElimination.cpp | 7 | ||||
-rw-r--r-- | test/passes/dce.txt | 6 | ||||
-rw-r--r-- | test/passes/dce.wast | 7 |
4 files changed, 22 insertions, 1 deletions
@@ -272,6 +272,9 @@ for t in sorted(os.listdir(os.path.join('test', 'passes'))): with open('split.wast', 'w') as o: o.write(module) cmd = [os.path.join('bin', 'wasm-opt')] + opts + ['split.wast', '--print'] actual += run_command(cmd) + # also check debug mode output is valid + debugged = run_command(cmd + ['--debug'], stderr=subprocess.PIPE) + fail_if_not_contained(actual, debugged) fail_if_not_identical(actual, open(os.path.join('test', 'passes', passname + '.txt')).read()) print '[ checking asm2wasm testcases... ]\n' diff --git a/src/passes/DeadCodeElimination.cpp b/src/passes/DeadCodeElimination.cpp index 9562b2973..de1191131 100644 --- a/src/passes/DeadCodeElimination.cpp +++ b/src/passes/DeadCodeElimination.cpp @@ -40,7 +40,12 @@ struct DeadCodeElimination : public WalkerPass<PostWalker<DeadCodeElimination, V Pass* create() override { return new DeadCodeElimination; } // whether the current code is actually reachable - bool reachable = true; + bool reachable; + + void doWalkFunction(Function* func) { + reachable = true; + walk(func->body); + } std::set<Name> reachableBreaks; diff --git a/test/passes/dce.txt b/test/passes/dce.txt index 3d32d9bed..5f287e183 100644 --- a/test/passes/dce.txt +++ b/test/passes/dce.txt @@ -236,4 +236,10 @@ ) (i32.const 1337) ) + (func $killer + (unreachable) + ) + (func $target + (i32.const 2000) + ) ) diff --git a/test/passes/dce.wast b/test/passes/dce.wast index e76607ecd..dcec20cc1 100644 --- a/test/passes/dce.wast +++ b/test/passes/dce.wast @@ -193,5 +193,12 @@ ) (i32.const 1337) ) + (func $killer + (unreachable) + (i32.const 1000) + ) + (func $target + (i32.const 2000) + ) ) |