Compute effects for indirect calls in GlobalEffects#8609
Compute effects for indirect calls in GlobalEffects#8609stevenfontanella wants to merge 21 commits intomainfrom
Conversation
b7ce0b6 to
9fcf76b
Compare
9fcf76b to
0e28a7a
Compare
0e28a7a to
83f4b3b
Compare
83f4b3b to
3a25c2e
Compare
|
Also added some tests exercising call_indirect. |
We don't need to walk up the supertype chain for type targets of indirect calls, we already do that for function implementations which would reach the type of the indirect call anyway
|
Added a test showing two different effect types being aggregated into the same function (global-effects-closed-world-simplify-locals.wast). |
The test went wrong at some point, let me update. |
It turns out that the effects were pessimized when changing the features from |
| if (!closedWorld) { | ||
| for (const auto& [caller, callerInfo] : funcInfos) { |
There was a problem hiding this comment.
Don't we have to add the function -> function direct call edges whether or not we're in a closed world? I would expect this condition to guard just the early return below.
There was a problem hiding this comment.
We do add these edges in both cases, the code is duplicated below. I wrote it this way since otherwise we'd have to have two different checks for !closedWorld (one continue in the loop and one early return before creating the Type -> Type edges), and I felt that it wasn't clear what the behavior is if !closedWorld since the logic was interleaved.
5086816 to
79f3ead
Compare
189d543 to
2630eff
Compare
Looks like this was due to LinearExecutionWalker (used in SimplifyLocals) not taking global effects into account and unconditionally assuming that functions may throw even if we determined that they won't. I tested with #8637 and found that the test works correctly with |
When running in --closed-world, compute effects for indirect calls by unioning the effects of all potential functions of that type. In --closed-world, we assume that all references originate in our module, so the only possible functions that we don't know about are imports. Previously we gave up on effects analysis for indirect calls.
Yields a very small byte count reduction in calcworker (3799354 - 3799297 = 57 bytes). Also shows no significant difference in Binaryen runtime: (0.1346069 -> 0.13375045 = <1% improvement, probably within noise). We expect more benefits after we're able to share indirect call effects with other passes, since currently they're only seen one layer up for callers of functions that indirectly call functions (see the newly-added tests for examples).
Followups:
Part of #8615.