summaryrefslogtreecommitdiff
path: root/src/ir/ReFinalize.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-03-18 14:18:09 -0700
committerGitHub <noreply@github.com>2024-03-18 14:18:09 -0700
commitd8086c63a9e3e6bbd1bdc5d7e0843af8433cc4c8 (patch)
treeb46989cd5f1e397b6eda83ca7741a1a5d2716728 /src/ir/ReFinalize.cpp
parentc166ca015860b337e9ce07a5e02cb707964056ba (diff)
downloadbinaryen-d8086c63a9e3e6bbd1bdc5d7e0843af8433cc4c8.tar.gz
binaryen-d8086c63a9e3e6bbd1bdc5d7e0843af8433cc4c8.tar.bz2
binaryen-d8086c63a9e3e6bbd1bdc5d7e0843af8433cc4c8.zip
DeadArgumentElimination/SignaturePruning: Prune params even if called with effects (#6395)
Before this PR, when we saw a param was unused we sometimes could not remove it. For example, if there was one call like this: (call $target (call $other) ) That nested call has effects, so we can't just remove it from the outer call - we'd need to move it first. That motion was hard to integrate which was why it was left out, but it turns out that is sometimes very important. E.g. in Java it is common to have such calls that send the this parameter as the result of another call; not being able to remove such params meant we kept those nested calls alive, creating empty structs just to have something to send there. To fix this, this builds on top of #6394 which makes it easier to move all children out of a parent, leaving only nested things that can be easily moved around and removed. In more detail, DeadArgumentElimination/SignaturePruning track whether we run into effects that prevent removing a field. If we do, then we queue an operation to move the children out, which we do using a new utility ParamUtils::localizeCallsTo. The pass then does another iteration after that operation. Alternatively we could try to move things around immediately, but that is quite hard: those passes already track a lot of state. It is simpler to do the fixup in an entirely separate utility. That does come at the cost of the utility doing another pass on the module and the pass itself running another iteration, but this situation is not the most common.
Diffstat (limited to 'src/ir/ReFinalize.cpp')
0 files changed, 0 insertions, 0 deletions