|
| 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 --signature-pruning --closed-world -all -S -o - | filecheck %s |
| 4 | + |
| 5 | +;; Test that configureAll is respected: referred functions are not pruned. |
| 6 | + |
| 7 | +(module |
| 8 | + ;; CHECK: (type $externs (array (mut externref))) |
| 9 | + (type $externs (array (mut externref))) |
| 10 | + |
| 11 | + ;; CHECK: (type $funcs (array (mut funcref))) |
| 12 | + (type $funcs (array (mut funcref))) |
| 13 | + |
| 14 | + ;; CHECK: (type $bytes (array (mut i8))) |
| 15 | + (type $bytes (array (mut i8))) |
| 16 | + |
| 17 | + |
| 18 | + ;; CHECK: (type $configureAll (func (param (ref null $externs) (ref null $funcs) (ref null $bytes) externref))) |
| 19 | + (type $configureAll (func (param (ref null $externs)) (param (ref null $funcs)) (param (ref null $bytes)) (param externref))) |
| 20 | + |
| 21 | + (type $struct (struct)) |
| 22 | + |
| 23 | + (rec |
| 24 | + ;; CHECK: (rec |
| 25 | + ;; CHECK-NEXT: (type $any-2 (func)) |
| 26 | + |
| 27 | + ;; CHECK: (type $any-1 (func (param anyref))) |
| 28 | + (type $any-1 (func (param anyref))) |
| 29 | + |
| 30 | + ;; use brands to allow $any-1/2 to be optimized separately. |
| 31 | + (type $brand1 (struct)) |
| 32 | + ) |
| 33 | + |
| 34 | + (rec |
| 35 | + (type $any-2 (func (param anyref))) |
| 36 | + |
| 37 | + (type $brand2 (struct)) |
| 38 | + (type $brand3 (struct)) |
| 39 | + ) |
| 40 | + |
| 41 | + ;; CHECK: (type $6 (func (result i32))) |
| 42 | + |
| 43 | + ;; CHECK: (type $7 (func)) |
| 44 | + |
| 45 | + ;; CHECK: (import "wasm:js-prototypes" "configureAll" (func $configureAll (type $configureAll) (param (ref null $externs) (ref null $funcs) (ref null $bytes) externref))) |
| 46 | + (import "wasm:js-prototypes" "configureAll" (func $configureAll (type $configureAll))) |
| 47 | + |
| 48 | + |
| 49 | + ;; CHECK: (data $bytes "12345678") |
| 50 | + |
| 51 | + ;; CHECK: (elem $externs externref (item (ref.null noextern))) |
| 52 | + (elem $externs externref |
| 53 | + (ref.null extern) |
| 54 | + ) |
| 55 | + |
| 56 | + ;; CHECK: (elem $funcs func $foo $bar) |
| 57 | + (elem $funcs funcref |
| 58 | + (ref.func $foo) |
| 59 | + (ref.func $bar) |
| 60 | + ) |
| 61 | + |
| 62 | + (data $bytes "12345678") |
| 63 | + |
| 64 | + ;; CHECK: (start $start) |
| 65 | + (start $start) |
| 66 | + |
| 67 | + ;; CHECK: (func $start (type $7) |
| 68 | + ;; CHECK-NEXT: (call $configureAll |
| 69 | + ;; CHECK-NEXT: (array.new_elem $externs $externs |
| 70 | + ;; CHECK-NEXT: (i32.const 0) |
| 71 | + ;; CHECK-NEXT: (i32.const 1) |
| 72 | + ;; CHECK-NEXT: ) |
| 73 | + ;; CHECK-NEXT: (array.new_elem $funcs $funcs |
| 74 | + ;; CHECK-NEXT: (i32.const 0) |
| 75 | + ;; CHECK-NEXT: (i32.const 2) |
| 76 | + ;; CHECK-NEXT: ) |
| 77 | + ;; CHECK-NEXT: (array.new_data $bytes $bytes |
| 78 | + ;; CHECK-NEXT: (i32.const 0) |
| 79 | + ;; CHECK-NEXT: (i32.const 8) |
| 80 | + ;; CHECK-NEXT: ) |
| 81 | + ;; CHECK-NEXT: (ref.null noextern) |
| 82 | + ;; CHECK-NEXT: ) |
| 83 | + ;; CHECK-NEXT: ) |
| 84 | + (func $start |
| 85 | + (call $configureAll |
| 86 | + (array.new_elem $externs $externs |
| 87 | + (i32.const 0) (i32.const 1)) |
| 88 | + (array.new_elem $funcs $funcs |
| 89 | + (i32.const 0) (i32.const 2)) |
| 90 | + (array.new_data $bytes $bytes |
| 91 | + (i32.const 0) (i32.const 8)) |
| 92 | + (ref.null extern) |
| 93 | + ) |
| 94 | + ) |
| 95 | + |
| 96 | + ;; CHECK: (func $foo (type $6) (result i32) |
| 97 | + ;; CHECK-NEXT: (i32.const 42) |
| 98 | + ;; CHECK-NEXT: ) |
| 99 | + (func $foo (result i32) |
| 100 | + ;; Nothing to do here anyhow, but do not error. |
| 101 | + (i32.const 42) |
| 102 | + ) |
| 103 | + |
| 104 | + ;; CHECK: (func $bar (type $any-1) (param $x anyref) |
| 105 | + ;; CHECK-NEXT: ) |
| 106 | + (func $bar (type $any-1) (param $x anyref) |
| 107 | + ;; The param is unused, but will not be pruned (turned into a local) due to |
| 108 | + ;; configureAll. |
| 109 | + ) |
| 110 | + |
| 111 | + ;; CHECK: (func $unconfigured (type $any-2) |
| 112 | + ;; CHECK-NEXT: (local $0 anyref) |
| 113 | + ;; CHECK-NEXT: ) |
| 114 | + (func $unconfigured (type $any-2) (param $x anyref) |
| 115 | + ;; This is not referred to by configureAll, and can be pruned. |
| 116 | + ) |
| 117 | +) |
0 commit comments