summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/debugInfo.asm.js26
-rw-r--r--test/debugInfo.fromasm53
-rw-r--r--test/debugInfo.fromasm.imprecise46
-rw-r--r--test/debugInfo.fromasm.imprecise.no-opts75
-rw-r--r--test/debugInfo.fromasm.no-opts77
-rw-r--r--test/passes/dce.txt5
-rw-r--r--test/passes/dce.wast6
7 files changed, 288 insertions, 0 deletions
diff --git a/test/debugInfo.asm.js b/test/debugInfo.asm.js
new file mode 100644
index 000000000..929d79804
--- /dev/null
+++ b/test/debugInfo.asm.js
@@ -0,0 +1,26 @@
+function () {
+ "use asm";
+ function add(x, y) {
+ x = x | 0;
+ y = y | 0;
+ x = x; //@line 5 "tests/hello_world.c"
+ y = y; //@line 6 "tests/hello_world.c"
+ x = y; //@line 314159 "tests/other_file.cpp"
+ return x + y | 0;
+ }
+ function ret(x) {
+ x = x | 0;
+ x = x << 1; //@line 50 "return.cpp"
+ return x + 1 | 0; //@line 100 "return.cpp"
+ }
+ function opts(x, y) {
+ x = x | 0;
+ y = y | 0;
+ x = (x + y) | 0; //@line 1 "even-opted.cpp"
+ y = y >> x; //@line 2 "even-opted.cpp"
+ x = (x | 0) % (y | 0); //@line 3 "even-opted.cpp"
+ return x + y | 0;
+ }
+ return { add: add, ret: ret, opts: opts };
+}
+
diff --git a/test/debugInfo.fromasm b/test/debugInfo.fromasm
new file mode 100644
index 000000000..f073f66a1
--- /dev/null
+++ b/test/debugInfo.fromasm
@@ -0,0 +1,53 @@
+(module
+ (type $FUNCSIG$iii (func (param i32 i32) (result i32)))
+ (type $FUNCSIG$vii (func (param i32 i32)))
+ (import "asm2wasm" "i32s-rem" (func $i32s-rem (param i32 i32) (result i32)))
+ (import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 0 0 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (data (get_global $memoryBase) "debugInfo.asm.js")
+ (export "add" (func $add))
+ (export "ret" (func $ret))
+ (export "opts" (func $opts))
+ (func $add (param $0 i32) (param $1 i32) (result i32)
+ (i32.add
+ (get_local $1)
+ (get_local $1)
+ )
+ )
+ (func $ret (param $0 i32) (result i32)
+ (i32.add
+ (i32.shl
+ (get_local $0)
+ (i32.const 1)
+ )
+ (i32.const 1)
+ )
+ )
+ (func $opts (param $0 i32) (param $1 i32) (result i32)
+ ;; even-opted.cpp:2
+ (set_local $1
+ (i32.shr_s
+ (get_local $1)
+ (tee_local $0
+ (i32.add
+ (get_local $0)
+ (get_local $1)
+ )
+ )
+ )
+ )
+ ;; even-opted.cpp:3
+ (set_local $0
+ (call $i32s-rem
+ (get_local $0)
+ (get_local $1)
+ )
+ )
+ (i32.add
+ (get_local $0)
+ (get_local $1)
+ )
+ )
+)
diff --git a/test/debugInfo.fromasm.imprecise b/test/debugInfo.fromasm.imprecise
new file mode 100644
index 000000000..ac850d495
--- /dev/null
+++ b/test/debugInfo.fromasm.imprecise
@@ -0,0 +1,46 @@
+(module
+ (type $FUNCSIG$vii (func (param i32 i32)))
+ (import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 0 0 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (export "add" (func $add))
+ (export "ret" (func $ret))
+ (export "opts" (func $opts))
+ (func $add (param $0 i32) (param $1 i32) (result i32)
+ (i32.add
+ (get_local $1)
+ (get_local $1)
+ )
+ )
+ (func $ret (param $0 i32) (result i32)
+ (i32.add
+ (i32.shl
+ (get_local $0)
+ (i32.const 1)
+ )
+ (i32.const 1)
+ )
+ )
+ (func $opts (param $0 i32) (param $1 i32) (result i32)
+ ;; even-opted.cpp:2
+ (set_local $1
+ (i32.shr_s
+ (get_local $1)
+ (tee_local $0
+ (i32.add
+ (get_local $0)
+ (get_local $1)
+ )
+ )
+ )
+ )
+ (i32.add
+ (i32.rem_s
+ (get_local $0)
+ (get_local $1)
+ )
+ (get_local $1)
+ )
+ )
+)
diff --git a/test/debugInfo.fromasm.imprecise.no-opts b/test/debugInfo.fromasm.imprecise.no-opts
new file mode 100644
index 000000000..ea20a12f2
--- /dev/null
+++ b/test/debugInfo.fromasm.imprecise.no-opts
@@ -0,0 +1,75 @@
+(module
+ (type $FUNCSIG$vii (func (param i32 i32)))
+ (import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 0 0 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (export "add" (func $add))
+ (export "ret" (func $ret))
+ (export "opts" (func $opts))
+ (func $add (param $x i32) (param $y i32) (result i32)
+ ;; tests/hello_world.c:5
+ (set_local $x
+ (get_local $x)
+ )
+ ;; tests/hello_world.c:6
+ (set_local $y
+ (get_local $y)
+ )
+ ;; tests/other_file.cpp:314159
+ (set_local $x
+ (get_local $y)
+ )
+ (return
+ (i32.add
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ )
+ (func $ret (param $x i32) (result i32)
+ ;; return.cpp:50
+ (set_local $x
+ (i32.shl
+ (get_local $x)
+ (i32.const 1)
+ )
+ )
+ ;; return.cpp:100
+ (return
+ (i32.add
+ (get_local $x)
+ (i32.const 1)
+ )
+ )
+ )
+ (func $opts (param $x i32) (param $y i32) (result i32)
+ ;; even-opted.cpp:1
+ (set_local $x
+ (i32.add
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ ;; even-opted.cpp:2
+ (set_local $y
+ (i32.shr_s
+ (get_local $y)
+ (get_local $x)
+ )
+ )
+ ;; even-opted.cpp:3
+ (set_local $x
+ (i32.rem_s
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ (return
+ (i32.add
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ )
+)
diff --git a/test/debugInfo.fromasm.no-opts b/test/debugInfo.fromasm.no-opts
new file mode 100644
index 000000000..0e450a5ab
--- /dev/null
+++ b/test/debugInfo.fromasm.no-opts
@@ -0,0 +1,77 @@
+(module
+ (type $FUNCSIG$iii (func (param i32 i32) (result i32)))
+ (type $FUNCSIG$vii (func (param i32 i32)))
+ (import "asm2wasm" "i32s-rem" (func $i32s-rem (param i32 i32) (result i32)))
+ (import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 0 0 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (export "add" (func $add))
+ (export "ret" (func $ret))
+ (export "opts" (func $opts))
+ (func $add (param $x i32) (param $y i32) (result i32)
+ ;; tests/hello_world.c:5
+ (set_local $x
+ (get_local $x)
+ )
+ ;; tests/hello_world.c:6
+ (set_local $y
+ (get_local $y)
+ )
+ ;; tests/other_file.cpp:314159
+ (set_local $x
+ (get_local $y)
+ )
+ (return
+ (i32.add
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ )
+ (func $ret (param $x i32) (result i32)
+ ;; return.cpp:50
+ (set_local $x
+ (i32.shl
+ (get_local $x)
+ (i32.const 1)
+ )
+ )
+ ;; return.cpp:100
+ (return
+ (i32.add
+ (get_local $x)
+ (i32.const 1)
+ )
+ )
+ )
+ (func $opts (param $x i32) (param $y i32) (result i32)
+ ;; even-opted.cpp:1
+ (set_local $x
+ (i32.add
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ ;; even-opted.cpp:2
+ (set_local $y
+ (i32.shr_s
+ (get_local $y)
+ (get_local $x)
+ )
+ )
+ ;; even-opted.cpp:3
+ (set_local $x
+ (call $i32s-rem
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ (return
+ (i32.add
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ )
+)
diff --git a/test/passes/dce.txt b/test/passes/dce.txt
index 71b46bd94..84757294a 100644
--- a/test/passes/dce.txt
+++ b/test/passes/dce.txt
@@ -332,4 +332,9 @@
(func $global (type $1)
(unreachable)
)
+ (func $ret (type $2) (result i32)
+ (return
+ (i32.const 0)
+ )
+ )
)
diff --git a/test/passes/dce.wast b/test/passes/dce.wast
index ad1d1d3c0..b7d903e6b 100644
--- a/test/passes/dce.wast
+++ b/test/passes/dce.wast
@@ -435,4 +435,10 @@
(drop (get_global $x))
(set_global $x (i32.const 1))
)
+ (func $ret (result i32)
+ (return
+ (i32.const 0)
+ )
+ (nop)
+ )
)