File: global-ordering.wat

package info (click to toggle)
binaryen 120-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,284 kB
  • sloc: cpp: 189,449; javascript: 62,189; ansic: 14,087; python: 5,379; pascal: 441; sh: 77; makefile: 30; asm: 27
file content (30 lines) | stat: -rw-r--r-- 1,062 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)
  )
)