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

Generate more fixed_nonallocatable constraints, and add debug assertions #5132

Merged
merged 2 commits into from
Nov 28, 2022

Conversation

elliottt
Copy link
Member

@elliottt elliottt commented Oct 26, 2022

Add assertions to the OperandCollector that show we're not using pinned vregs, and use reg_fixed_nonallocatable constraints when a real register is used with other constraint generation functions like reg_use etc.

I experimented with adding debug assertions that the reused operand referenced in reg_reuse_def constraints was compatible with the new constraint that would be generated. This didn't end up being possible as some backends will recursively process instructions when collecting operands, making it impossible without more invasive changes to tell where that operand is in the operand vector. Given that we would need to plumb through somewhat substantial changes to support adding debug assertions, I decided that rephrasing the existing warning comment about real registers would be good enough.

@elliottt elliottt force-pushed the trevor/ssa-assertions branch 2 times, most recently from 92bc735 to 463b859 Compare October 26, 2022 20:41
@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:aarch64 Issues related to AArch64 backend. cranelift:area:x64 Issues related to x64 codegen isle Related to the ISLE domain-specific language labels Oct 26, 2022
@github-actions
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

This issue or pull request has been labeled: "cranelift", "cranelift:area:aarch64", "cranelift:area:machinst", "cranelift:area:x64", "isle"

Thus the following users have been cc'd because of the following labels:

  • cfallin: isle
  • fitzgen: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@elliottt elliottt force-pushed the trevor/ssa-assertions branch from 463b859 to e2221c2 Compare October 26, 2022 22:29
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.

One thought on s390x's EmitInfo below, but general direction seems OK.

Separately from these asserts, we were also going to add checks that we don't use any pinned vregs, right? So the vreg provided to any operand (normal use/def, fixed-constraint use/def) needs to be non-pinned, i.e. >= 128.

cranelift/codegen/src/isa/s390x/inst/emit.rs Outdated Show resolved Hide resolved
@elliottt elliottt force-pushed the trevor/ssa-assertions branch from e2221c2 to 528e71e Compare November 1, 2022 16:57
@elliottt elliottt force-pushed the trevor/ssa-assertions branch 5 times, most recently from f05681c to b085ce4 Compare November 15, 2022 20:51
@elliottt elliottt force-pushed the trevor/ssa-assertions branch 5 times, most recently from 664ffb5 to bf21a10 Compare November 19, 2022 00:31
@elliottt elliottt force-pushed the trevor/ssa-assertions branch from bf21a10 to b6aa575 Compare November 19, 2022 06:43
@elliottt elliottt force-pushed the trevor/ssa-assertions branch from b6aa575 to 52a14a2 Compare November 19, 2022 09:06
@elliottt elliottt changed the title Debug assertions for SSA Generate more fixed Nov 19, 2022
@elliottt elliottt changed the title Generate more fixed Generate more fixed_nonallocatable constraints, and add debug assertions in constraint collection Nov 19, 2022
@elliottt elliottt changed the title Generate more fixed_nonallocatable constraints, and add debug assertions in constraint collection Generate more fixed_nonallocatable constraints, and add debug assertions Nov 19, 2022
@elliottt elliottt marked this pull request as ready for review November 19, 2022 09:15
@elliottt elliottt requested a review from cfallin November 28, 2022 17:29
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.

LGTM, thanks!

@elliottt elliottt merged commit 54a6d2f into bytecodealliance:main Nov 28, 2022
jameysharp added a commit to jameysharp/wasmtime that referenced this pull request Apr 23, 2024
When OperandCollector's reg_use/reg_late_use/reg_def/reg_early_def
methods are handed a Reg that refers to a physical ("real") register,
they all delegate to reg_fixed_nonallocatable, ignoring the constraint
kinds and positions. This behavior was introduced in bytecodealliance#5132.

In several cases, the s390x backend was calling those methods with the
result of the `gpr` or `writable_gpr` functions, which return physical
registers. In these cases we can now be more explicit that this is a
non-allocatable register.

In addition, this PR reverts bytecodealliance#4973 and bytecodealliance#5121 because they became
unecessary due, again, to bytecodealliance#5132.
github-merge-queue bot pushed a commit that referenced this pull request Apr 23, 2024
When OperandCollector's reg_use/reg_late_use/reg_def/reg_early_def
methods are handed a Reg that refers to a physical ("real") register,
they all delegate to reg_fixed_nonallocatable, ignoring the constraint
kinds and positions. This behavior was introduced in #5132.

In several cases, the s390x backend was calling those methods with the
result of the `gpr` or `writable_gpr` functions, which return physical
registers. In these cases we can now be more explicit that this is a
non-allocatable register.

In addition, this PR reverts #4973 and #5121 because they became
unecessary due, again, to #5132.
jameysharp added a commit to jameysharp/wasmtime that referenced this pull request May 13, 2024
Consumption of non-allocatable operands was added in bytecodealliance#5253 and bytecodealliance#5132,
and removed in bytecodealliance#8524 and following PRs. Now they are not only ignored by
regalloc2, but the placeholders that it leaves in the allocation results
are also ignored by Cranelift. So let's stop adding them to the operands
list entirely.
github-merge-queue bot pushed a commit that referenced this pull request May 14, 2024
Consumption of non-allocatable operands was added in #5253 and #5132,
and removed in #8524 and following PRs. Now they are not only ignored by
regalloc2, but the placeholders that it leaves in the allocation results
are also ignored by Cranelift. So let's stop adding them to the operands
list entirely.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:aarch64 Issues related to AArch64 backend. 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 isle Related to the ISLE domain-specific language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants