summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-11-17 21:36:40 -0800
committerGitHub <noreply@github.com>2017-11-17 21:36:40 -0800
commit8a6964014cc1198acda11646c4b2f79406c5fec2 (patch)
tree398a300e052afa01783249337b866c364c43c6ec /test
parentda0c45566118c863f12a2edb004e28a084ef5660 (diff)
downloadbinaryen-8a6964014cc1198acda11646c4b2f79406c5fec2.tar.gz
binaryen-8a6964014cc1198acda11646c4b2f79406c5fec2.tar.bz2
binaryen-8a6964014cc1198acda11646c4b2f79406c5fec2.zip
Fix a code-folding fuzz bug (#1282)
* fix a code-folding bug where when merging function-level tails, we moved code out of where it could reach a break target - we must not move code if it has a break target not enclosed in itself. the EffectAnalyzer already had the functionality for that, move the code around a little there to make that clearer too
Diffstat (limited to 'test')
-rw-r--r--test/passes/code-folding.txt57
-rw-r--r--test/passes/code-folding.wast62
2 files changed, 119 insertions, 0 deletions
diff --git a/test/passes/code-folding.txt b/test/passes/code-folding.txt
index 031f93b91..e11999ac8 100644
--- a/test/passes/code-folding.txt
+++ b/test/passes/code-folding.txt
@@ -49,4 +49,61 @@
(f32.const 0)
)
)
+ (func $break-target-outside-of-return-merged-code (; 4 ;) (type $1)
+ (block $label$A
+ (if
+ (unreachable)
+ (block $block
+ (block $block0
+ (block $label$B
+ (if
+ (unreachable)
+ (br_table $label$A $label$B
+ (unreachable)
+ )
+ )
+ )
+ (return)
+ )
+ )
+ (block $block2
+ (block $label$C
+ (if
+ (unreachable)
+ (br_table $label$A $label$C
+ (unreachable)
+ )
+ )
+ )
+ (return)
+ )
+ )
+ )
+ )
+ (func $break-target-inside-all-good (; 5 ;) (type $1)
+ (block $folding-inner0
+ (block $label$A
+ (if
+ (unreachable)
+ (block $block
+ (block $block4
+ (br $folding-inner0)
+ )
+ )
+ (block $block6
+ (br $folding-inner0)
+ )
+ )
+ )
+ )
+ (block $label$B
+ (if
+ (unreachable)
+ (br_table $label$B $label$B
+ (unreachable)
+ )
+ )
+ )
+ (return)
+ )
)
diff --git a/test/passes/code-folding.wast b/test/passes/code-folding.wast
index 32a32b28b..2064f2db6 100644
--- a/test/passes/code-folding.wast
+++ b/test/passes/code-folding.wast
@@ -52,5 +52,67 @@
)
)
)
+ (func $break-target-outside-of-return-merged-code
+ (block $label$A
+ (if
+ (unreachable)
+ (block
+ (block
+ (block $label$B
+ (if
+ (unreachable)
+ (br_table $label$A $label$B
+ (unreachable)
+ )
+ )
+ )
+ (return)
+ )
+ )
+ (block
+ (block $label$C
+ (if
+ (unreachable)
+ (br_table $label$A $label$C ;; this all looks mergeable, but $label$A is outside
+ (unreachable)
+ )
+ )
+ )
+ (return)
+ )
+ )
+ )
+ )
+ (func $break-target-inside-all-good
+ (block $label$A
+ (if
+ (unreachable)
+ (block
+ (block
+ (block $label$B
+ (if
+ (unreachable)
+ (br_table $label$B $label$B
+ (unreachable)
+ )
+ )
+ )
+ (return)
+ )
+ )
+ (block
+ (block $label$C
+ (if
+ (unreachable)
+ (br_table $label$C $label$C ;; this all looks mergeable, and is, B ~~ C
+ (unreachable)
+ )
+ )
+ )
+ (return)
+ )
+ )
+ )
+ )
)