Compute effects for indirect calls in GlobalEffects#8609
Compute effects for indirect calls in GlobalEffects#8609stevenfontanella wants to merge 10 commits intomainfrom
Conversation
b7ce0b6 to
9fcf76b
Compare
9fcf76b to
0e28a7a
Compare
0e28a7a to
83f4b3b
Compare
83f4b3b to
3a25c2e
Compare
| } | ||
| }; | ||
|
|
||
| // Explicit deduction guide to resolve -Wctad-maybe-unsupported |
There was a problem hiding this comment.
Using ranges turned out to be much more complicated than I thought 😢
There was a problem hiding this comment.
I am not that impressed with the clarity of the Ranges code... but I don't feel strongly if you two like it.
There was a problem hiding this comment.
Totally agreed, this is my first time trying ranges. Disabling -Wctad-maybe-unsupported is an option which would let us remove this but Gemini suggested that the auto-generated deduction guides go wrong sometimes: https://gist.github.com/stevenfontanella/819251700a408d6243f7833acebdad20
There was a problem hiding this comment.
The bigger problem is that google uses that option when compiling this internally.
| (type $func-with-sub-param (sub (func (param (ref $sub))))) | ||
| ;; Subtype | ||
| ;; CHECK: (type $func-with-super-param (sub $func-with-sub-param (func (param (ref $super))))) | ||
| (type $func-with-super-param (sub $func-with-sub-param (func (param (ref $super))))) |
There was a problem hiding this comment.
You could simplify these tests by getting rid of the struct types and parameters entirely, and just have (type $super (sub (func))) and (type $sub (sub $super (func))).
| ;; Similar to $f, but we may still trap here because the ref is null, so we | ||
| ;; don't optimize. | ||
| (call $calls-nop-via-nullable-ref (local.get $ref)) |
There was a problem hiding this comment.
It would be interesting to test --traps-never-happen mode as well so show that this will be optimized in that case.
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 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.