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

Spill for VReg lifetimes instead of SpillSet lifetimes #171

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

elliottt
Copy link
Member

@elliottt elliottt commented Dec 6, 2023

This PR removes the redundant move eliminator by changing where we store spill allocations: switching from allocating spills to bundles to instead spilling vregs for their full lifetime. Changes to the cranelift test suite are for the most part positive, though there are some cases where the number of stack slots grows as a result of the new spilling strategy. I think that this could probably be mitigated by revisiting how we compute spill weight, but would also like to see what the change to more substantial targets like spidermonkey are before committing to that.

The change consists of three parts:

  1. Moving the spill allocation granularity to VRegs instead of spill bundles
  2. Using the new authoritative spill location to avoid writing to spill slots unnecessarily (writing when processing a def or block param instead)
  3. And finally, removing the redundant move eliminator now that we don't generate unnecessary moves back into spill slots

I've fuzzed this for about 24 hours without discovering any new test failures, but I think it's a pretty substantial change that warrants more discussion once @cfallin is back.

elliottt and others added 4 commits November 30, 2023 16:55
Instead of processing all liveranges for each vreg, instead use the
aggregate lifetime for the vreg when constructing the stack map. As
spill slots are allocated to vregs now instead of spillsets, determining
which vreg allocations cross safepoints is now much simpler.

co-authored-by: Jamey Sharp <jsharp@fastly.com>
@elliottt elliottt changed the title Spill for VReg lifetimes instead of spillset lifetimes Spill for VReg lifetimes instead of SpillSet lifetimes Dec 6, 2023
@Amanieu
Copy link
Contributor

Amanieu commented Dec 6, 2023

Isn't the redundant move eliminator still useful when dealing with fixed-reg constraints? Since regalloc2 fundamentally can only model a vreg in a single location at a time, multiple fixed constaints can often introduce unnecessary back-and-forth copying which can be eliminated by the redundant move eliminator.

@elliottt
Copy link
Member Author

elliottt commented Dec 6, 2023

We do support overlapping liveranges now, so perhaps we could address this by allowing the value to exist in multiple places at once?

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.

None yet

2 participants