Commit 317dc20
Evict larger limits first using spill weights
Consider an instruction that could potentially overallocate to a limited
range of registers:
```
Use: v0i limit(0..=1), Use: v0i limit(0..=1), Use: v1i limit(0..=7)
```
Both uses of `v0` _must_ fit in registers 0-1 and `v1` should find its
home somewhere else in registers 2-7. But fuzzing found a case where
this failed. If `v1` was allocated first--say to register 0--and one of
the uses of `v0` allocated to the remaining register--register 1--the
final use of `v0` had nowhere to go _and_ could not evict either of the
previous allocations. This caused `ion` to fail with `TooManyLiveRegs`
when in fact a solution was possible.
(Why are the identical uses of `v0` allocated separately? Can't they use
the same register? I'm not entirely sure, but I think `ion` had 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:
- minimal with `fixed` constraint
- minimal with `limit(0..=0)` constraint
- minimal with `limit(0..=1)` constraint
- ...
- minimal with `limit(0..=255)` constraint
- minimal, any other constraint
- non-minimal
Doing this allows `ion` to evict bundles with higher limits (e.g., `v1i
limit(0..=7)` once they become minimal, allowing allocation to continue.
Co-authored-by: Chris Fallin <[email protected]>
Co-authored-by: Rahul Chaphalkar <[email protected]>1 parent 292ad71 commit 317dc20
2 files changed
+7
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
212 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
213 | 214 | | |
214 | 215 | | |
215 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
325 | 326 | | |
326 | 327 | | |
327 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
328 | 332 | | |
329 | 333 | | |
330 | 334 | | |
| |||
0 commit comments