|
1 | 1 | ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. |
2 | | -;; RUN: wasm-opt %s --optimize-instructions --ignore-implicit-traps --enable-reference-types --enable-gc -S -o - \ |
| 2 | +;; RUN: foreach %s %t wasm-opt --optimize-instructions --ignore-implicit-traps --enable-reference-types --enable-gc -S -o - \ |
3 | 3 | ;; RUN: | filecheck %s |
4 | | -;; RUN: wasm-opt %s --optimize-instructions --ignore-implicit-traps --enable-reference-types --enable-gc --nominal -S -o - \ |
| 4 | +;; RUN: foreach %s %t wasm-opt --optimize-instructions --ignore-implicit-traps --enable-reference-types --enable-gc --nominal -S -o - \ |
5 | 5 | ;; RUN: | filecheck %s --check-prefix NOMNL |
6 | 6 | ;; Also test trapsNeverHappen (with nominal; no need for both type system modes). |
7 | | -;; RUN: wasm-opt %s --optimize-instructions --traps-never-happen --enable-reference-types --enable-gc --nominal -S -o - \ |
| 7 | +;; RUN: foreach %s %t wasm-opt --optimize-instructions --traps-never-happen --enable-reference-types --enable-gc --nominal -S -o - \ |
8 | 8 | ;; RUN: | filecheck %s --check-prefix NOMNL-TNH |
9 | 9 |
|
10 | 10 | (module |
|
367 | 367 | ) |
368 | 368 | ) |
369 | 369 | ) |
| 370 | + |
| 371 | +(module |
| 372 | + ;; CHECK: (type $B (struct (field (ref null $A)))) |
| 373 | + |
| 374 | + ;; CHECK: (type $A (struct )) |
| 375 | + ;; NOMNL: (type $C (struct_subtype (field (ref null $D)) $B)) |
| 376 | + |
| 377 | + ;; NOMNL: (type $D (struct_subtype $A)) |
| 378 | + |
| 379 | + ;; NOMNL: (type $A (struct_subtype data)) |
| 380 | + ;; NOMNL-TNH: (type $C (struct_subtype (field (ref null $D)) $B)) |
| 381 | + |
| 382 | + ;; NOMNL-TNH: (type $D (struct_subtype $A)) |
| 383 | + |
| 384 | + ;; NOMNL-TNH: (type $A (struct_subtype data)) |
| 385 | + (type $A (struct_subtype data)) |
| 386 | + ;; NOMNL: (type $B (struct_subtype (field (ref null $A)) $A)) |
| 387 | + ;; NOMNL-TNH: (type $B (struct_subtype (field (ref null $A)) $A)) |
| 388 | + (type $B (struct_subtype (field (ref null $A)) $A)) |
| 389 | + (type $C (struct_subtype (field (ref null $D)) $B)) |
| 390 | + (type $D (struct_subtype $A)) |
| 391 | + |
| 392 | + ;; CHECK: (func $test (param $C (ref $B)) (result anyref) |
| 393 | + ;; CHECK-NEXT: (struct.get $B 0 |
| 394 | + ;; CHECK-NEXT: (local.get $C) |
| 395 | + ;; CHECK-NEXT: ) |
| 396 | + ;; CHECK-NEXT: ) |
| 397 | + ;; NOMNL: (func $test (type $ref|$C|_=>_anyref) (param $C (ref $C)) (result anyref) |
| 398 | + ;; NOMNL-NEXT: (struct.get $C 0 |
| 399 | + ;; NOMNL-NEXT: (local.get $C) |
| 400 | + ;; NOMNL-NEXT: ) |
| 401 | + ;; NOMNL-NEXT: ) |
| 402 | + ;; NOMNL-TNH: (func $test (type $ref|$C|_=>_anyref) (param $C (ref $C)) (result anyref) |
| 403 | + ;; NOMNL-TNH-NEXT: (struct.get $C 0 |
| 404 | + ;; NOMNL-TNH-NEXT: (local.get $C) |
| 405 | + ;; NOMNL-TNH-NEXT: ) |
| 406 | + ;; NOMNL-TNH-NEXT: ) |
| 407 | + (func $test (param $C (ref $C)) (result anyref) |
| 408 | + (struct.get $B 0 |
| 409 | + (ref.cast_static $B ;; Try to cast a $C to its parent, $B. That always |
| 410 | + ;; works, so the cast can be removed. |
| 411 | + ;; Then once the cast is removed, the outer struct.get |
| 412 | + ;; will have a reference with a different type, |
| 413 | + ;; making it a (struct.get $C ..) instead of $B. |
| 414 | + ;; But $B and $C have different types on field 0, and |
| 415 | + ;; so the struct.get must be refinalized so the node |
| 416 | + ;; has the expected type. |
| 417 | + (local.get $C) |
| 418 | + ) |
| 419 | + ) |
| 420 | + ) |
| 421 | +) |
0 commit comments