diff options
author | Alon Zakai <azakai@google.com> | 2021-07-28 13:00:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-28 13:00:55 -0700 |
commit | c5166f636c5835413046be76e26c362ef4bbecc5 (patch) | |
tree | a96e328836e14b6ecc153eccc693329aca45a381 | |
parent | 5aab7956eab367c12af1aadb052f67f40667e3ef (diff) | |
download | binaryen-c5166f636c5835413046be76e26c362ef4bbecc5.tar.gz binaryen-c5166f636c5835413046be76e26c362ef4bbecc5.tar.bz2 binaryen-c5166f636c5835413046be76e26c362ef4bbecc5.zip |
[Wasm GC] Allow tail call subtyping in DeadArgumentElimination (#4035)
Partially reverts #4025, removing the code and updates the test to show
we do the optimization.
-rw-r--r-- | src/passes/DeadArgumentElimination.cpp | 10 | ||||
-rw-r--r-- | test/lit/passes/dae-gc.wast | 8 |
2 files changed, 6 insertions, 12 deletions
diff --git a/src/passes/DeadArgumentElimination.cpp b/src/passes/DeadArgumentElimination.cpp index 9d8fa5b0d..f3e3ae98c 100644 --- a/src/passes/DeadArgumentElimination.cpp +++ b/src/passes/DeadArgumentElimination.cpp @@ -327,14 +327,8 @@ struct DAE : public Pass { // affect whether an argument is used or not, it just refines the type // where possible. refineArgumentTypes(func, calls, module); - // Refine return types as well, if we can. We cannot do so if this - // function is tail-called, because then the return type must match that - // of the function doing a tail call of it - we cannot change just one of - // them. - // - // TODO: Try to optimize in a more holistic manner, see the TODO in - // refineReturnTypes() about missing a global optimum. - if (!tailCallees.count(name) && refineReturnTypes(func, calls, module)) { + // Refine return types as well. + if (refineReturnTypes(func, calls, module)) { refinedReturnTypes = true; } // Check if all calls pass the same constant for a particular argument. diff --git a/test/lit/passes/dae-gc.wast b/test/lit/passes/dae-gc.wast index 0ea322ce8..833a56a1f 100644 --- a/test/lit/passes/dae-gc.wast +++ b/test/lit/passes/dae-gc.wast @@ -579,16 +579,16 @@ ) ;; This function does a return call of the one after it. The one after it - ;; returns a ref.func of this one. They both begin by returning a funcref; if - ;; we refine the return type of the latter (which ref.func allows us to do) - ;; then the return type would not match, and we would get a validation error. + ;; returns a ref.func of this one. They both begin by returning a funcref; + ;; after refining the return type of the second function, it will have a more + ;; specific type (which is ok as subtyping is allowed with tail calls). ;; CHECK: (func $do-return-call (result funcref) ;; CHECK-NEXT: (return_call $return-ref-func) ;; CHECK-NEXT: ) (func $do-return-call (result funcref) (return_call $return-ref-func) ) - ;; CHECK: (func $return-ref-func (result funcref) + ;; CHECK: (func $return-ref-func (result (ref $none_=>_funcref)) ;; CHECK-NEXT: (ref.func $do-return-call) ;; CHECK-NEXT: ) (func $return-ref-func (result funcref) |