diff options
author | Alon Zakai <azakai@google.com> | 2023-01-13 10:45:45 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-13 18:45:45 +0000 |
commit | dc278daff914c401201c1476035de30dc5bc0bd2 (patch) | |
tree | c8e31136d856ce1bbe65d319c82c806197ab4630 /test | |
parent | 26d3eaada5e8f386b4cfff64461792824c9ff596 (diff) | |
download | binaryen-dc278daff914c401201c1476035de30dc5bc0bd2.tar.gz binaryen-dc278daff914c401201c1476035de30dc5bc0bd2.tar.bz2 binaryen-dc278daff914c401201c1476035de30dc5bc0bd2.zip |
[Wasm GC] SignaturePruning should not prune fields from a type with subtypes (#5427)
For subtyping to not break, we must leave the number of fields equal in both
super and subtype, for each such pair.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/signature-pruning.wast | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/lit/passes/signature-pruning.wast b/test/lit/passes/signature-pruning.wast index c3d6567f7..76a2666ab 100644 --- a/test/lit/passes/signature-pruning.wast +++ b/test/lit/passes/signature-pruning.wast @@ -849,3 +849,42 @@ ) ) ) + +;; Due to function subtyping, we cannot prune fields from $func.B without also +;; pruning them in $func.A, and vice versa, if they have a subtyping +;; relationship. Atm we do not prune such "cycles" so we do not optimize here. +;; TODO +(module + ;; CHECK: (type $array.A (array (ref $struct.A))) + + ;; CHECK: (type $array.B (array_subtype (ref $struct.B) $array.A)) + + ;; CHECK: (type $func.A (func (param (ref $array.B)) (result (ref $array.A)))) + + ;; CHECK: (type $func.B (func_subtype (param (ref $array.A)) (result (ref $array.B)) $func.A)) + + ;; CHECK: (type $struct.A (struct (field i32))) + (type $struct.A (struct (field i32))) + ;; CHECK: (type $struct.B (struct_subtype (field i32) (field i64) $struct.A)) + (type $struct.B (struct_subtype (field i32) (field i64) $struct.A)) + + (type $array.A (array (ref $struct.A))) + (type $array.B (array_subtype (ref $struct.B) $array.A)) + + (type $func.A (func (param (ref $array.B)) (result (ref $array.A)))) + (type $func.B (func_subtype (param (ref $array.A)) (result (ref $array.B)) $func.A)) + + ;; CHECK: (func $func.A (type $func.A) (param $0 (ref $array.B)) (result (ref $array.A)) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $func.A (type $func.A) (param $0 (ref $array.B)) (result (ref $array.A)) + (unreachable) + ) + + ;; CHECK: (func $func.B (type $func.B) (param $0 (ref $array.A)) (result (ref $array.B)) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $func.B (type $func.B) (param $0 (ref $array.A)) (result (ref $array.B)) + (unreachable) + ) +) |