summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/merge/basics.wast38
-rw-r--r--test/merge/basics.wast.combined133
-rw-r--r--test/merge/basics.wast.combined.finalized133
-rw-r--r--test/merge/basics.wast.combined.finalized.opt86
-rw-r--r--test/merge/basics.wast.combined.finalized.opt.stdout3
-rw-r--r--test/merge/basics.wast.combined.finalized.stdout3
-rw-r--r--test/merge/basics.wast.combined.opt122
-rw-r--r--test/merge/basics.wast.combined.opt.stdout3
-rw-r--r--test/merge/basics.wast.combined.stdout3
-rw-r--r--test/merge/basics.wast.toMerge63
-rw-r--r--test/merge/dylib.wasmbin0 -> 364 bytes
-rw-r--r--test/merge/dylib.wasm.combined91
-rw-r--r--test/merge/dylib.wasm.combined.finalized91
-rw-r--r--test/merge/dylib.wasm.combined.finalized.opt81
-rw-r--r--test/merge/dylib.wasm.combined.finalized.opt.stdout3
-rw-r--r--test/merge/dylib.wasm.combined.finalized.stdout3
-rw-r--r--test/merge/dylib.wasm.combined.opt90
-rw-r--r--test/merge/dylib.wasm.combined.opt.stdout3
-rw-r--r--test/merge/dylib.wasm.combined.stdout3
-rw-r--r--test/merge/dylib.wasm.toMergebin0 -> 318 bytes
-rw-r--r--test/merge/fusing.wast18
-rw-r--r--test/merge/fusing.wast.combined44
-rw-r--r--test/merge/fusing.wast.combined.finalized44
-rw-r--r--test/merge/fusing.wast.combined.finalized.opt32
-rw-r--r--test/merge/fusing.wast.combined.finalized.opt.stdout3
-rw-r--r--test/merge/fusing.wast.combined.finalized.stdout3
-rw-r--r--test/merge/fusing.wast.combined.opt35
-rw-r--r--test/merge/fusing.wast.combined.opt.stdout3
-rw-r--r--test/merge/fusing.wast.combined.stdout3
-rw-r--r--test/merge/fusing.wast.toMerge20
-rw-r--r--test/merge/global-init.wast10
-rw-r--r--test/merge/global-init.wast.combined16
-rw-r--r--test/merge/global-init.wast.combined.finalized16
-rw-r--r--test/merge/global-init.wast.combined.finalized.opt5
-rw-r--r--test/merge/global-init.wast.combined.finalized.opt.stdout3
-rw-r--r--test/merge/global-init.wast.combined.finalized.stdout3
-rw-r--r--test/merge/global-init.wast.combined.opt8
-rw-r--r--test/merge/global-init.wast.combined.opt.stdout3
-rw-r--r--test/merge/global-init.wast.combined.stdout3
-rw-r--r--test/merge/global-init.wast.toMerge10
-rw-r--r--test/merge/main-lacks-segments.wast7
-rw-r--r--test/merge/main-lacks-segments.wast.combined25
-rw-r--r--test/merge/main-lacks-segments.wast.combined.finalized25
-rw-r--r--test/merge/main-lacks-segments.wast.combined.finalized.opt10
-rw-r--r--test/merge/main-lacks-segments.wast.combined.finalized.opt.stdout3
-rw-r--r--test/merge/main-lacks-segments.wast.combined.finalized.stdout3
-rw-r--r--test/merge/main-lacks-segments.wast.combined.opt19
-rw-r--r--test/merge/main-lacks-segments.wast.combined.opt.stdout3
-rw-r--r--test/merge/main-lacks-segments.wast.combined.stdout3
-rw-r--r--test/merge/main-lacks-segments.wast.toMerge13
-rw-r--r--test/merge/post-instantiate-a.wast9
-rw-r--r--test/merge/post-instantiate-a.wast.combined19
-rw-r--r--test/merge/post-instantiate-a.wast.combined.finalized19
-rw-r--r--test/merge/post-instantiate-a.wast.combined.finalized.opt10
-rw-r--r--test/merge/post-instantiate-a.wast.combined.finalized.opt.stdout3
-rw-r--r--test/merge/post-instantiate-a.wast.combined.finalized.stdout3
-rw-r--r--test/merge/post-instantiate-a.wast.combined.opt12
-rw-r--r--test/merge/post-instantiate-a.wast.combined.opt.stdout3
-rw-r--r--test/merge/post-instantiate-a.wast.combined.stdout3
-rw-r--r--test/merge/post-instantiate-a.wast.toMerge6
-rw-r--r--test/merge/post-instantiate-b.wast6
-rw-r--r--test/merge/post-instantiate-b.wast.combined19
-rw-r--r--test/merge/post-instantiate-b.wast.combined.finalized19
-rw-r--r--test/merge/post-instantiate-b.wast.combined.finalized.opt10
-rw-r--r--test/merge/post-instantiate-b.wast.combined.finalized.opt.stdout3
-rw-r--r--test/merge/post-instantiate-b.wast.combined.finalized.stdout3
-rw-r--r--test/merge/post-instantiate-b.wast.combined.opt12
-rw-r--r--test/merge/post-instantiate-b.wast.combined.opt.stdout3
-rw-r--r--test/merge/post-instantiate-b.wast.combined.stdout3
-rw-r--r--test/merge/post-instantiate-b.wast.toMerge9
-rw-r--r--test/merge/printf.wast13
-rw-r--r--test/merge/printf.wast.combined28
-rw-r--r--test/merge/printf.wast.combined.finalized28
-rw-r--r--test/merge/printf.wast.combined.finalized.opt12
-rw-r--r--test/merge/printf.wast.combined.finalized.opt.stdout3
-rw-r--r--test/merge/printf.wast.combined.finalized.stdout3
-rw-r--r--test/merge/printf.wast.combined.opt15
-rw-r--r--test/merge/printf.wast.combined.opt.stdout3
-rw-r--r--test/merge/printf.wast.combined.stdout3
-rw-r--r--test/merge/printf.wast.toMerge14
80 files changed, 1641 insertions, 0 deletions
diff --git a/test/merge/basics.wast b/test/merge/basics.wast
new file mode 100644
index 000000000..7a234584b
--- /dev/null
+++ b/test/merge/basics.wast
@@ -0,0 +1,38 @@
+(module
+ (type $ii (func (param i32 i32)))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "some-func" (func $some-func))
+ (import "env" "some-collide" (func $some-collide))
+ (data (get_global $memoryBase) "hello, A!\n")
+ (global $global-collide i32 (i32.const 0))
+ (global $global-collide-mut (mut i32) (i32.const 0))
+ (global $global-a i32 (i32.const 1))
+ (elem (get_global $tableBase) $only-a $willCollide $some-func $some-collide $only-a)
+ (export "exp-a" (func $only-a))
+ (export "exp-collide" (func $only-a))
+ (export "exp-collide2" (func $willCollide))
+ (func $only-a
+ (drop (i32.const 100))
+ (call $only-a)
+ (call_import $some-func)
+ (call_import $some-collide)
+ (call_indirect $ii
+ (i32.const 123)
+ (i32.const 456)
+ (i32.const 789)
+ )
+ (drop (get_global $global-collide))
+ (drop (get_global $global-a))
+ (drop (get_global $memoryBase))
+ (drop (get_global $tableBase))
+ (set_global $global-collide-mut (i32.const 1234))
+ )
+ (func $willCollide
+ (drop (i32.const 200))
+ (call $willCollide)
+ )
+)
+
diff --git a/test/merge/basics.wast.combined b/test/merge/basics.wast.combined
new file mode 100644
index 000000000..f0654ec7a
--- /dev/null
+++ b/test/merge/basics.wast.combined
@@ -0,0 +1,133 @@
+(module
+ (type $ii (func (param i32 i32)))
+ (type $FUNCSIG$v (func))
+ (type $ii$0 (func (param i32 i32)))
+ (type $FUNCSIG$v$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 10 anyfunc))
+ (import "env" "some-func" (func $some-func))
+ (import "env" "some-collide" (func $some-collide))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (import "env" "some-func-b" (func $some-func-b))
+ (import "env" "some-collide" (func $some-collide$0))
+ (global $global-collide i32 (i32.const 0))
+ (global $global-collide-mut (mut i32) (i32.const 0))
+ (global $global-a i32 (i32.const 1))
+ (global $global-collide$0 i32 (i32.const 0))
+ (global $global-collide-mut$0 (mut i32) (i32.const 0))
+ (global $global-b i32 (i32.const 1))
+ (elem (get_global $tableBase) $only-a $willCollide $some-func $some-collide $only-a $only-a $only-b $willCollide$0 $some-func-b $some-collide$0)
+ (data (get_global $memoryBase) "hello, A!\n\00\00\00\00\00\00hello, B!\n\00\00\00\00\00\00")
+ (export "exp-a" (func $only-a))
+ (export "exp-collide" (func $only-a))
+ (export "exp-collide2" (func $willCollide))
+ (export "exp-b" (func $only-b))
+ (export "exp-b-nameCollided" (func $willCollide$0))
+ (func $only-a (type $FUNCSIG$v)
+ (drop
+ (i32.const 100)
+ )
+ (call $only-a)
+ (call $some-func)
+ (call $some-collide)
+ (call_indirect $ii
+ (i32.const 123)
+ (i32.const 456)
+ (i32.const 789)
+ )
+ (drop
+ (get_global $global-collide)
+ )
+ (drop
+ (get_global $global-a)
+ )
+ (drop
+ (get_global $memoryBase)
+ )
+ (drop
+ (get_global $tableBase)
+ )
+ (set_global $global-collide-mut
+ (i32.const 1234)
+ )
+ )
+ (func $willCollide (type $FUNCSIG$v)
+ (drop
+ (i32.const 200)
+ )
+ (call $willCollide)
+ )
+ (func $only-b (type $FUNCSIG$v$0)
+ (drop
+ (i32.const 111)
+ )
+ (call $only-b)
+ (call $some-func-b)
+ (call $some-collide$0)
+ (call_indirect $ii$0
+ (i32.const 12)
+ (i32.const 34)
+ (i32.const 56)
+ )
+ (drop
+ (get_global $global-collide$0)
+ )
+ (drop
+ (get_global $global-b)
+ )
+ (drop
+ (i32.add
+ (get_global $memoryBase$0)
+ (i32.const 16)
+ )
+ )
+ (drop
+ (i32.add
+ (get_global $tableBase$0)
+ (i32.const 6)
+ )
+ )
+ (drop
+ (i32.add
+ (get_global $memoryBase$0)
+ (i32.const 1016)
+ )
+ )
+ (drop
+ (i32.add
+ (get_global $tableBase$0)
+ (i32.const 1006)
+ )
+ )
+ (drop
+ (i32.add
+ (i32.add
+ (get_global $tableBase$0)
+ (i32.const 6)
+ )
+ (unreachable)
+ )
+ )
+ (drop
+ (i32.sub
+ (i32.add
+ (get_global $tableBase$0)
+ (i32.const 6)
+ )
+ (i32.const 1000)
+ )
+ )
+ (set_global $global-collide-mut$0
+ (i32.const 5678)
+ )
+ )
+ (func $willCollide$0 (type $FUNCSIG$v$0)
+ (drop
+ (i32.const 222)
+ )
+ (call $willCollide$0)
+ )
+)
diff --git a/test/merge/basics.wast.combined.finalized b/test/merge/basics.wast.combined.finalized
new file mode 100644
index 000000000..7637b787b
--- /dev/null
+++ b/test/merge/basics.wast.combined.finalized
@@ -0,0 +1,133 @@
+(module
+ (type $ii (func (param i32 i32)))
+ (type $FUNCSIG$v (func))
+ (type $ii$0 (func (param i32 i32)))
+ (type $FUNCSIG$v$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 18 anyfunc))
+ (import "env" "some-func" (func $some-func))
+ (import "env" "some-collide" (func $some-collide))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (import "env" "some-func-b" (func $some-func-b))
+ (import "env" "some-collide" (func $some-collide$0))
+ (global $global-collide i32 (i32.const 0))
+ (global $global-collide-mut (mut i32) (i32.const 0))
+ (global $global-a i32 (i32.const 1))
+ (global $global-collide$0 i32 (i32.const 0))
+ (global $global-collide-mut$0 (mut i32) (i32.const 0))
+ (global $global-b i32 (i32.const 1))
+ (elem (i32.const 8) $only-a $willCollide $some-func $some-collide $only-a $only-a $only-b $willCollide$0 $some-func-b $some-collide$0)
+ (data (i32.const 1024) "hello, A!\n\00\00\00\00\00\00hello, B!\n\00\00\00\00\00\00")
+ (export "exp-a" (func $only-a))
+ (export "exp-collide" (func $only-a))
+ (export "exp-collide2" (func $willCollide))
+ (export "exp-b" (func $only-b))
+ (export "exp-b-nameCollided" (func $willCollide$0))
+ (func $only-a (type $FUNCSIG$v)
+ (drop
+ (i32.const 100)
+ )
+ (call $only-a)
+ (call $some-func)
+ (call $some-collide)
+ (call_indirect $ii
+ (i32.const 123)
+ (i32.const 456)
+ (i32.const 789)
+ )
+ (drop
+ (get_global $global-collide)
+ )
+ (drop
+ (get_global $global-a)
+ )
+ (drop
+ (i32.const 1024)
+ )
+ (drop
+ (i32.const 8)
+ )
+ (set_global $global-collide-mut
+ (i32.const 1234)
+ )
+ )
+ (func $willCollide (type $FUNCSIG$v)
+ (drop
+ (i32.const 200)
+ )
+ (call $willCollide)
+ )
+ (func $only-b (type $FUNCSIG$v$0)
+ (drop
+ (i32.const 111)
+ )
+ (call $only-b)
+ (call $some-func-b)
+ (call $some-collide$0)
+ (call_indirect $ii$0
+ (i32.const 12)
+ (i32.const 34)
+ (i32.const 56)
+ )
+ (drop
+ (get_global $global-collide$0)
+ )
+ (drop
+ (get_global $global-b)
+ )
+ (drop
+ (i32.add
+ (i32.const 1024)
+ (i32.const 16)
+ )
+ )
+ (drop
+ (i32.add
+ (i32.const 8)
+ (i32.const 6)
+ )
+ )
+ (drop
+ (i32.add
+ (i32.const 1024)
+ (i32.const 1016)
+ )
+ )
+ (drop
+ (i32.add
+ (i32.const 8)
+ (i32.const 1006)
+ )
+ )
+ (drop
+ (i32.add
+ (i32.add
+ (i32.const 8)
+ (i32.const 6)
+ )
+ (unreachable)
+ )
+ )
+ (drop
+ (i32.sub
+ (i32.add
+ (i32.const 8)
+ (i32.const 6)
+ )
+ (i32.const 1000)
+ )
+ )
+ (set_global $global-collide-mut$0
+ (i32.const 5678)
+ )
+ )
+ (func $willCollide$0 (type $FUNCSIG$v$0)
+ (drop
+ (i32.const 222)
+ )
+ (call $willCollide$0)
+ )
+)
diff --git a/test/merge/basics.wast.combined.finalized.opt b/test/merge/basics.wast.combined.finalized.opt
new file mode 100644
index 000000000..320ba8fa7
--- /dev/null
+++ b/test/merge/basics.wast.combined.finalized.opt
@@ -0,0 +1,86 @@
+(module
+ (type $ii (func (param i32 i32)))
+ (type $FUNCSIG$v (func))
+ (type $ii$0 (func (param i32 i32)))
+ (type $FUNCSIG$v$0 (func))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 18 anyfunc))
+ (import "env" "some-func" (func $some-func))
+ (import "env" "some-collide" (func $some-collide))
+ (import "env" "some-func-b" (func $some-func-b))
+ (import "env" "some-collide" (func $some-collide$0))
+ (global $global-collide i32 (i32.const 0))
+ (global $global-collide-mut (mut i32) (i32.const 0))
+ (global $global-a i32 (i32.const 1))
+ (global $global-collide$0 i32 (i32.const 0))
+ (global $global-collide-mut$0 (mut i32) (i32.const 0))
+ (global $global-b i32 (i32.const 1))
+ (elem (i32.const 8) $only-a $willCollide $some-func $some-collide $only-a $only-a $only-b $willCollide$0 $some-func-b $some-collide$0)
+ (data (i32.const 1024) "hello, A!\n\00\00\00\00\00\00hello, B!\n")
+ (export "exp-a" (func $only-a))
+ (export "exp-collide" (func $only-a))
+ (export "exp-collide2" (func $willCollide))
+ (export "exp-b" (func $only-b))
+ (export "exp-b-nameCollided" (func $willCollide$0))
+ (func $only-a (type $FUNCSIG$v)
+ (nop)
+ (call $only-a)
+ (call $some-func)
+ (call $some-collide)
+ (call_indirect $ii
+ (i32.const 123)
+ (i32.const 456)
+ (i32.const 789)
+ )
+ (drop
+ (get_global $global-collide)
+ )
+ (drop
+ (get_global $global-a)
+ )
+ (nop)
+ (nop)
+ (set_global $global-collide-mut
+ (i32.const 1234)
+ )
+ )
+ (func $willCollide (type $FUNCSIG$v)
+ (nop)
+ (call $willCollide)
+ )
+ (func $only-b (type $FUNCSIG$v$0)
+ (nop)
+ (call $only-b)
+ (call $some-func-b)
+ (call $some-collide$0)
+ (call_indirect $ii$0
+ (i32.const 12)
+ (i32.const 34)
+ (i32.const 56)
+ )
+ (drop
+ (get_global $global-collide$0)
+ )
+ (drop
+ (get_global $global-b)
+ )
+ (nop)
+ (nop)
+ (nop)
+ (nop)
+ (drop
+ (i32.add
+ (unreachable)
+ (i32.const 14)
+ )
+ )
+ (nop)
+ (set_global $global-collide-mut$0
+ (i32.const 5678)
+ )
+ )
+ (func $willCollide$0 (type $FUNCSIG$v$0)
+ (nop)
+ (call $willCollide$0)
+ )
+)
diff --git a/test/merge/basics.wast.combined.finalized.opt.stdout b/test/merge/basics.wast.combined.finalized.opt.stdout
new file mode 100644
index 000000000..18fbdb05e
--- /dev/null
+++ b/test/merge/basics.wast.combined.finalized.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 32
+merged total table size: 10
+merged functions: 4
diff --git a/test/merge/basics.wast.combined.finalized.stdout b/test/merge/basics.wast.combined.finalized.stdout
new file mode 100644
index 000000000..18fbdb05e
--- /dev/null
+++ b/test/merge/basics.wast.combined.finalized.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 32
+merged total table size: 10
+merged functions: 4
diff --git a/test/merge/basics.wast.combined.opt b/test/merge/basics.wast.combined.opt
new file mode 100644
index 000000000..ba8ab6220
--- /dev/null
+++ b/test/merge/basics.wast.combined.opt
@@ -0,0 +1,122 @@
+(module
+ (type $ii (func (param i32 i32)))
+ (type $FUNCSIG$v (func))
+ (type $ii$0 (func (param i32 i32)))
+ (type $FUNCSIG$v$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 10 anyfunc))
+ (import "env" "some-func" (func $some-func))
+ (import "env" "some-collide" (func $some-collide))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (import "env" "some-func-b" (func $some-func-b))
+ (import "env" "some-collide" (func $some-collide$0))
+ (global $global-collide i32 (i32.const 0))
+ (global $global-collide-mut (mut i32) (i32.const 0))
+ (global $global-a i32 (i32.const 1))
+ (global $global-collide$0 i32 (i32.const 0))
+ (global $global-collide-mut$0 (mut i32) (i32.const 0))
+ (global $global-b i32 (i32.const 1))
+ (elem (get_global $tableBase) $only-a $willCollide $some-func $some-collide $only-a $only-a $only-b $willCollide$0 $some-func-b $some-collide$0)
+ (data (get_global $memoryBase) "hello, A!\n\00\00\00\00\00\00hello, B!\n")
+ (export "exp-a" (func $only-a))
+ (export "exp-collide" (func $only-a))
+ (export "exp-collide2" (func $willCollide))
+ (export "exp-b" (func $only-b))
+ (export "exp-b-nameCollided" (func $willCollide$0))
+ (func $only-a (type $FUNCSIG$v)
+ (nop)
+ (call $only-a)
+ (call $some-func)
+ (call $some-collide)
+ (call_indirect $ii
+ (i32.const 123)
+ (i32.const 456)
+ (i32.const 789)
+ )
+ (drop
+ (get_global $global-collide)
+ )
+ (drop
+ (get_global $global-a)
+ )
+ (drop
+ (get_global $memoryBase)
+ )
+ (drop
+ (get_global $tableBase)
+ )
+ (set_global $global-collide-mut
+ (i32.const 1234)
+ )
+ )
+ (func $willCollide (type $FUNCSIG$v)
+ (nop)
+ (call $willCollide)
+ )
+ (func $only-b (type $FUNCSIG$v$0)
+ (nop)
+ (call $only-b)
+ (call $some-func-b)
+ (call $some-collide$0)
+ (call_indirect $ii$0
+ (i32.const 12)
+ (i32.const 34)
+ (i32.const 56)
+ )
+ (drop
+ (get_global $global-collide$0)
+ )
+ (drop
+ (get_global $global-b)
+ )
+ (drop
+ (i32.add
+ (get_global $memoryBase$0)
+ (i32.const 16)
+ )
+ )
+ (drop
+ (i32.add
+ (get_global $tableBase$0)
+ (i32.const 6)
+ )
+ )
+ (drop
+ (i32.add
+ (get_global $memoryBase$0)
+ (i32.const 1016)
+ )
+ )
+ (drop
+ (i32.add
+ (get_global $tableBase$0)
+ (i32.const 1006)
+ )
+ )
+ (drop
+ (i32.add
+ (i32.add
+ (get_global $tableBase$0)
+ (i32.const 6)
+ )
+ (unreachable)
+ )
+ )
+ (drop
+ (i32.add
+ (get_global $tableBase$0)
+ (i32.const -994)
+ )
+ )
+ (set_global $global-collide-mut$0
+ (i32.const 5678)
+ )
+ )
+ (func $willCollide$0 (type $FUNCSIG$v$0)
+ (nop)
+ (call $willCollide$0)
+ )
+)
diff --git a/test/merge/basics.wast.combined.opt.stdout b/test/merge/basics.wast.combined.opt.stdout
new file mode 100644
index 000000000..18fbdb05e
--- /dev/null
+++ b/test/merge/basics.wast.combined.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 32
+merged total table size: 10
+merged functions: 4
diff --git a/test/merge/basics.wast.combined.stdout b/test/merge/basics.wast.combined.stdout
new file mode 100644
index 000000000..18fbdb05e
--- /dev/null
+++ b/test/merge/basics.wast.combined.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 32
+merged total table size: 10
+merged functions: 4
diff --git a/test/merge/basics.wast.toMerge b/test/merge/basics.wast.toMerge
new file mode 100644
index 000000000..5122afe31
--- /dev/null
+++ b/test/merge/basics.wast.toMerge
@@ -0,0 +1,63 @@
+(module
+ (type $ii (func (param i32 i32)))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "some-func-b" (func $some-func-b))
+ (import "env" "some-collide" (func $some-collide))
+ (data (get_global $memoryBase) "hello, B!\n")
+ (global $global-collide i32 (i32.const 0))
+ (global $global-collide-mut (mut i32) (i32.const 0))
+ (global $global-b i32 (i32.const 1))
+ (elem (get_global $tableBase) $only-b $willCollide $some-func-b $some-collide)
+ (export "exp-b" (func $only-b))
+ (export "exp-collide" (func $only-b))
+ (export "exp-collide2" (func $willCollide))
+ (export "exp-b-nameCollided" (func $willCollide))
+ (func $only-b
+ (drop (i32.const 111))
+ (call $only-b)
+ (call $some-func-b)
+ (call_import $some-collide)
+ (call_indirect $ii
+ (i32.const 12)
+ (i32.const 34)
+ (i32.const 56)
+ )
+ (drop (get_global $global-collide))
+ (drop (get_global $global-b))
+ (drop (get_global $memoryBase))
+ (drop (get_global $tableBase))
+ (drop
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 1000)
+ )
+ )
+ (drop
+ (i32.add
+ (get_global $tableBase)
+ (i32.const 1000)
+ )
+ )
+ (drop
+ (i32.add
+ (get_global $tableBase)
+ (unreachable) ;; bad!
+ )
+ )
+ (drop
+ (i32.sub ;; bad!
+ (get_global $tableBase)
+ (i32.const 1000)
+ )
+ )
+ (set_global $global-collide-mut (i32.const 5678))
+ )
+ (func $willCollide
+ (drop (i32.const 222))
+ (call $willCollide)
+ )
+)
+
diff --git a/test/merge/dylib.wasm b/test/merge/dylib.wasm
new file mode 100644
index 000000000..4d86a9483
--- /dev/null
+++ b/test/merge/dylib.wasm
Binary files differ
diff --git a/test/merge/dylib.wasm.combined b/test/merge/dylib.wasm.combined
new file mode 100644
index 000000000..0133476a9
--- /dev/null
+++ b/test/merge/dylib.wasm.combined
@@ -0,0 +1,91 @@
+(module
+ (type $0 (func (param i32 i32)))
+ (type $1 (func (param i32) (result i32)))
+ (type $2 (func (result i32)))
+ (type $3 (func))
+ (type $0$0 (func (param i32 i32)))
+ (type $1$0 (func (result i32)))
+ (type $2$0 (func))
+ (import "env" "memoryBase" (global $import$0 i32))
+ (import "env" "_puts" (func $import$1 (param i32) (result i32)))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "tableBase" (global $import$4 i32))
+ (import "env" "memoryBase" (global $import$0$0 i32))
+ (import "env" "tableBase" (global $import$4$0 i32))
+ (global $global$0 (mut i32) (i32.const 0))
+ (global $global$1 (mut i32) (i32.const 0))
+ (global $global$2 i32 (i32.const 0))
+ (global $global$0$0 (mut i32) (i32.const 0))
+ (global $global$1$0 (mut i32) (i32.const 0))
+
+ (data (get_global $import$0) "hello, world!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
+ (export "__post_instantiate" (func $__post_instantiate))
+ (export "_main" (func $_main))
+ (export "runPostSets" (func $runPostSets))
+ (export "_str" (global $global$2))
+ (export "_foo" (func $_foo))
+ (func $_main (type $2) (result i32)
+ (block $label$0 i32
+ (drop
+ (call $import$1
+ (get_global $import$0)
+ )
+ )
+ (i32.const 0)
+ )
+ )
+ (func $runPostSets (type $3)
+ (nop)
+ )
+ (func $__post_instantiate (type $3)
+ (call $__post_instantiate$0)
+ (block
+ (block $label$0
+ (set_global $global$0
+ (i32.add
+ (get_global $import$0)
+ (i32.const 16)
+ )
+ )
+ (set_global $global$1
+ (i32.add
+ (get_global $global$0)
+ (i32.const 32)
+ )
+ )
+ (call $runPostSets)
+ )
+ )
+ )
+ (func $_foo (type $1$0) (result i32)
+ (local $var$0 i32)
+ (block $label$0 i32
+ (set_local $var$0
+ (call $_main)
+ )
+ (get_local $var$0)
+ )
+ )
+ (func $runPostSets$0 (type $2$0)
+ (nop)
+ )
+ (func $__post_instantiate$0 (type $2$0)
+ (block $label$0
+ (set_global $global$0$0
+ (i32.add
+ (get_global $import$0$0)
+ (i32.const 48)
+ )
+ )
+ (set_global $global$1$0
+ (i32.add
+ (get_global $global$0$0)
+ (i32.const 10)
+ )
+ )
+ (call $runPostSets$0)
+ )
+ )
+ ;; custom section "dylink", size 2
+)
diff --git a/test/merge/dylib.wasm.combined.finalized b/test/merge/dylib.wasm.combined.finalized
new file mode 100644
index 000000000..c3f64a0b5
--- /dev/null
+++ b/test/merge/dylib.wasm.combined.finalized
@@ -0,0 +1,91 @@
+(module
+ (type $0 (func (param i32 i32)))
+ (type $1 (func (param i32) (result i32)))
+ (type $2 (func (result i32)))
+ (type $3 (func))
+ (type $0$0 (func (param i32 i32)))
+ (type $1$0 (func (result i32)))
+ (type $2$0 (func))
+ (import "env" "memoryBase" (global $import$0 i32))
+ (import "env" "_puts" (func $import$1 (param i32) (result i32)))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 8 anyfunc))
+ (import "env" "tableBase" (global $import$4 i32))
+ (import "env" "memoryBase" (global $import$0$0 i32))
+ (import "env" "tableBase" (global $import$4$0 i32))
+ (global $global$0 (mut i32) (i32.const 0))
+ (global $global$1 (mut i32) (i32.const 0))
+ (global $global$2 i32 (i32.const 0))
+ (global $global$0$0 (mut i32) (i32.const 0))
+ (global $global$1$0 (mut i32) (i32.const 0))
+
+ (data (i32.const 1024) "hello, world!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
+ (export "__post_instantiate" (func $__post_instantiate))
+ (export "_main" (func $_main))
+ (export "runPostSets" (func $runPostSets))
+ (export "_str" (global $global$2))
+ (export "_foo" (func $_foo))
+ (func $_main (type $2) (result i32)
+ (block $label$0 i32
+ (drop
+ (call $import$1
+ (i32.const 1024)
+ )
+ )
+ (i32.const 0)
+ )
+ )
+ (func $runPostSets (type $3)
+ (nop)
+ )
+ (func $__post_instantiate (type $3)
+ (call $__post_instantiate$0)
+ (block
+ (block $label$0
+ (set_global $global$0
+ (i32.add
+ (i32.const 1024)
+ (i32.const 16)
+ )
+ )
+ (set_global $global$1
+ (i32.add
+ (get_global $global$0)
+ (i32.const 32)
+ )
+ )
+ (call $runPostSets)
+ )
+ )
+ )
+ (func $_foo (type $1$0) (result i32)
+ (local $var$0 i32)
+ (block $label$0 i32
+ (set_local $var$0
+ (call $_main)
+ )
+ (get_local $var$0)
+ )
+ )
+ (func $runPostSets$0 (type $2$0)
+ (nop)
+ )
+ (func $__post_instantiate$0 (type $2$0)
+ (block $label$0
+ (set_global $global$0$0
+ (i32.add
+ (i32.const 1024)
+ (i32.const 48)
+ )
+ )
+ (set_global $global$1$0
+ (i32.add
+ (get_global $global$0$0)
+ (i32.const 10)
+ )
+ )
+ (call $runPostSets$0)
+ )
+ )
+ ;; custom section "dylink", size 2
+)
diff --git a/test/merge/dylib.wasm.combined.finalized.opt b/test/merge/dylib.wasm.combined.finalized.opt
new file mode 100644
index 000000000..2d40fb83c
--- /dev/null
+++ b/test/merge/dylib.wasm.combined.finalized.opt
@@ -0,0 +1,81 @@
+(module
+ (type $0 (func (param i32 i32)))
+ (type $1 (func (param i32) (result i32)))
+ (type $2 (func (result i32)))
+ (type $3 (func))
+ (type $0$0 (func (param i32 i32)))
+ (type $1$0 (func (result i32)))
+ (type $2$0 (func))
+ (import "env" "_puts" (func $import$1 (param i32) (result i32)))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 8 anyfunc))
+ (global $global$0 (mut i32) (i32.const 0))
+ (global $global$1 (mut i32) (i32.const 0))
+ (global $global$2 i32 (i32.const 0))
+ (global $global$0$0 (mut i32) (i32.const 0))
+ (global $global$1$0 (mut i32) (i32.const 0))
+
+ (data (i32.const 1024) "hello, world!")
+ (export "__post_instantiate" (func $__post_instantiate))
+ (export "_main" (func $_main))
+ (export "runPostSets" (func $runPostSets))
+ (export "_str" (global $global$2))
+ (export "_foo" (func $_foo))
+ (func $_main (type $2) (result i32)
+ (block $label$0 i32
+ (drop
+ (call $import$1
+ (i32.const 1024)
+ )
+ )
+ (i32.const 0)
+ )
+ )
+ (func $runPostSets (type $3)
+ (nop)
+ )
+ (func $__post_instantiate (type $3)
+ (call $__post_instantiate$0)
+ (block
+ (block $label$0
+ (set_global $global$0
+ (i32.const 1040)
+ )
+ (set_global $global$1
+ (i32.add
+ (get_global $global$0)
+ (i32.const 32)
+ )
+ )
+ (call $runPostSets)
+ )
+ )
+ )
+ (func $_foo (type $1$0) (result i32)
+ (local $var$0 i32)
+ (block $label$0 i32
+ (set_local $var$0
+ (call $_main)
+ )
+ (get_local $var$0)
+ )
+ )
+ (func $runPostSets$0 (type $2$0)
+ (nop)
+ )
+ (func $__post_instantiate$0 (type $2$0)
+ (block $label$0
+ (set_global $global$0$0
+ (i32.const 1072)
+ )
+ (set_global $global$1$0
+ (i32.add
+ (get_global $global$0$0)
+ (i32.const 10)
+ )
+ )
+ (call $runPostSets$0)
+ )
+ )
+ ;; custom section "dylink", size 2
+)
diff --git a/test/merge/dylib.wasm.combined.finalized.opt.stdout b/test/merge/dylib.wasm.combined.finalized.opt.stdout
new file mode 100644
index 000000000..fb480861a
--- /dev/null
+++ b/test/merge/dylib.wasm.combined.finalized.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 64
+merged total table size: 0
+merged functions: 6
diff --git a/test/merge/dylib.wasm.combined.finalized.stdout b/test/merge/dylib.wasm.combined.finalized.stdout
new file mode 100644
index 000000000..fb480861a
--- /dev/null
+++ b/test/merge/dylib.wasm.combined.finalized.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 64
+merged total table size: 0
+merged functions: 6
diff --git a/test/merge/dylib.wasm.combined.opt b/test/merge/dylib.wasm.combined.opt
new file mode 100644
index 000000000..8c354e34d
--- /dev/null
+++ b/test/merge/dylib.wasm.combined.opt
@@ -0,0 +1,90 @@
+(module
+ (type $0 (func (param i32 i32)))
+ (type $1 (func (param i32) (result i32)))
+ (type $2 (func (result i32)))
+ (type $3 (func))
+ (type $0$0 (func (param i32 i32)))
+ (type $1$0 (func (result i32)))
+ (type $2$0 (func))
+ (import "env" "memoryBase" (global $import$0 i32))
+ (import "env" "_puts" (func $import$1 (param i32) (result i32)))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "tableBase" (global $import$4 i32))
+ (import "env" "memoryBase" (global $import$0$0 i32))
+ (global $global$0 (mut i32) (i32.const 0))
+ (global $global$1 (mut i32) (i32.const 0))
+ (global $global$2 i32 (i32.const 0))
+ (global $global$0$0 (mut i32) (i32.const 0))
+ (global $global$1$0 (mut i32) (i32.const 0))
+
+ (data (get_global $import$0) "hello, world!")
+ (export "__post_instantiate" (func $__post_instantiate))
+ (export "_main" (func $_main))
+ (export "runPostSets" (func $runPostSets))
+ (export "_str" (global $global$2))
+ (export "_foo" (func $_foo))
+ (func $_main (type $2) (result i32)
+ (block $label$0 i32
+ (drop
+ (call $import$1
+ (get_global $import$0)
+ )
+ )
+ (i32.const 0)
+ )
+ )
+ (func $runPostSets (type $3)
+ (nop)
+ )
+ (func $__post_instantiate (type $3)
+ (call $__post_instantiate$0)
+ (block
+ (block $label$0
+ (set_global $global$0
+ (i32.add
+ (get_global $import$0)
+ (i32.const 16)
+ )
+ )
+ (set_global $global$1
+ (i32.add
+ (get_global $global$0)
+ (i32.const 32)
+ )
+ )
+ (call $runPostSets)
+ )
+ )
+ )
+ (func $_foo (type $1$0) (result i32)
+ (local $var$0 i32)
+ (block $label$0 i32
+ (set_local $var$0
+ (call $_main)
+ )
+ (get_local $var$0)
+ )
+ )
+ (func $runPostSets$0 (type $2$0)
+ (nop)
+ )
+ (func $__post_instantiate$0 (type $2$0)
+ (block $label$0
+ (set_global $global$0$0
+ (i32.add
+ (get_global $import$0$0)
+ (i32.const 48)
+ )
+ )
+ (set_global $global$1$0
+ (i32.add
+ (get_global $global$0$0)
+ (i32.const 10)
+ )
+ )
+ (call $runPostSets$0)
+ )
+ )
+ ;; custom section "dylink", size 2
+)
diff --git a/test/merge/dylib.wasm.combined.opt.stdout b/test/merge/dylib.wasm.combined.opt.stdout
new file mode 100644
index 000000000..fb480861a
--- /dev/null
+++ b/test/merge/dylib.wasm.combined.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 64
+merged total table size: 0
+merged functions: 6
diff --git a/test/merge/dylib.wasm.combined.stdout b/test/merge/dylib.wasm.combined.stdout
new file mode 100644
index 000000000..fb480861a
--- /dev/null
+++ b/test/merge/dylib.wasm.combined.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 64
+merged total table size: 0
+merged functions: 6
diff --git a/test/merge/dylib.wasm.toMerge b/test/merge/dylib.wasm.toMerge
new file mode 100644
index 000000000..c9953956b
--- /dev/null
+++ b/test/merge/dylib.wasm.toMerge
Binary files differ
diff --git a/test/merge/fusing.wast b/test/merge/fusing.wast
new file mode 100644
index 000000000..588647e35
--- /dev/null
+++ b/test/merge/fusing.wast
@@ -0,0 +1,18 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (export "foo" (func $foo-func))
+ (import "env" "bar" (func $bar-func))
+ (global $a-global i32 (i32.const 0))
+ (export "aglobal" (global $a-global))
+ (import "env" "bglobal" (global $b-global f64))
+ (func $foo-func
+ (drop (i32.const 1337))
+ (call_import $bar-func)
+ (drop (get_global $a-global))
+ (drop (get_global $b-global))
+ )
+)
+
diff --git a/test/merge/fusing.wast.combined b/test/merge/fusing.wast.combined
new file mode 100644
index 000000000..2a7adf6e2
--- /dev/null
+++ b/test/merge/fusing.wast.combined
@@ -0,0 +1,44 @@
+(module
+ (type $FUNCSIG$v (func))
+ (type $FUNCSIG$v$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (global $a-global i32 (i32.const 0))
+ (global $b-global f64 (f64.const 2.14281428))
+
+ (data (get_global $memoryBase) "")
+ (export "foo" (func $foo-func))
+ (export "aglobal" (global $a-global))
+ (export "bar" (func $bar-func))
+ (export "bglobal" (global $b-global))
+ (func $foo-func (type $FUNCSIG$v)
+ (drop
+ (i32.const 1337)
+ )
+ (call $bar-func)
+ (drop
+ (get_global $a-global)
+ )
+ (drop
+ (get_global $b-global)
+ )
+ )
+ (func $b (type $FUNCSIG$v$0)
+ (call $foo-func)
+ )
+ (func $bar-func (type $FUNCSIG$v$0)
+ (drop
+ (f64.const 3.14159)
+ )
+ (drop
+ (get_global $a-global)
+ )
+ (drop
+ (get_global $b-global)
+ )
+ )
+)
diff --git a/test/merge/fusing.wast.combined.finalized b/test/merge/fusing.wast.combined.finalized
new file mode 100644
index 000000000..7896e448d
--- /dev/null
+++ b/test/merge/fusing.wast.combined.finalized
@@ -0,0 +1,44 @@
+(module
+ (type $FUNCSIG$v (func))
+ (type $FUNCSIG$v$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 8 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (global $a-global i32 (i32.const 0))
+ (global $b-global f64 (f64.const 2.14281428))
+
+ (data (i32.const 1024) "")
+ (export "foo" (func $foo-func))
+ (export "aglobal" (global $a-global))
+ (export "bar" (func $bar-func))
+ (export "bglobal" (global $b-global))
+ (func $foo-func (type $FUNCSIG$v)
+ (drop
+ (i32.const 1337)
+ )
+ (call $bar-func)
+ (drop
+ (get_global $a-global)
+ )
+ (drop
+ (get_global $b-global)
+ )
+ )
+ (func $b (type $FUNCSIG$v$0)
+ (call $foo-func)
+ )
+ (func $bar-func (type $FUNCSIG$v$0)
+ (drop
+ (f64.const 3.14159)
+ )
+ (drop
+ (get_global $a-global)
+ )
+ (drop
+ (get_global $b-global)
+ )
+ )
+)
diff --git a/test/merge/fusing.wast.combined.finalized.opt b/test/merge/fusing.wast.combined.finalized.opt
new file mode 100644
index 000000000..202c566e1
--- /dev/null
+++ b/test/merge/fusing.wast.combined.finalized.opt
@@ -0,0 +1,32 @@
+(module
+ (type $FUNCSIG$v (func))
+ (type $FUNCSIG$v$0 (func))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 8 anyfunc))
+ (global $a-global i32 (i32.const 0))
+ (global $b-global f64 (f64.const 2.14281428))
+
+ (export "foo" (func $foo-func))
+ (export "aglobal" (global $a-global))
+ (export "bar" (func $bar-func))
+ (export "bglobal" (global $b-global))
+ (func $foo-func (type $FUNCSIG$v)
+ (nop)
+ (call $bar-func)
+ (drop
+ (get_global $a-global)
+ )
+ (drop
+ (get_global $b-global)
+ )
+ )
+ (func $bar-func (type $FUNCSIG$v$0)
+ (nop)
+ (drop
+ (get_global $a-global)
+ )
+ (drop
+ (get_global $b-global)
+ )
+ )
+)
diff --git a/test/merge/fusing.wast.combined.finalized.opt.stdout b/test/merge/fusing.wast.combined.finalized.opt.stdout
new file mode 100644
index 000000000..80b514d22
--- /dev/null
+++ b/test/merge/fusing.wast.combined.finalized.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 3
diff --git a/test/merge/fusing.wast.combined.finalized.stdout b/test/merge/fusing.wast.combined.finalized.stdout
new file mode 100644
index 000000000..80b514d22
--- /dev/null
+++ b/test/merge/fusing.wast.combined.finalized.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 3
diff --git a/test/merge/fusing.wast.combined.opt b/test/merge/fusing.wast.combined.opt
new file mode 100644
index 000000000..1a09fb784
--- /dev/null
+++ b/test/merge/fusing.wast.combined.opt
@@ -0,0 +1,35 @@
+(module
+ (type $FUNCSIG$v (func))
+ (type $FUNCSIG$v$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (global $a-global i32 (i32.const 0))
+ (global $b-global f64 (f64.const 2.14281428))
+
+ (data (get_global $memoryBase) "")
+ (export "foo" (func $foo-func))
+ (export "aglobal" (global $a-global))
+ (export "bar" (func $bar-func))
+ (export "bglobal" (global $b-global))
+ (func $foo-func (type $FUNCSIG$v)
+ (nop)
+ (call $bar-func)
+ (drop
+ (get_global $a-global)
+ )
+ (drop
+ (get_global $b-global)
+ )
+ )
+ (func $bar-func (type $FUNCSIG$v$0)
+ (nop)
+ (drop
+ (get_global $a-global)
+ )
+ (drop
+ (get_global $b-global)
+ )
+ )
+)
diff --git a/test/merge/fusing.wast.combined.opt.stdout b/test/merge/fusing.wast.combined.opt.stdout
new file mode 100644
index 000000000..80b514d22
--- /dev/null
+++ b/test/merge/fusing.wast.combined.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 3
diff --git a/test/merge/fusing.wast.combined.stdout b/test/merge/fusing.wast.combined.stdout
new file mode 100644
index 000000000..80b514d22
--- /dev/null
+++ b/test/merge/fusing.wast.combined.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 3
diff --git a/test/merge/fusing.wast.toMerge b/test/merge/fusing.wast.toMerge
new file mode 100644
index 000000000..4abd0a5e1
--- /dev/null
+++ b/test/merge/fusing.wast.toMerge
@@ -0,0 +1,20 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "foo" (func $b-foo))
+ (export "bar" (func $bar-func))
+ (global $b-global f64 (f64.const 2.14281428))
+ (export "bglobal" (global $b-global))
+ (import "env" "aglobal" (global $a-global i32))
+ (func $b
+ (call $b-foo)
+ )
+ (func $bar-func
+ (drop (f64.const 3.14159))
+ (drop (get_global $a-global))
+ (drop (get_global $b-global))
+ )
+)
+
diff --git a/test/merge/global-init.wast b/test/merge/global-init.wast
new file mode 100644
index 000000000..ddf1a868f
--- /dev/null
+++ b/test/merge/global-init.wast
@@ -0,0 +1,10 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "globally" (global $i-collide i32))
+ (global $a i32 (get_global $i-collide))
+ (global $g-collide i32 (get_global $i-collide))
+)
+
diff --git a/test/merge/global-init.wast.combined b/test/merge/global-init.wast.combined
new file mode 100644
index 000000000..95b339968
--- /dev/null
+++ b/test/merge/global-init.wast.combined
@@ -0,0 +1,16 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "globally" (global $i-collide i32))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (import "env" "globally" (global $i-collide$0 f64))
+ (global $a i32 (get_global $i-collide))
+ (global $g-collide i32 (get_global $i-collide))
+ (global $b f64 (get_global $i-collide$0))
+ (global $g-collide$0 f64 (get_global $i-collide$0))
+
+ (data (get_global $memoryBase) "")
+)
diff --git a/test/merge/global-init.wast.combined.finalized b/test/merge/global-init.wast.combined.finalized
new file mode 100644
index 000000000..40a5066fa
--- /dev/null
+++ b/test/merge/global-init.wast.combined.finalized
@@ -0,0 +1,16 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 8 anyfunc))
+ (import "env" "globally" (global $i-collide i32))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (import "env" "globally" (global $i-collide$0 f64))
+ (global $a i32 (get_global $i-collide))
+ (global $g-collide i32 (get_global $i-collide))
+ (global $b f64 (get_global $i-collide$0))
+ (global $g-collide$0 f64 (get_global $i-collide$0))
+
+ (data (i32.const 1024) "")
+)
diff --git a/test/merge/global-init.wast.combined.finalized.opt b/test/merge/global-init.wast.combined.finalized.opt
new file mode 100644
index 000000000..02a0900f5
--- /dev/null
+++ b/test/merge/global-init.wast.combined.finalized.opt
@@ -0,0 +1,5 @@
+(module
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 8 anyfunc))
+
+)
diff --git a/test/merge/global-init.wast.combined.finalized.opt.stdout b/test/merge/global-init.wast.combined.finalized.opt.stdout
new file mode 100644
index 000000000..361590ef0
--- /dev/null
+++ b/test/merge/global-init.wast.combined.finalized.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 0
diff --git a/test/merge/global-init.wast.combined.finalized.stdout b/test/merge/global-init.wast.combined.finalized.stdout
new file mode 100644
index 000000000..361590ef0
--- /dev/null
+++ b/test/merge/global-init.wast.combined.finalized.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 0
diff --git a/test/merge/global-init.wast.combined.opt b/test/merge/global-init.wast.combined.opt
new file mode 100644
index 000000000..44c047693
--- /dev/null
+++ b/test/merge/global-init.wast.combined.opt
@@ -0,0 +1,8 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+
+ (data (get_global $memoryBase) "")
+)
diff --git a/test/merge/global-init.wast.combined.opt.stdout b/test/merge/global-init.wast.combined.opt.stdout
new file mode 100644
index 000000000..361590ef0
--- /dev/null
+++ b/test/merge/global-init.wast.combined.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 0
diff --git a/test/merge/global-init.wast.combined.stdout b/test/merge/global-init.wast.combined.stdout
new file mode 100644
index 000000000..361590ef0
--- /dev/null
+++ b/test/merge/global-init.wast.combined.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 0
diff --git a/test/merge/global-init.wast.toMerge b/test/merge/global-init.wast.toMerge
new file mode 100644
index 000000000..6f5d5e6dd
--- /dev/null
+++ b/test/merge/global-init.wast.toMerge
@@ -0,0 +1,10 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "globally" (global $i-collide f64))
+ (global $b f64 (get_global $i-collide))
+ (global $g-collide f64 (get_global $i-collide))
+)
+
diff --git a/test/merge/main-lacks-segments.wast b/test/merge/main-lacks-segments.wast
new file mode 100644
index 000000000..c18db2470
--- /dev/null
+++ b/test/merge/main-lacks-segments.wast
@@ -0,0 +1,7 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+)
+
diff --git a/test/merge/main-lacks-segments.wast.combined b/test/merge/main-lacks-segments.wast.combined
new file mode 100644
index 000000000..33eb89435
--- /dev/null
+++ b/test/merge/main-lacks-segments.wast.combined
@@ -0,0 +1,25 @@
+(module
+ (type $0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 2 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (elem (get_global $tableBase) $foo $foo)
+ (data (get_global $memoryBase) "hello, this is some data!\00\00\00\00\00\00\00")
+ (func $foo (type $0)
+ (drop
+ (i32.add
+ (get_global $tableBase$0)
+ (i32.const 0)
+ )
+ )
+ (drop
+ (i32.add
+ (get_global $memoryBase$0)
+ (i32.const 0)
+ )
+ )
+ )
+)
diff --git a/test/merge/main-lacks-segments.wast.combined.finalized b/test/merge/main-lacks-segments.wast.combined.finalized
new file mode 100644
index 000000000..923ffd34d
--- /dev/null
+++ b/test/merge/main-lacks-segments.wast.combined.finalized
@@ -0,0 +1,25 @@
+(module
+ (type $0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 10 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (elem (i32.const 8) $foo $foo)
+ (data (i32.const 1024) "hello, this is some data!\00\00\00\00\00\00\00")
+ (func $foo (type $0)
+ (drop
+ (i32.add
+ (i32.const 8)
+ (i32.const 0)
+ )
+ )
+ (drop
+ (i32.add
+ (i32.const 1024)
+ (i32.const 0)
+ )
+ )
+ )
+)
diff --git a/test/merge/main-lacks-segments.wast.combined.finalized.opt b/test/merge/main-lacks-segments.wast.combined.finalized.opt
new file mode 100644
index 000000000..0aeb4c62d
--- /dev/null
+++ b/test/merge/main-lacks-segments.wast.combined.finalized.opt
@@ -0,0 +1,10 @@
+(module
+ (type $0 (func))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 10 anyfunc))
+ (elem (i32.const 8) $foo $foo)
+ (data (i32.const 1024) "hello, this is some data!")
+ (func $foo (type $0)
+ (nop)
+ )
+)
diff --git a/test/merge/main-lacks-segments.wast.combined.finalized.opt.stdout b/test/merge/main-lacks-segments.wast.combined.finalized.opt.stdout
new file mode 100644
index 000000000..5e72852f9
--- /dev/null
+++ b/test/merge/main-lacks-segments.wast.combined.finalized.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 32
+merged total table size: 2
+merged functions: 1
diff --git a/test/merge/main-lacks-segments.wast.combined.finalized.stdout b/test/merge/main-lacks-segments.wast.combined.finalized.stdout
new file mode 100644
index 000000000..5e72852f9
--- /dev/null
+++ b/test/merge/main-lacks-segments.wast.combined.finalized.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 32
+merged total table size: 2
+merged functions: 1
diff --git a/test/merge/main-lacks-segments.wast.combined.opt b/test/merge/main-lacks-segments.wast.combined.opt
new file mode 100644
index 000000000..4ea294a8e
--- /dev/null
+++ b/test/merge/main-lacks-segments.wast.combined.opt
@@ -0,0 +1,19 @@
+(module
+ (type $0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 2 anyfunc))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (elem (get_global $tableBase) $foo $foo)
+ (data (get_global $memoryBase) "hello, this is some data!")
+ (func $foo (type $0)
+ (drop
+ (get_global $tableBase$0)
+ )
+ (drop
+ (get_global $memoryBase$0)
+ )
+ )
+)
diff --git a/test/merge/main-lacks-segments.wast.combined.opt.stdout b/test/merge/main-lacks-segments.wast.combined.opt.stdout
new file mode 100644
index 000000000..5e72852f9
--- /dev/null
+++ b/test/merge/main-lacks-segments.wast.combined.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 32
+merged total table size: 2
+merged functions: 1
diff --git a/test/merge/main-lacks-segments.wast.combined.stdout b/test/merge/main-lacks-segments.wast.combined.stdout
new file mode 100644
index 000000000..5e72852f9
--- /dev/null
+++ b/test/merge/main-lacks-segments.wast.combined.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 32
+merged total table size: 2
+merged functions: 1
diff --git a/test/merge/main-lacks-segments.wast.toMerge b/test/merge/main-lacks-segments.wast.toMerge
new file mode 100644
index 000000000..63c2c3a3a
--- /dev/null
+++ b/test/merge/main-lacks-segments.wast.toMerge
@@ -0,0 +1,13 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (elem (get_global $tableBase) $foo)
+ (data (get_global $memoryBase) "hello, this is some data!")
+ (func $foo
+ (drop (get_global $tableBase))
+ (drop (get_global $memoryBase))
+ )
+)
+
diff --git a/test/merge/post-instantiate-a.wast b/test/merge/post-instantiate-a.wast
new file mode 100644
index 000000000..5099df574
--- /dev/null
+++ b/test/merge/post-instantiate-a.wast
@@ -0,0 +1,9 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (export "__post_instantiate" (func $0))
+ (func $0
+ (drop (i32.const 1000))
+ )
+)
+
diff --git a/test/merge/post-instantiate-a.wast.combined b/test/merge/post-instantiate-a.wast.combined
new file mode 100644
index 000000000..725e1df28
--- /dev/null
+++ b/test/merge/post-instantiate-a.wast.combined
@@ -0,0 +1,19 @@
+(module
+ (type $0 (func))
+ (type $0$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (memory $0 0)
+ (data (get_global $memoryBase) "")
+ (export "__post_instantiate" (func $0))
+ (func $0 (type $0)
+ (drop
+ (i32.const 1000)
+ )
+ )
+ (func $0$0 (type $0$0)
+ (nop)
+ )
+)
diff --git a/test/merge/post-instantiate-a.wast.combined.finalized b/test/merge/post-instantiate-a.wast.combined.finalized
new file mode 100644
index 000000000..e50f84e79
--- /dev/null
+++ b/test/merge/post-instantiate-a.wast.combined.finalized
@@ -0,0 +1,19 @@
+(module
+ (type $0 (func))
+ (type $0$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (memory $0 1)
+ (data (i32.const 1024) "")
+ (export "__post_instantiate" (func $0))
+ (func $0 (type $0)
+ (drop
+ (i32.const 1000)
+ )
+ )
+ (func $0$0 (type $0$0)
+ (nop)
+ )
+)
diff --git a/test/merge/post-instantiate-a.wast.combined.finalized.opt b/test/merge/post-instantiate-a.wast.combined.finalized.opt
new file mode 100644
index 000000000..2fc7dbdb3
--- /dev/null
+++ b/test/merge/post-instantiate-a.wast.combined.finalized.opt
@@ -0,0 +1,10 @@
+(module
+ (type $0 (func))
+ (type $0$0 (func))
+ (memory $0 1)
+ (data (i32.const 1024) "")
+ (export "__post_instantiate" (func $0))
+ (func $0 (type $0)
+ (nop)
+ )
+)
diff --git a/test/merge/post-instantiate-a.wast.combined.finalized.opt.stdout b/test/merge/post-instantiate-a.wast.combined.finalized.opt.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/post-instantiate-a.wast.combined.finalized.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/post-instantiate-a.wast.combined.finalized.stdout b/test/merge/post-instantiate-a.wast.combined.finalized.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/post-instantiate-a.wast.combined.finalized.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/post-instantiate-a.wast.combined.opt b/test/merge/post-instantiate-a.wast.combined.opt
new file mode 100644
index 000000000..8f190f187
--- /dev/null
+++ b/test/merge/post-instantiate-a.wast.combined.opt
@@ -0,0 +1,12 @@
+(module
+ (type $0 (func))
+ (type $0$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (memory $0 0)
+ (data (get_global $memoryBase) "")
+ (export "__post_instantiate" (func $0))
+ (func $0 (type $0)
+ (nop)
+ )
+)
diff --git a/test/merge/post-instantiate-a.wast.combined.opt.stdout b/test/merge/post-instantiate-a.wast.combined.opt.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/post-instantiate-a.wast.combined.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/post-instantiate-a.wast.combined.stdout b/test/merge/post-instantiate-a.wast.combined.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/post-instantiate-a.wast.combined.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/post-instantiate-a.wast.toMerge b/test/merge/post-instantiate-a.wast.toMerge
new file mode 100644
index 000000000..3b62ceb9e
--- /dev/null
+++ b/test/merge/post-instantiate-a.wast.toMerge
@@ -0,0 +1,6 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (func $0)
+)
+
diff --git a/test/merge/post-instantiate-b.wast b/test/merge/post-instantiate-b.wast
new file mode 100644
index 000000000..3b62ceb9e
--- /dev/null
+++ b/test/merge/post-instantiate-b.wast
@@ -0,0 +1,6 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (func $0)
+)
+
diff --git a/test/merge/post-instantiate-b.wast.combined b/test/merge/post-instantiate-b.wast.combined
new file mode 100644
index 000000000..df4bfe76d
--- /dev/null
+++ b/test/merge/post-instantiate-b.wast.combined
@@ -0,0 +1,19 @@
+(module
+ (type $0 (func))
+ (type $0$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (memory $0 0)
+ (data (get_global $memoryBase) "")
+ (export "__post_instantiate" (func $0$0))
+ (func $0 (type $0)
+ (nop)
+ )
+ (func $0$0 (type $0$0)
+ (drop
+ (i32.const 2000)
+ )
+ )
+)
diff --git a/test/merge/post-instantiate-b.wast.combined.finalized b/test/merge/post-instantiate-b.wast.combined.finalized
new file mode 100644
index 000000000..a6f2d309b
--- /dev/null
+++ b/test/merge/post-instantiate-b.wast.combined.finalized
@@ -0,0 +1,19 @@
+(module
+ (type $0 (func))
+ (type $0$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (memory $0 1)
+ (data (i32.const 1024) "")
+ (export "__post_instantiate" (func $0$0))
+ (func $0 (type $0)
+ (nop)
+ )
+ (func $0$0 (type $0$0)
+ (drop
+ (i32.const 2000)
+ )
+ )
+)
diff --git a/test/merge/post-instantiate-b.wast.combined.finalized.opt b/test/merge/post-instantiate-b.wast.combined.finalized.opt
new file mode 100644
index 000000000..f335f08d9
--- /dev/null
+++ b/test/merge/post-instantiate-b.wast.combined.finalized.opt
@@ -0,0 +1,10 @@
+(module
+ (type $0 (func))
+ (type $0$0 (func))
+ (memory $0 1)
+ (data (i32.const 1024) "")
+ (export "__post_instantiate" (func $0$0))
+ (func $0$0 (type $0$0)
+ (nop)
+ )
+)
diff --git a/test/merge/post-instantiate-b.wast.combined.finalized.opt.stdout b/test/merge/post-instantiate-b.wast.combined.finalized.opt.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/post-instantiate-b.wast.combined.finalized.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/post-instantiate-b.wast.combined.finalized.stdout b/test/merge/post-instantiate-b.wast.combined.finalized.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/post-instantiate-b.wast.combined.finalized.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/post-instantiate-b.wast.combined.opt b/test/merge/post-instantiate-b.wast.combined.opt
new file mode 100644
index 000000000..1a85ff79d
--- /dev/null
+++ b/test/merge/post-instantiate-b.wast.combined.opt
@@ -0,0 +1,12 @@
+(module
+ (type $0 (func))
+ (type $0$0 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (memory $0 0)
+ (data (get_global $memoryBase) "")
+ (export "__post_instantiate" (func $0$0))
+ (func $0$0 (type $0$0)
+ (nop)
+ )
+)
diff --git a/test/merge/post-instantiate-b.wast.combined.opt.stdout b/test/merge/post-instantiate-b.wast.combined.opt.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/post-instantiate-b.wast.combined.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/post-instantiate-b.wast.combined.stdout b/test/merge/post-instantiate-b.wast.combined.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/post-instantiate-b.wast.combined.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/post-instantiate-b.wast.toMerge b/test/merge/post-instantiate-b.wast.toMerge
new file mode 100644
index 000000000..0b3678389
--- /dev/null
+++ b/test/merge/post-instantiate-b.wast.toMerge
@@ -0,0 +1,9 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (export "__post_instantiate" (func $0))
+ (func $0
+ (drop (i32.const 2000))
+ )
+)
+
diff --git a/test/merge/printf.wast b/test/merge/printf.wast
new file mode 100644
index 000000000..c984602bf
--- /dev/null
+++ b/test/merge/printf.wast
@@ -0,0 +1,13 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "globally" (global $i-collide i32))
+ (import "env" "foobar" (func $import$8 (param i32 i32) (result i32)))
+ (export "_printf" (func $625))
+ (func $625 (param $var$0 i32) (param $var$1 i32) (result i32)
+ (i32.const 102030)
+ )
+)
+
diff --git a/test/merge/printf.wast.combined b/test/merge/printf.wast.combined
new file mode 100644
index 000000000..f8dcc3d0c
--- /dev/null
+++ b/test/merge/printf.wast.combined
@@ -0,0 +1,28 @@
+(module
+ (type $FUNCSIG$iii (func (param i32 i32) (result i32)))
+ (type $FUNCSIG$iii$0 (func (param i32 i32) (result i32)))
+ (type $1 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "globally" (global $i-collide i32))
+ (import "env" "foobar" (func $import$8 (param i32 i32) (result i32)))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (import "env" "globally" (global $i-collide$0 f64))
+
+ (data (get_global $memoryBase) "")
+ (export "_printf" (func $625))
+ (func $625 (type $FUNCSIG$iii) (param $var$0 i32) (param $var$1 i32) (result i32)
+ (i32.const 102030)
+ )
+ (func $b (type $1)
+ (drop
+ (call $625
+ (i32.const 11)
+ (i32.const 22)
+ )
+ )
+ )
+)
diff --git a/test/merge/printf.wast.combined.finalized b/test/merge/printf.wast.combined.finalized
new file mode 100644
index 000000000..c72f0d28f
--- /dev/null
+++ b/test/merge/printf.wast.combined.finalized
@@ -0,0 +1,28 @@
+(module
+ (type $FUNCSIG$iii (func (param i32 i32) (result i32)))
+ (type $FUNCSIG$iii$0 (func (param i32 i32) (result i32)))
+ (type $1 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 8 anyfunc))
+ (import "env" "globally" (global $i-collide i32))
+ (import "env" "foobar" (func $import$8 (param i32 i32) (result i32)))
+ (import "env" "memoryBase" (global $memoryBase$0 i32))
+ (import "env" "tableBase" (global $tableBase$0 i32))
+ (import "env" "globally" (global $i-collide$0 f64))
+
+ (data (i32.const 1024) "")
+ (export "_printf" (func $625))
+ (func $625 (type $FUNCSIG$iii) (param $var$0 i32) (param $var$1 i32) (result i32)
+ (i32.const 102030)
+ )
+ (func $b (type $1)
+ (drop
+ (call $625
+ (i32.const 11)
+ (i32.const 22)
+ )
+ )
+ )
+)
diff --git a/test/merge/printf.wast.combined.finalized.opt b/test/merge/printf.wast.combined.finalized.opt
new file mode 100644
index 000000000..92e17f720
--- /dev/null
+++ b/test/merge/printf.wast.combined.finalized.opt
@@ -0,0 +1,12 @@
+(module
+ (type $FUNCSIG$iii (func (param i32 i32) (result i32)))
+ (type $FUNCSIG$iii$0 (func (param i32 i32) (result i32)))
+ (type $1 (func))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 8 anyfunc))
+
+ (export "_printf" (func $625))
+ (func $625 (type $FUNCSIG$iii) (param $var$0 i32) (param $var$1 i32) (result i32)
+ (i32.const 102030)
+ )
+)
diff --git a/test/merge/printf.wast.combined.finalized.opt.stdout b/test/merge/printf.wast.combined.finalized.opt.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/printf.wast.combined.finalized.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/printf.wast.combined.finalized.stdout b/test/merge/printf.wast.combined.finalized.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/printf.wast.combined.finalized.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/printf.wast.combined.opt b/test/merge/printf.wast.combined.opt
new file mode 100644
index 000000000..e01710fd1
--- /dev/null
+++ b/test/merge/printf.wast.combined.opt
@@ -0,0 +1,15 @@
+(module
+ (type $FUNCSIG$iii (func (param i32 i32) (result i32)))
+ (type $FUNCSIG$iii$0 (func (param i32 i32) (result i32)))
+ (type $1 (func))
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+
+ (data (get_global $memoryBase) "")
+ (export "_printf" (func $625))
+ (func $625 (type $FUNCSIG$iii) (param $var$0 i32) (param $var$1 i32) (result i32)
+ (i32.const 102030)
+ )
+)
diff --git a/test/merge/printf.wast.combined.opt.stdout b/test/merge/printf.wast.combined.opt.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/printf.wast.combined.opt.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/printf.wast.combined.stdout b/test/merge/printf.wast.combined.stdout
new file mode 100644
index 000000000..3816869a7
--- /dev/null
+++ b/test/merge/printf.wast.combined.stdout
@@ -0,0 +1,3 @@
+merged total memory size: 0
+merged total table size: 0
+merged functions: 2
diff --git a/test/merge/printf.wast.toMerge b/test/merge/printf.wast.toMerge
new file mode 100644
index 000000000..d394abe34
--- /dev/null
+++ b/test/merge/printf.wast.toMerge
@@ -0,0 +1,14 @@
+(module
+ (import "env" "memoryBase" (global $memoryBase i32))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 0 anyfunc))
+ (import "env" "globally" (global $i-collide f64))
+ (import "env" "_printf" (func $import$8 (param i32 i32) (result i32)))
+ (func $b
+ (drop
+ (call $import$8 (i32.const 11) (i32.const 22))
+ )
+ )
+)
+