Evict larger limits first using spill weights #249
+7
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Consider an instruction that could potentially overallocate to a limited range of registers:
Both uses of
v0must fit in registers 0-1 andv1should find its home somewhere else in registers 2-7. But fuzzing found a case where this failed. Ifv1was allocated first--say to register 0--and one of the uses ofv0allocated to the remaining register--register 1--the final use ofv0had nowhere to go and could not evict either of the previous allocations. This causedionto fail withTooManyLiveRegswhen in fact a solution was possible.(Why are the identical uses of
v0allocated separately? Can't they use the same register? I'm not entirely sure, but I thinkionhad split things down to minimal bundles).The fix in this change is to alter the default spill weights assigned to a minimal bundle. Previously, minimal bundles with a fixed constraint received the highest weight, followed by other minimal bundles and then non-minimal bundles. This reserves weights for limits into that order:
fixedconstraintlimit(0..=0)constraintlimit(0..=1)constraintlimit(0..=255)constraintDoing this allows
ionto evict bundles with higher limits (e.g.,v1i limit(0..=7)once they become minimal, allowing allocation to continue.