diff options
author | Alon Zakai <azakai@google.com> | 2022-08-08 11:39:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-08 11:39:00 -0700 |
commit | 1610e6b3f5148d47c4f352c528db7d24bcfa598c (patch) | |
tree | 669add18bea57695dd732ff366a5d19ddfcc6d95 /test/lit | |
parent | ec7af8390fb19fff06f2c5a385285370455d810a (diff) | |
download | binaryen-1610e6b3f5148d47c4f352c528db7d24bcfa598c.tar.gz binaryen-1610e6b3f5148d47c4f352c528db7d24bcfa598c.tar.bz2 binaryen-1610e6b3f5148d47c4f352c528db7d24bcfa598c.zip |
[Wasm GC] Fix SignaturePruning on CallWithoutEffects (#4882)
call.without.effects will turn into a normal call of the last parameter later,
(call $call.without.effects
A
B
(ref.func $foo)
)
;; => intrinsic lowering
(call $foo
A
B
)
SignaturePruning needs to be aware of that: we can't remove a parameter from $foo without
also updating relevant calls to $call.without.effects. Rather than handle that, just skip such
cases, and leave them to be optimized after intrinsics are lowered away.
Diffstat (limited to 'test/lit')
-rw-r--r-- | test/lit/passes/signature-pruning.wast | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/lit/passes/signature-pruning.wast b/test/lit/passes/signature-pruning.wast index 3c4500eaf..79f658007 100644 --- a/test/lit/passes/signature-pruning.wast +++ b/test/lit/passes/signature-pruning.wast @@ -810,3 +810,41 @@ ) ) ) + +;; Do not prune signatures used in the call.without.effects intrinsic. +(module + ;; CHECK: (type $i32_funcref_=>_i32 (func_subtype (param i32 funcref) (result i32) func)) + + ;; CHECK: (type $i32_=>_i32 (func_subtype (param i32) (result i32) func)) + + ;; CHECK: (type $none_=>_i32 (func_subtype (result i32) func)) + + ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $cwe (param i32 funcref) (result i32))) + (import "binaryen-intrinsics" "call.without.effects" (func $cwe (param i32 funcref) (result i32))) + + ;; CHECK: (elem declare func $func) + + ;; CHECK: (func $func (type $i32_=>_i32) (param $0 i32) (result i32) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + (func $func (param i32) (result i32) + ;; The parameter is unused, so we want to prune it. We won't because of the + ;; situation in the calling function, below. + (i32.const 1) + ) + + ;; CHECK: (func $caller (type $none_=>_i32) (result i32) + ;; CHECK-NEXT: (call $cwe + ;; CHECK-NEXT: (i32.const 41) + ;; CHECK-NEXT: (ref.func $func) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $caller (result i32) + ;; We call $func using call.without.effects. This causes us to not optimize + ;; in this case. + (call $cwe + (i32.const 41) + (ref.func $func) + ) + ) +) |