| ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. | |
| ;; RUN: foreach %s %t wasm-opt --gsi -all --closed-world -S -o - | filecheck %s | |
| ;; RUN: foreach %s %t wasm-opt --gsi-desc-cast -all --closed-world -S -o - | filecheck %s | |
| ;; A struct.new in a table initializer or in an element segment creates an | |
| ;; object that is not in a global, so a struct.get must not be replaced by a | |
| ;; read of the globals. | |
| (module | |
| ;; CHECK: (type $U (struct (field i32) (field i64))) | |
| ;; CHECK: (type $T (struct (field i32))) | |
| (type $T (struct (field i32))) | |
| (type $U (struct (field i32) (field i64))) | |
| ;; CHECK: (type $2 (func (result i32))) | |
| ;; CHECK: (global $g1 (ref $T) (struct.new $T | |
| ;; CHECK-NEXT: (i32.const 1) | |
| ;; CHECK-NEXT: )) | |
| (global $g1 (ref $T) (struct.new $T (i32.const 1))) | |
| ;; CHECK: (global $g2 (ref $T) (struct.new $T | |
| ;; CHECK-NEXT: (i32.const 2) | |
| ;; CHECK-NEXT: )) | |
| (global $g2 (ref $T) (struct.new $T (i32.const 2))) | |
| ;; CHECK: (global $h1 (ref $U) (struct.new $U | |
| ;; CHECK-NEXT: (i32.const 3) | |
| ;; CHECK-NEXT: (i64.const 0) | |
| ;; CHECK-NEXT: )) | |
| (global $h1 (ref $U) (struct.new $U (i32.const 3) (i64.const 0))) | |
| ;; CHECK: (global $h2 (ref $U) (struct.new $U | |
| ;; CHECK-NEXT: (i32.const 4) | |
| ;; CHECK-NEXT: (i64.const 0) | |
| ;; CHECK-NEXT: )) | |
| (global $h2 (ref $U) (struct.new $U (i32.const 4) (i64.const 0))) | |
| ;; CHECK: (table $t 1 1 (ref null $T) (struct.new $T | |
| ;; CHECK-NEXT: (i32.const 99) | |
| ;; CHECK-NEXT: )) | |
| (table $t 1 1 (ref null $T) (struct.new $T (i32.const 99))) | |
| ;; CHECK: (table $u 1 1 (ref null $U)) | |
| (table $u 1 1 (ref null $U)) | |
| (elem (table $u) (i32.const 0) (ref null $U) | |
| (item (struct.new $U (i32.const 98) (i64.const 0)))) | |
| ;; CHECK: (elem $0 (table $u) (i32.const 0) (ref null $U) (item (struct.new $U | |
| ;; CHECK-NEXT: (i32.const 98) | |
| ;; CHECK-NEXT: (i64.const 0) | |
| ;; CHECK-NEXT: ))) | |
| ;; CHECK: (export "from-table-init" (func $from-table-init)) | |
| ;; CHECK: (export "from-elem" (func $from-elem)) | |
| ;; CHECK: (func $from-table-init (type $2) (result i32) | |
| ;; CHECK-NEXT: (struct.get $T 0 | |
| ;; CHECK-NEXT: (ref.as_non_null | |
| ;; CHECK-NEXT: (table.get $t | |
| ;; CHECK-NEXT: (i32.const 0) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| (func $from-table-init (export "from-table-init") (result i32) | |
| (struct.get $T 0 | |
| (ref.as_non_null | |
| (table.get $t (i32.const 0)) | |
| ) | |
| ) | |
| ) | |
| ;; CHECK: (func $from-elem (type $2) (result i32) | |
| ;; CHECK-NEXT: (struct.get $U 0 | |
| ;; CHECK-NEXT: (ref.as_non_null | |
| ;; CHECK-NEXT: (table.get $u | |
| ;; CHECK-NEXT: (i32.const 0) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| (func $from-elem (export "from-elem") (result i32) | |
| (struct.get $U 0 | |
| (ref.as_non_null | |
| (table.get $u (i32.const 0)) | |
| ) | |
| ) | |
| ) | |
| ) |