summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-11-07 10:41:05 -0800
committerGitHub <noreply@github.com>2018-11-07 10:41:05 -0800
commit30f0e0a6c9df43f3a70089629b6baa11688bfce4 (patch)
treec5ca79ea2ccd84df42efe19202b41aa6e6aa6213 /test
parentb2070673bd4f6e4eb9eb7707bc0e64c76e9ecef7 (diff)
downloadbinaryen-30f0e0a6c9df43f3a70089629b6baa11688bfce4.tar.gz
binaryen-30f0e0a6c9df43f3a70089629b6baa11688bfce4.tar.bz2
binaryen-30f0e0a6c9df43f3a70089629b6baa11688bfce4.zip
Fix a DataFlowOpts bug (#1729)
We create some fake nodes for internal use, and were looking at one by mistake. This fixes that by * Creating a non-ambiguous fake node, a call (which represents an unknown value properly, unlike a zero which we had before). * Make DFO not rely on those values, if it knows a node is constant, apply those constant values. Found by the fuzzer.
Diffstat (limited to 'test')
-rw-r--r--test/passes/flatten_dfo_O3.txt5
-rw-r--r--test/passes/flatten_dfo_O3.wast16
2 files changed, 21 insertions, 0 deletions
diff --git a/test/passes/flatten_dfo_O3.txt b/test/passes/flatten_dfo_O3.txt
index 02cdbfa86..c0e8a8811 100644
--- a/test/passes/flatten_dfo_O3.txt
+++ b/test/passes/flatten_dfo_O3.txt
@@ -3,12 +3,14 @@
(type $1 (func (param i32 i32) (result i32)))
(type $2 (func (param i64 i32) (result f64)))
(type $3 (func (param f64) (result f64)))
+ (type $4 (func (result i32)))
(memory $0 (shared 1 1))
(export "one" (func $0))
(export "two" (func $1))
(export "use-var" (func $2))
(export "bad1" (func $3))
(export "only-dfo" (func $4))
+ (export "dfo-tee-get" (func $5))
(func $0 (; 0 ;) (; has Stack IR ;) (type $0)
(loop $label$2
(block $label$3
@@ -47,4 +49,7 @@
(br $label$1)
)
)
+ (func $5 (; 5 ;) (; has Stack IR ;) (type $4) (result i32)
+ (i32.const 1)
+ )
)
diff --git a/test/passes/flatten_dfo_O3.wast b/test/passes/flatten_dfo_O3.wast
index 512315995..7ba5a2fd6 100644
--- a/test/passes/flatten_dfo_O3.wast
+++ b/test/passes/flatten_dfo_O3.wast
@@ -183,5 +183,21 @@
(br $label$1)
)
)
+ (func "dfo-tee-get" (result i32)
+ (local $0 i32)
+ (if (result i32)
+ (tee_local $0
+ (i32.const 1)
+ )
+ (loop $label$2 (result i32)
+ (select
+ (i32.const 1)
+ (i32.const -1709605511)
+ (get_local $0)
+ )
+ )
+ (unreachable)
+ )
+ )
)