diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-07-24 13:50:29 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2017-07-24 13:50:29 -0700 |
commit | 96e9398420dd4612bc3f72ad8fedbcbc55e1577a (patch) | |
tree | 5ff129e378a8cf05f08cc6718f4f577d1282f00f | |
parent | 93dcb15eba5051f36dad86d479935dede6f0b05f (diff) | |
download | binaryen-96e9398420dd4612bc3f72ad8fedbcbc55e1577a.tar.gz binaryen-96e9398420dd4612bc3f72ad8fedbcbc55e1577a.tar.bz2 binaryen-96e9398420dd4612bc3f72ad8fedbcbc55e1577a.zip |
when finalizing a block in MergeBlocks, use its type, so that we don't need to consider type changes for its parent (changing it from a forced i32 to an unreachable might mean the parent needs to become unreachable too)
-rw-r--r-- | src/passes/MergeBlocks.cpp | 2 | ||||
-rw-r--r-- | test/passes/merge-blocks.txt | 13 | ||||
-rw-r--r-- | test/passes/merge-blocks.wast | 13 |
3 files changed, 27 insertions, 1 deletions
diff --git a/src/passes/MergeBlocks.cpp b/src/passes/MergeBlocks.cpp index 455e54971..d32948bee 100644 --- a/src/passes/MergeBlocks.cpp +++ b/src/passes/MergeBlocks.cpp @@ -213,7 +213,7 @@ static void optimizeBlock(Block* curr, Module* module) { break; } } - if (changed) curr->finalize(); + if (changed) curr->finalize(curr->type); } void BreakValueDropper::visitBlock(Block* curr) { diff --git a/test/passes/merge-blocks.txt b/test/passes/merge-blocks.txt index dd496df2f..545438b1d 100644 --- a/test/passes/merge-blocks.txt +++ b/test/passes/merge-blocks.txt @@ -87,4 +87,17 @@ ) ) ) + (func $drop-block-squared-iloop (type $0) + (drop + (block $label$0 (result i32) + (block $label$1 + (drop + (loop $label$2 + (br $label$2) + ) + ) + ) + ) + ) + ) ) diff --git a/test/passes/merge-blocks.wast b/test/passes/merge-blocks.wast index 4b2f248e2..e998060c4 100644 --- a/test/passes/merge-blocks.wast +++ b/test/passes/merge-blocks.wast @@ -69,5 +69,18 @@ ) ) ) + (func $drop-block-squared-iloop + (drop + (block $label$0 (result i32) ;; this block's type should not change, so the drop remains none and valid + (drop + (block $label$1 + (loop $label$2 + (br $label$2) + ) + ) + ) + ) + ) + ) ) |