| 1 |
= Zone |
| 2 |
|
| 3 |
<<Zone#>> is an optimization pass for the <<SSA2#>> |
| 4 |
<<IntermediateLanguage#>>, invoked from <<SSA2Simplify#>>. |
| 5 |
|
| 6 |
== Description |
| 7 |
|
| 8 |
This pass breaks large <<SSA2#>> functions into zones, which are |
| 9 |
connected subgraphs of the dominator tree. For each zone, at the node |
| 10 |
that dominates the zone (the "zone root"), it places a tuple |
| 11 |
collecting all of the live variables at that node. It replaces any |
| 12 |
variables used in that zone with offsets from the tuple. The goal is |
| 13 |
to decrease the liveness information in large <<SSA#>> functions. |
| 14 |
|
| 15 |
== Implementation |
| 16 |
|
| 17 |
* https://github.com/MLton/mlton/blob/master/mlton/ssa/zone.fun[`zone.fun`] |
| 18 |
|
| 19 |
== Details and Notes |
| 20 |
|
| 21 |
Compute strongly-connected components to avoid put tuple constructions |
| 22 |
in loops. |
| 23 |
|
| 24 |
There are two (expert) flags that govern the use of this pass |
| 25 |
|
| 26 |
* `-max-function-size <n>` |
| 27 |
* `-zone-cut-depth <n>` |
| 28 |
|
| 29 |
Zone splitting only works when the number of basic blocks in a |
| 30 |
function is greater than `n`. The `n` used to cut the dominator tree |
| 31 |
is set by `-zone-cut-depth`. |
| 32 |
|
| 33 |
There is currently no attempt to be safe-for-space. That is, the |
| 34 |
tuples are not restricted to containing only "small" values. |
| 35 |
|
| 36 |
In the `HOL` program, the particular problem is the main function, |
| 37 |
which has 161,783 blocks and 257,519 variables -- the product of those |
| 38 |
two numbers being about 41 billion. Now, we're not likely going to |
| 39 |
need that much space since we use a sparse representation. But even |
| 40 |
1/100th would really hurt. And of course this rules out bit vectors. |