Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay argument location use in CallSite::gen_arg #8151

Merged
merged 2 commits into from
Mar 15, 2024

Conversation

elliottt
Copy link
Member

@elliottt elliottt commented Mar 15, 2024

In preparation for handling callee-save registers in the tail calling convention, split the logic for handling argument locations out of CallSite::gen_arg. This allows us to process the arguments as normal, but delay the actual move to the stack until later.

I also took the opportunity to directly emit the instruction vector at the end of CallSite::gen_arg instead of returning it, as this is what's done at every use of CallSite::gen_arg already. Unfortunately the intermediate vector is still necessary as all calls to emit would be underneath an immutable borrow of ctx, but this does clean things up a little bit.

@elliottt elliottt requested a review from a team as a code owner March 15, 2024 18:51
@elliottt elliottt requested review from cfallin and removed request for a team March 15, 2024 18:51
Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me!

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:x64 Issues related to x64 codegen labels Mar 15, 2024
@elliottt elliottt added this pull request to the merge queue Mar 15, 2024
Merged via the queue into bytecodealliance:main with commit e3a08d4 Mar 15, 2024
21 checks passed
@elliottt elliottt deleted the trevor/gen-arg-locs branch March 15, 2024 21:03
jameysharp added a commit to jameysharp/wasmtime that referenced this pull request Apr 3, 2024
The `gen_spill` and `gen_reload` methods on `Callee` are used to emit
appropriate moves between registers and the stack, as directed by the
register allocator.

These moves always apply to a single register at a time, even if that
register was originally part of a group of registers. For example, when
an I128 is represented using two 64-bit registers, either of those
registers may be spilled independently.

As a result, the `load_spillslot`/`store_spillslot` helpers were more
general than necessary, which in turn required extra complexity in the
`gen_load_stack_multi`/`gen_store_stack_multi` helpers. None of these
helpers were used in any other context, so all that complexity was
unnecessary.

Inlining all four helpers and then simplifying eliminates a lot of code
without changing the output of the compiler.

These helpers were also the only uses of `StackAMode::offset`, so I've
deleted that. While I was there, I also deleted `StackAMode::get_type`,
which was introduced in bytecodealliance#8151 and became unused again in bytecodealliance#8246.
github-merge-queue bot pushed a commit that referenced this pull request Apr 3, 2024
The `gen_spill` and `gen_reload` methods on `Callee` are used to emit
appropriate moves between registers and the stack, as directed by the
register allocator.

These moves always apply to a single register at a time, even if that
register was originally part of a group of registers. For example, when
an I128 is represented using two 64-bit registers, either of those
registers may be spilled independently.

As a result, the `load_spillslot`/`store_spillslot` helpers were more
general than necessary, which in turn required extra complexity in the
`gen_load_stack_multi`/`gen_store_stack_multi` helpers. None of these
helpers were used in any other context, so all that complexity was
unnecessary.

Inlining all four helpers and then simplifying eliminates a lot of code
without changing the output of the compiler.

These helpers were also the only uses of `StackAMode::offset`, so I've
deleted that. While I was there, I also deleted `StackAMode::get_type`,
which was introduced in #8151 and became unused again in #8246.
jameysharp added a commit to jameysharp/wasmtime that referenced this pull request Apr 18, 2024
This reverts the key parts of e3a08d4
(bytecodealliance#8151), because it turns out that we didn't need that abstraction.

Several changes in the last month have enabled this:

- bytecodealliance#8292 and then bytecodealliance#8316 allow us to refer to either incoming or outgoing
  argument areas in a (mostly) consistent way

- bytecodealliance#8327, bytecodealliance#8377, and bytecodealliance#8383 demonstrate that we never need to delay
  writing stack arguments directly to their final location
jameysharp added a commit to jameysharp/wasmtime that referenced this pull request Apr 18, 2024
This reverts the key parts of e3a08d4
(bytecodealliance#8151), because it turns out that we didn't need that abstraction.

Several changes in the last month have enabled this:

- bytecodealliance#8292 and then bytecodealliance#8316 allow us to refer to either incoming or outgoing
  argument areas in a (mostly) consistent way

- bytecodealliance#8327, bytecodealliance#8377, and bytecodealliance#8383 demonstrate that we never need to delay
  writing stack arguments directly to their final location

prtest:full
github-merge-queue bot pushed a commit that referenced this pull request Apr 18, 2024
This reverts the key parts of e3a08d4
(#8151), because it turns out that we didn't need that abstraction.

Several changes in the last month have enabled this:

- #8292 and then #8316 allow us to refer to either incoming or outgoing
  argument areas in a (mostly) consistent way

- #8327, #8377, and #8383 demonstrate that we never need to delay
  writing stack arguments directly to their final location

prtest:full
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants