diff options
| author | 2025-12-15 19:49:36 +0100 | |
|---|---|---|
| committer | 2025-12-15 21:43:17 +0100 | |
| commit | bf0f2805b5aec7f4fa5fb4ff1a4da081a0112e4e (patch) | |
| tree | afbfd38cb55bbfea8bb9b13821fa07c73256de67 /todo.txt | |
| parent | adea4038e6aa8603aa14283375b31366501ed7ee (diff) | |
regalloc: fix lifetime construction for nested loops
Previously, given something like
```
1 a = ...
2 loop { // outer
3 b = do something with a
4 loop { // inner
5 ...
6 if (b < 0)
7 break 'inner;
8 if (b == 0)
9 return;
10 ...
11 }
12 }
```
Regalloc thought outer goes from 2..6, because 6 is the last place where
flow jumps directly back to 2. So `a` would have the lifetime [1,7).
However if neither the break nor return are taken, the inner loop
repeats and then control could flow back to 7 -> 3. But now the physical
location for `a` might have been clobbered between 8..10, which is
wrong. This fixes that by making sure the outer loop is considered to
span 2..10.
The way I went about it might not be the best way of doing it. I'm not
100% certain that it's fully correct and will always find the correct
loopend, either. It's surprising it took this long to hit this edge
case.
Diffstat (limited to 'todo.txt')
0 files changed, 0 insertions, 0 deletions