summaryrefslogtreecommitdiff
path: root/test/lit/merge
diff options
context:
space:
mode:
Diffstat (limited to 'test/lit/merge')
-rw-r--r--test/lit/merge/global-ordering.wat30
-rw-r--r--test/lit/merge/global-ordering.wat.second3
-rw-r--r--test/lit/merge/renamings.wat11
3 files changed, 39 insertions, 5 deletions
diff --git a/test/lit/merge/global-ordering.wat b/test/lit/merge/global-ordering.wat
new file mode 100644
index 000000000..2cc3b504b
--- /dev/null
+++ b/test/lit/merge/global-ordering.wat
@@ -0,0 +1,30 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+
+;; RUN: wasm-merge %s first %s.second second -all -S -o - | filecheck %s
+
+;; After the merge this module's global will read a value from a global that is
+;; appended after it, from the second module. Those must be reordered so that
+;; we validate, as a global can only read from previous ones.
+
+(module
+ (import "second" "second.global.export" (global i32))
+
+ ;; CHECK: (type $0 (func (result i32)))
+
+ ;; CHECK: (global $second.global i32 (i32.const 42))
+
+ ;; CHECK: (global $first.global (mut i32) (global.get $second.global))
+ (global $first.global (mut i32) (global.get 0))
+
+ ;; CHECK: (export "run" (func $run))
+
+ ;; CHECK: (export "second.global.export" (global $second.global))
+
+ ;; CHECK: (func $run (type $0) (result i32)
+ ;; CHECK-NEXT: (global.get $first.global)
+ ;; CHECK-NEXT: )
+ (func $run (export "run") (result i32)
+ ;; Use the global to avoid it being removed.
+ (global.get $first.global)
+ )
+)
diff --git a/test/lit/merge/global-ordering.wat.second b/test/lit/merge/global-ordering.wat.second
new file mode 100644
index 000000000..7676599e4
--- /dev/null
+++ b/test/lit/merge/global-ordering.wat.second
@@ -0,0 +1,3 @@
+(module
+ (global $second.global (export "second.global.export") i32 (i32.const 42))
+)
diff --git a/test/lit/merge/renamings.wat b/test/lit/merge/renamings.wat
index 6d4de5c65..98aac63be 100644
--- a/test/lit/merge/renamings.wat
+++ b/test/lit/merge/renamings.wat
@@ -23,20 +23,21 @@
;; CHECK: (import "elsewhere" "some.tag" (tag $imported (param f64)))
+ ;; CHECK: (global $bar_2 i32 (i32.const 4))
+
+ ;; CHECK: (global $other i32 (i32.const 3))
+
+ ;; CHECK: (global $bar i32 (i32.const 2))
+
;; CHECK: (global $foo i32 (i32.const 1))
(global $foo i32 (i32.const 1))
;; This global has a conflict in second.wat, and so second.wat's $bar
;; will be renamed.
- ;; CHECK: (global $bar i32 (i32.const 2))
(global $bar i32 (i32.const 2))
;; This memory has a conflict in second.wat, and so second.wat's $foo
;; will be renamed.
- ;; CHECK: (global $other i32 (i32.const 3))
-
- ;; CHECK: (global $bar_2 i32 (i32.const 4))
-
;; CHECK: (memory $foo 10 20)
(memory $foo 10 20)