Skip to content

Translate Wasm block params into Variables instead of CLIF block params#13711

Open
fitzgen wants to merge 1 commit into
bytecodealliance:mainfrom
fitzgen:wasmtime-wasm-block-params-should-be-variables
Open

Translate Wasm block params into Variables instead of CLIF block params#13711
fitzgen wants to merge 1 commit into
bytecodealliance:mainfrom
fitzgen:wasmtime-wasm-block-params-should-be-variables

Conversation

@fitzgen

@fitzgen fitzgen commented Jun 22, 2026

Copy link
Copy Markdown
Member

This allows SSA construction to determine whether they need to actually become block params or not, and cuts down on the number of unnecessary block parameters we pessimistically introduce during Wasm-to-CLIF translation.

…rams

This allows SSA construction to determine whether they need to actually become
block params or not, and cuts down on the number of unnecessary block parameters
we pessimistically introduce during Wasm-to-CLIF translation.
@fitzgen fitzgen requested review from a team as code owners June 22, 2026 22:01
@fitzgen fitzgen requested review from cfallin and removed request for a team June 22, 2026 22:01

@cfallin cfallin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This technically looks fine to me, and I agree it's nice to use our existing algorithm to avoid creating blockparams where they are actually trivial/unneeded.

I'm curious, however, since this does make things a little more complex (some blocks take vars, some don't), and leans more on an implicit SSA construction algorithm, which does have some cost, with the hypothesis that we'll get better code / faster compiles with fewer blockparams in the IR: have you measured the improvement? Do we see faster compile or faster runtimes out of this?

/// For a Wasm control-flow target (i.e. a block with associated parameter
/// `Variable`s) we `use_var` each of those variables. For a block with real
/// CLIF block parameters (the function's exit block) we read those parameters
/// directly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This distinction seems to me like it has potential to be error-prone or at least lead to subtle cases (e.g. there's the implicit invariant that the exit block is not also a Wasm target; we're creating a new bifurcation of kinds-of-blocks). Is there a reason we can't have the exit-block take its return value(s) as variables, too?

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.

2 participants