File: simplify-globals-nested.wast

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 (32 lines) | stat: -rw-r--r-- 1,054 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
31
32
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up.

;; RUN: foreach %s %t wasm-opt --simplify-globals -all -S -o - | filecheck %s

;; Test that we propagate globals into nested children of other globals.

(module
 ;; CHECK:      (type $struct (struct (field i32) (field i32) (field i32)))
 (type $struct (struct i32 i32 i32))

 ;; CHECK:      (import "x" "y" (global $no i32))
 (import "x" "y" (global $no i32))

 ;; CHECK:      (global $a i32 (i32.const 42))
 (global $a i32 (i32.const 42))

 ;; CHECK:      (global $b i32 (i32.const 1337))
 (global $b i32 (i32.const 1337))

 ;; CHECK:      (global $struct (ref $struct) (struct.new $struct
 ;; CHECK-NEXT:  (i32.const 42)
 ;; CHECK-NEXT:  (global.get $no)
 ;; CHECK-NEXT:  (i32.const 1337)
 ;; CHECK-NEXT: ))
 (global $struct (ref $struct) (struct.new $struct
  (global.get $a)
  (global.get $no) ;; the middle item cannot be optimized
  (global.get $b)
 ))
)