Skip to content

Compute effects for indirect calls in GlobalEffects#8609

Open
stevenfontanella wants to merge 18 commits intomainfrom
indirect-effects-scc
Open

Compute effects for indirect calls in GlobalEffects#8609
stevenfontanella wants to merge 18 commits intomainfrom
indirect-effects-scc

Conversation

@stevenfontanella
Copy link
Copy Markdown
Member

@stevenfontanella stevenfontanella commented Apr 15, 2026

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:

  • Share effect information per type with other passes besides just via Function::effects
  • Exclude functions that don't have an address (i.e. functions that aren't the target of ref.func) from effect analysis
  • Compute effects more precisely for exact + nullable/non-nullable references

Part of #8615.

@stevenfontanella stevenfontanella changed the base branch from main to effects-scc April 16, 2026 16:28
@stevenfontanella stevenfontanella force-pushed the indirect-effects-scc branch 8 times, most recently from b7ce0b6 to 9fcf76b Compare April 16, 2026 20:59
@stevenfontanella stevenfontanella changed the title Indirect effects scc Compute effects for indirect calls in GlobalEffects Apr 16, 2026
@stevenfontanella stevenfontanella marked this pull request as ready for review April 16, 2026 21:43
@stevenfontanella stevenfontanella requested a review from a team as a code owner April 16, 2026 21:43
@stevenfontanella stevenfontanella requested review from kripken and removed request for a team April 16, 2026 21:43
Base automatically changed from effects-scc to main April 16, 2026 22:36
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp
Comment thread src/passes/GlobalEffects.cpp
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp
Comment thread src/passes/GlobalEffects.cpp
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread test/lit/passes/global-effects-closed-world.wast Outdated
Comment thread test/lit/passes/global-effects-closed-world.wast
Comment thread test/lit/passes/global-effects-closed-world.wast
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp
Comment thread test/lit/passes/global-effects-closed-world.wast Outdated
Comment thread test/lit/passes/global-effects-closed-world.wast
Comment thread out.txt Outdated
Comment thread test/lit/passes/global-effects-closed-world.wast Outdated
Comment thread test/lit/passes/global-effects-closed-world.wast
Comment thread src/passes/GlobalEffects.cpp Outdated
@stevenfontanella
Copy link
Copy Markdown
Member Author

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
@stevenfontanella
Copy link
Copy Markdown
Member Author

Added a test showing two different effect types being aggregated into the same function (global-effects-closed-world-simplify-locals.wast).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants