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