|
| 1 | +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. |
| 2 | + |
| 3 | +;; RUN: foreach %s %t wasm-opt --gufa --closed-world -all -S -o - | filecheck %s |
| 4 | + |
| 5 | +;; Test that configureAll is respected: referred functions are assumed to be |
| 6 | +;; called from outside the module, depsite closed world. |
| 7 | + |
| 8 | +(module |
| 9 | + ;; CHECK: (type $externs (array (mut externref))) |
| 10 | + (type $externs (array (mut externref))) |
| 11 | + |
| 12 | + ;; CHECK: (type $funcs (array (mut funcref))) |
| 13 | + (type $funcs (array (mut funcref))) |
| 14 | + |
| 15 | + ;; CHECK: (type $bytes (array (mut i8))) |
| 16 | + (type $bytes (array (mut i8))) |
| 17 | + |
| 18 | + ;; CHECK: (type $3 (func (param i32) (result i32))) |
| 19 | + |
| 20 | + ;; CHECK: (type $configureAll (func (param (ref null $externs) (ref null $funcs) (ref null $bytes) externref))) |
| 21 | + (type $configureAll (func (param (ref null $externs)) (param (ref null $funcs)) (param (ref null $bytes)) (param externref))) |
| 22 | + |
| 23 | + ;; CHECK: (type $5 (func)) |
| 24 | + |
| 25 | + ;; CHECK: (import "wasm:js-prototypes" "configureAll" (func $configureAll (type $configureAll) (param (ref null $externs) (ref null $funcs) (ref null $bytes) externref))) |
| 26 | + (import "wasm:js-prototypes" "configureAll" (func $configureAll (type $configureAll))) |
| 27 | + |
| 28 | + ;; CHECK: (data $bytes "12345678") |
| 29 | + (data $bytes "12345678") |
| 30 | + |
| 31 | + ;; CHECK: (elem $externs externref (item (ref.null noextern))) |
| 32 | + (elem $externs externref |
| 33 | + (ref.null extern) |
| 34 | + ) |
| 35 | + |
| 36 | + ;; CHECK: (elem $funcs func $configured) |
| 37 | + (elem $funcs funcref |
| 38 | + (ref.func $configured) |
| 39 | + ) |
| 40 | + |
| 41 | + ;; CHECK: (elem $other func $unconfigured) |
| 42 | + (elem $other funcref |
| 43 | + (ref.func $unconfigured) |
| 44 | + ) |
| 45 | + |
| 46 | + ;; CHECK: (start $start) |
| 47 | + (start $start) |
| 48 | + |
| 49 | + ;; CHECK: (func $start (type $5) |
| 50 | + ;; CHECK-NEXT: (call $configureAll |
| 51 | + ;; CHECK-NEXT: (array.new_elem $externs $externs |
| 52 | + ;; CHECK-NEXT: (i32.const 0) |
| 53 | + ;; CHECK-NEXT: (i32.const 1) |
| 54 | + ;; CHECK-NEXT: ) |
| 55 | + ;; CHECK-NEXT: (array.new_elem $funcs $funcs |
| 56 | + ;; CHECK-NEXT: (i32.const 0) |
| 57 | + ;; CHECK-NEXT: (i32.const 1) |
| 58 | + ;; CHECK-NEXT: ) |
| 59 | + ;; CHECK-NEXT: (array.new_data $bytes $bytes |
| 60 | + ;; CHECK-NEXT: (i32.const 0) |
| 61 | + ;; CHECK-NEXT: (i32.const 8) |
| 62 | + ;; CHECK-NEXT: ) |
| 63 | + ;; CHECK-NEXT: (ref.null noextern) |
| 64 | + ;; CHECK-NEXT: ) |
| 65 | + ;; CHECK-NEXT: ) |
| 66 | + (func $start |
| 67 | + (call $configureAll |
| 68 | + (array.new_elem $externs $externs |
| 69 | + (i32.const 0) (i32.const 1)) |
| 70 | + (array.new_elem $funcs $funcs |
| 71 | + (i32.const 0) (i32.const 1)) |
| 72 | + (array.new_data $bytes $bytes |
| 73 | + (i32.const 0) (i32.const 8)) |
| 74 | + (ref.null extern) |
| 75 | + ) |
| 76 | + ) |
| 77 | + |
| 78 | + ;; CHECK: (func $configured (type $3) (param $x i32) (result i32) |
| 79 | + ;; CHECK-NEXT: (i32.eqz |
| 80 | + ;; CHECK-NEXT: (local.get $x) |
| 81 | + ;; CHECK-NEXT: ) |
| 82 | + ;; CHECK-NEXT: ) |
| 83 | + (func $configured (param $x i32) (result i32) |
| 84 | + ;; The call from outside the module, through configureAll, is the only call |
| 85 | + ;; we have - without it, this would be unreachable code, and optimized away. |
| 86 | + (i32.eqz |
| 87 | + (local.get $x) |
| 88 | + ) |
| 89 | + ) |
| 90 | + |
| 91 | + ;; CHECK: (func $unconfigured (type $3) (param $x i32) (result i32) |
| 92 | + ;; CHECK-NEXT: (i32.eqz |
| 93 | + ;; CHECK-NEXT: (unreachable) |
| 94 | + ;; CHECK-NEXT: ) |
| 95 | + ;; CHECK-NEXT: ) |
| 96 | + (func $unconfigured (param $x i32) (result i32) |
| 97 | + ;; As above, but *not* in configureAll (though it is in a table, so it is |
| 98 | + ;; not entirely removed) - so we do optimize. |
| 99 | + (i32.eqz |
| 100 | + (local.get $x) |
| 101 | + ) |
| 102 | + ) |
| 103 | +) |
0 commit comments