blob: 077c51e734d75fa1bae18819c37d767475188091 (
plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
;; 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
;; Apply constant globals to segment offsets. The non-imported global.gets will
;; be applied in the segments named $use-defined.
(module
;; CHECK: (type $0 (func))
;; CHECK: (import "env" "memory" (memory $memory 256))
(import "env" "memory" (memory $memory 256))
;; CHECK: (import "env" "table" (table $table 0 funcref))
(import "env" "table" (table $table 0 funcref))
;; CHECK: (import "env" "imported" (global $imported i32))
(import "env" "imported" (global $imported i32))
;; CHECK: (global $defined i32 (i32.const 42))
(global $defined i32 (i32.const 42))
;; CHECK: (global $use-defined i32 (i32.const 42))
(global $use-defined i32 (global.get $defined))
;; CHECK: (data $use-imported (global.get $imported) "hello, world!")
(data $use-imported (global.get $imported) "hello, world!")
;; CHECK: (data $use-defined (i32.const 42) "hello, world!")
(data $use-defined (global.get $defined) "hello, world!")
;; A passive segment has no offset to test, which we should not error on.
;; CHECK: (data $dropped "hello, world!")
(data $dropped "hello, world!")
;; CHECK: (elem $use-imported (global.get $imported) $func)
(elem $use-imported (global.get $imported) $func)
;; CHECK: (elem $use-defined (i32.const 42) $func $func)
(elem $use-defined (global.get $defined) $func $func)
;; CHECK: (export "func" (func $func))
(export "func" (func $func))
;; CHECK: (func $func (type $0)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.load
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (table.get $table
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (global.get $imported)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 42)
;; CHECK-NEXT: )
;; CHECK-NEXT: (data.drop $dropped)
;; CHECK-NEXT: )
(func $func
;; Use things to avoid DCE.
(drop
(i32.load
(i32.const 0)
)
)
(drop
(table.get $table
(i32.const 0)
)
)
(drop
(global.get $imported)
)
(drop
(global.get $use-defined)
)
(data.drop $dropped)
)
)
|