| ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. |
| |
| ;; RUN: wasm-merge %s first %s.second second -all -S -o - | filecheck %s |
| |
| ;; A table initializer expression may only refer to imported globals. When |
| ;; wasm-merge fuses the imported global $g that the table initializer refers to |
| ;; with the module-defined global exported from the second module, the |
| ;; initializer would end up referring to a module-defined global, which is not |
| ;; allowed. Verify that we inline the global's value into the initializer to keep |
| ;; it valid, rather than emitting an invalid module. |
| |
| (module |
| ;; CHECK: (type $f (func)) |
| (type $f (func)) |
| |
| (global $g (import "second" "g") (ref $f)) |
| |
| ;; CHECK: (global $g_1 (ref $f) (ref.func $h)) |
| |
| ;; CHECK: (table $t 3 funcref (ref.func $h)) |
| (table $t (export "t") 3 funcref (global.get $g)) |
| ) |
| ;; CHECK: (export "t" (table $t)) |
| |
| ;; CHECK: (export "g" (global $g_1)) |
| |
| ;; CHECK: (func $h (type $f) |
| ;; CHECK-NEXT: ) |