|
494 | 494 | ;; CHECK-NEXT: )
|
495 | 495 | ;; CHECK-NEXT: (drop
|
496 | 496 | ;; CHECK-NEXT: (br $block
|
497 |
| - ;; CHECK-NEXT: (local.tee $any |
498 |
| - ;; CHECK-NEXT: (struct.new_default $struct2) |
| 497 | + ;; CHECK-NEXT: (ref.as_non_null |
| 498 | + ;; CHECK-NEXT: (local.tee $any |
| 499 | + ;; CHECK-NEXT: (struct.new_default $struct2) |
| 500 | + ;; CHECK-NEXT: ) |
499 | 501 | ;; CHECK-NEXT: )
|
500 | 502 | ;; CHECK-NEXT: )
|
501 | 503 | ;; CHECK-NEXT: )
|
|
531 | 533 | )
|
532 | 534 | )
|
533 | 535 | (drop
|
534 |
| - ;; Ditto. |
| 536 | + ;; Ditto, but also add a ref.as_non_null, as we must keep sending a non- |
| 537 | + ;; null value to the block (the block would still validate either way, but |
| 538 | + ;; we do not want to un-refine the sent value). See the next function for a |
| 539 | + ;; test with a non-nullable block. |
535 | 540 | (br_on_cast_fail $block anyref (ref null $struct)
|
536 | 541 | (local.tee $any (struct.new $struct2))
|
537 | 542 | )
|
|
552 | 557 | )
|
553 | 558 | )
|
554 | 559 |
|
| 560 | + ;; CHECK: (func $br_on_cast_fail_unrelated-fallthrough-non-null (type $11) (result (ref any)) |
| 561 | + ;; CHECK-NEXT: (local $any anyref) |
| 562 | + ;; CHECK-NEXT: (local $nullable-struct2 (ref null $struct2)) |
| 563 | + ;; CHECK-NEXT: (block $block (result (ref any)) |
| 564 | + ;; CHECK-NEXT: (drop |
| 565 | + ;; CHECK-NEXT: (br $block |
| 566 | + ;; CHECK-NEXT: (ref.as_non_null |
| 567 | + ;; CHECK-NEXT: (local.tee $any |
| 568 | + ;; CHECK-NEXT: (struct.new_default $struct2) |
| 569 | + ;; CHECK-NEXT: ) |
| 570 | + ;; CHECK-NEXT: ) |
| 571 | + ;; CHECK-NEXT: ) |
| 572 | + ;; CHECK-NEXT: ) |
| 573 | + ;; CHECK-NEXT: (drop |
| 574 | + ;; CHECK-NEXT: (block (result nullref) |
| 575 | + ;; CHECK-NEXT: (br_on_non_null $block |
| 576 | + ;; CHECK-NEXT: (local.tee $any |
| 577 | + ;; CHECK-NEXT: (local.get $nullable-struct2) |
| 578 | + ;; CHECK-NEXT: ) |
| 579 | + ;; CHECK-NEXT: ) |
| 580 | + ;; CHECK-NEXT: (ref.null none) |
| 581 | + ;; CHECK-NEXT: ) |
| 582 | + ;; CHECK-NEXT: ) |
| 583 | + ;; CHECK-NEXT: (unreachable) |
| 584 | + ;; CHECK-NEXT: ) |
| 585 | + ;; CHECK-NEXT: ) |
| 586 | + (func $br_on_cast_fail_unrelated-fallthrough-non-null (result (ref any)) |
| 587 | + ;; Same as above, but the block is now non-nullable. Only the branches that |
| 588 | + ;; work with that are tested. |
| 589 | + (local $any anyref) |
| 590 | + (local $nullable-struct2 (ref null $struct2)) |
| 591 | + (block $block (result (ref any)) ;; this changed, and the function's results |
| 592 | + (drop |
| 593 | + ;; Will definitely take the branch. |
| 594 | + (br_on_cast_fail $block anyref (ref null $struct) |
| 595 | + (local.tee $any (struct.new $struct2)) |
| 596 | + ) |
| 597 | + ) |
| 598 | + (drop |
| 599 | + ;; Still has to do a null check. |
| 600 | + (br_on_cast_fail $block anyref (ref null $struct) |
| 601 | + (local.tee $any (local.get $nullable-struct2)) |
| 602 | + ) |
| 603 | + ) |
| 604 | + (unreachable) |
| 605 | + ) |
| 606 | + ) |
| 607 | + |
555 | 608 | ;; CHECK: (func $br_on_cast-unreachable (type $7) (param $i31ref i31ref) (result anyref)
|
556 | 609 | ;; CHECK-NEXT: (block $block
|
557 | 610 | ;; CHECK-NEXT: (drop
|
|
840 | 893 | )
|
841 | 894 | )
|
842 | 895 |
|
843 |
| - ;; CHECK: (func $threading (type $11) (param $x anyref) |
| 896 | + ;; CHECK: (func $threading (type $12) (param $x anyref) |
844 | 897 | ;; CHECK-NEXT: (block $outer
|
845 | 898 | ;; CHECK-NEXT: (block $inner
|
846 | 899 | ;; CHECK-NEXT: (drop
|
|
864 | 917 | )
|
865 | 918 | )
|
866 | 919 |
|
867 |
| - ;; CHECK: (func $test (type $12) (param $x (ref any)) |
| 920 | + ;; CHECK: (func $test (type $13) (param $x (ref any)) |
868 | 921 | ;; CHECK-NEXT: (local $temp anyref)
|
869 | 922 | ;; CHECK-NEXT: (drop
|
870 | 923 | ;; CHECK-NEXT: (block $block (result (ref $struct-nn))
|
|
916 | 969 | )
|
917 | 970 | )
|
918 | 971 |
|
919 |
| - ;; CHECK: (func $select-refinalize (type $13) (param $param (ref $struct)) (result (ref struct)) |
| 972 | + ;; CHECK: (func $select-refinalize (type $14) (param $param (ref $struct)) (result (ref struct)) |
920 | 973 | ;; CHECK-NEXT: (select (result (ref $struct))
|
921 | 974 | ;; CHECK-NEXT: (select (result (ref $struct))
|
922 | 975 | ;; CHECK-NEXT: (global.get $struct)
|
|
0 commit comments