diff options
author | Alon Zakai <azakai@google.com> | 2024-08-26 16:00:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-26 16:00:45 -0700 |
commit | 459bc0797f67cb2a8fd4598bb7143b34036608d9 (patch) | |
tree | b582f48e4ac61dae6614d7296786fe363f7b82f5 /test | |
parent | 50181145e39304785ccedcd84be9cb7cc428b1f2 (diff) | |
download | binaryen-459bc0797f67cb2a8fd4598bb7143b34036608d9.tar.gz binaryen-459bc0797f67cb2a8fd4598bb7143b34036608d9.tar.bz2 binaryen-459bc0797f67cb2a8fd4598bb7143b34036608d9.zip |
[NFC] Optimize ParamUtils::getUsedParams() (#6866)
This constructed a LocalGraph, which computes the sets that reach each get. But
all we need to know is which params are live, so instead we can do a liveness
computation (which is just a boolean, not the list of sets). Also, it is simple to get
the liveness computation to only work on the parameters and not all the locals,
as a further optimization.
Existing tests cover this, though I did find that the case of unreachability needed
a new test.
On a large testcase I am looking at, this makes --dae 17% faster.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/dae_all-features.wast | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/lit/passes/dae_all-features.wast b/test/lit/passes/dae_all-features.wast index 17ea77942..da9558dd8 100644 --- a/test/lit/passes/dae_all-features.wast +++ b/test/lit/passes/dae_all-features.wast @@ -940,3 +940,34 @@ (unreachable) ) ) + +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (type $1 (func (param i32))) + + ;; CHECK: (func $target (type $0) + ;; CHECK-NEXT: (local $0 i32) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $target (param $0 i32) + ;; The parameter here is unused: there is a get, but it is unreachable. We can + ;; remove the parameter here, and in the caller below. + (unreachable) + (drop + (local.get $0) + ) + ) + + ;; CHECK: (func $caller (type $1) (param $x i32) + ;; CHECK-NEXT: (call $target) + ;; CHECK-NEXT: ) + (func $caller (param $x i32) + (call $target + (local.get $x) + ) + ) +) |