diff options
author | Alon Zakai <azakai@google.com> | 2023-11-14 19:09:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-14 19:09:49 -0800 |
commit | 20fe882b47c4b2570c70b2f9d82189c5b2144d03 (patch) | |
tree | 51eb6b6b63ccfecf21d732dc682cee646272947f /test | |
parent | 001be441be8ec04df0b03035aefc411923485780 (diff) | |
download | binaryen-20fe882b47c4b2570c70b2f9d82189c5b2144d03.tar.gz binaryen-20fe882b47c4b2570c70b2f9d82189c5b2144d03.tar.bz2 binaryen-20fe882b47c4b2570c70b2f9d82189c5b2144d03.zip |
SignatureRefining: Notice LUB requirements of intrinsic calls (#6122)
call.without.effects implies a call to the function reference in the last parameter,
so the values sent in the other parameters must be taken into account when
computing LUBs for refining arguments, otherwise we might refine so much that
the intrinsic call no longer validates.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/signature-refining.wast | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/lit/passes/signature-refining.wast b/test/lit/passes/signature-refining.wast index c2a505e51..95007b1c4 100644 --- a/test/lit/passes/signature-refining.wast +++ b/test/lit/passes/signature-refining.wast @@ -985,3 +985,60 @@ (struct.new $C) ;; this will allow this function's result to be refined to $C ) ) + +;; Test we consider call.without.effects when deciding what to refine. $A has +;; two subtypes, B1 and B2, and a call.without.effects sends in one while a +;; normal call sends in the other. As a result, we cannot refine to either. +(module + (rec + ;; CHECK: (rec + ;; CHECK-NEXT: (type $A (sub (struct ))) + (type $A (sub (struct))) + + ;; CHECK: (type $B1 (sub $A (struct ))) + (type $B1 (sub $A (struct))) + + ;; CHECK: (type $B2 (sub $A (struct ))) + (type $B2 (sub $A (struct))) + ) + + ;; CHECK: (type $3 (func (param (ref $A) funcref))) + + ;; CHECK: (type $4 (func)) + + ;; CHECK: (type $5 (func (param (ref $A)))) + + ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $no.side.effects (type $3) (param (ref $A) funcref))) + (import "binaryen-intrinsics" "call.without.effects" (func $no.side.effects + (param (ref $A)) + (param funcref) + )) + + ;; CHECK: (elem declare func $target) + + ;; CHECK: (func $calls (type $4) + ;; CHECK-NEXT: (call $no.side.effects + ;; CHECK-NEXT: (struct.new_default $B1) + ;; CHECK-NEXT: (ref.func $target) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $target + ;; CHECK-NEXT: (struct.new_default $B2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $calls + (call $no.side.effects + (struct.new $B1) + (ref.func $target) + ) + (call $target + (struct.new $B2) + ) + ) + + ;; CHECK: (func $target (type $5) (param $x (ref $A)) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + (func $target (param $x (ref $A)) + ;; Because of the two calls above, this cannot be refined. + ) +) |