|
| 1 | +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. |
| 2 | +;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up. |
| 3 | + |
| 4 | +;; RUN: foreach %s %t wasm-opt --simplify-globals -all -S -o - | filecheck %s |
| 5 | + |
| 6 | +;; Apply constant globals to segment offsets. The non-imported global.gets will |
| 7 | +;; be applied in the segments named $use-defined. |
| 8 | + |
| 9 | +(module |
| 10 | + ;; CHECK: (type $0 (func)) |
| 11 | + |
| 12 | + ;; CHECK: (import "env" "memory" (memory $memory 256)) |
| 13 | + (import "env" "memory" (memory $memory 256)) |
| 14 | + |
| 15 | + ;; CHECK: (import "env" "table" (table $table 0 funcref)) |
| 16 | + (import "env" "table" (table $table 0 funcref)) |
| 17 | + |
| 18 | + ;; CHECK: (import "env" "imported" (global $imported i32)) |
| 19 | + (import "env" "imported" (global $imported i32)) |
| 20 | + |
| 21 | + ;; CHECK: (global $defined i32 (i32.const 42)) |
| 22 | + (global $defined i32 (i32.const 42)) |
| 23 | + |
| 24 | + ;; CHECK: (global $use-defined i32 (i32.const 42)) |
| 25 | + (global $use-defined i32 (global.get $defined)) |
| 26 | + |
| 27 | + ;; CHECK: (data $use-imported (global.get $imported) "hello, world!") |
| 28 | + (data $use-imported (global.get $imported) "hello, world!") |
| 29 | + |
| 30 | + ;; CHECK: (data $use-defined (i32.const 42) "hello, world!") |
| 31 | + (data $use-defined (global.get $defined) "hello, world!") |
| 32 | + |
| 33 | + ;; A passive segment has no offset to test, which we should not error on. |
| 34 | + ;; CHECK: (data $dropped "hello, world!") |
| 35 | + (data $dropped "hello, world!") |
| 36 | + |
| 37 | + ;; CHECK: (elem $use-imported (global.get $imported) $func) |
| 38 | + (elem $use-imported (global.get $imported) $func) |
| 39 | + |
| 40 | + ;; CHECK: (elem $use-defined (i32.const 42) $func $func) |
| 41 | + (elem $use-defined (global.get $defined) $func $func) |
| 42 | + |
| 43 | + ;; CHECK: (export "func" (func $func)) |
| 44 | + (export "func" (func $func)) |
| 45 | + |
| 46 | + ;; CHECK: (func $func (type $0) |
| 47 | + ;; CHECK-NEXT: (drop |
| 48 | + ;; CHECK-NEXT: (i32.load |
| 49 | + ;; CHECK-NEXT: (i32.const 0) |
| 50 | + ;; CHECK-NEXT: ) |
| 51 | + ;; CHECK-NEXT: ) |
| 52 | + ;; CHECK-NEXT: (drop |
| 53 | + ;; CHECK-NEXT: (table.get $table |
| 54 | + ;; CHECK-NEXT: (i32.const 0) |
| 55 | + ;; CHECK-NEXT: ) |
| 56 | + ;; CHECK-NEXT: ) |
| 57 | + ;; CHECK-NEXT: (drop |
| 58 | + ;; CHECK-NEXT: (global.get $imported) |
| 59 | + ;; CHECK-NEXT: ) |
| 60 | + ;; CHECK-NEXT: (drop |
| 61 | + ;; CHECK-NEXT: (i32.const 42) |
| 62 | + ;; CHECK-NEXT: ) |
| 63 | + ;; CHECK-NEXT: (data.drop $dropped) |
| 64 | + ;; CHECK-NEXT: ) |
| 65 | + (func $func |
| 66 | + ;; Use things to avoid DCE. |
| 67 | + (drop |
| 68 | + (i32.load |
| 69 | + (i32.const 0) |
| 70 | + ) |
| 71 | + ) |
| 72 | + (drop |
| 73 | + (table.get $table |
| 74 | + (i32.const 0) |
| 75 | + ) |
| 76 | + ) |
| 77 | + (drop |
| 78 | + (global.get $imported) |
| 79 | + ) |
| 80 | + (drop |
| 81 | + (global.get $use-defined) |
| 82 | + ) |
| 83 | + (data.drop $dropped) |
| 84 | + ) |
| 85 | +) |
0 commit comments