summaryrefslogtreecommitdiff
path: root/test/lit/binary/bad-multivalue-block.test.wasm
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-05-29 16:48:55 -0700
committerGitHub <noreply@github.com>2024-05-29 16:48:55 -0700
commitb85197cac4a295768f83133f7d01347ae2051276 (patch)
tree8b9fdf1f2a7fdf5d9113f22485b41d44f916a632 /test/lit/binary/bad-multivalue-block.test.wasm
parent56fe06220d558d300f3d49a036d637632ebd5ae4 (diff)
downloadbinaryen-b85197cac4a295768f83133f7d01347ae2051276.tar.gz
binaryen-b85197cac4a295768f83133f7d01347ae2051276.tar.bz2
binaryen-b85197cac4a295768f83133f7d01347ae2051276.zip
SignaturePruning: Properly handle public types (#6630)
The SignaturePruning pass optimizes away parameters that it proves are safe to remove. It turns out that that does not always match the definition of private types, which is more restrictive. Specifically, if say all the types are in one big rec group and one of them is used on an exported function then all of them are considered public (as the rec group is). However, in closed world, it would be ok to leave that rec group unchanged but to create a pruned version of that type and use it, in cases where we see it is safe to remove a parameter. (See the testcase for a concrete example.) To put it another way, SignaturePruning already proves that a parameter is safe to remove in all the ways that matter. Before this PR, however, the testcase in this PR would error - so this PR is not an optimization but a bugfix, really - because SignaturePruning would see that a parameter is safe to remove but then TypeUpdating would see the type is public and so it would leave it alone, leading to a broken module. This situation is in fact not that rare, and happens on real-world Java code. The reason we did not notice it before is that typically there are no remaining SignaturePruning opportunities late in the process (when other closed world optimizations have typically led to a single big rec group). The concrete fix here is to add additionalPrivateTypes to a few more places in TypeUpdating. We already supported that for cases where a pass knew better than the general logic what can be modified, and this adds that ability to the signature-rewriting logic there. Then SignaturePruning can send in all the types it has proven are safe to modify. * Also necessary here is to only add from additionalPrivateTypes if the type is not already in our list (or we'd end up with duplicates in the final rec group). * Also move newSignatures in SignaturePruning out of the top level, which was confusing (the pass has multiple iterations, and we want each to have a fresh instance).
Diffstat (limited to 'test/lit/binary/bad-multivalue-block.test.wasm')
0 files changed, 0 insertions, 0 deletions