<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.10">
<title>Zone</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">


<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css">
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20201002</a>
</div>
</div>
<div id="header">
<h1>Zone</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p><a href="Zone">Zone</a> is an optimization pass for the <a href="SSA2">SSA2</a>
<a href="IntermediateLanguage">IntermediateLanguage</a>, invoked from <a href="SSA2Simplify">SSA2Simplify</a>.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_description">Description</h2>
<div class="sectionbody">
<div class="paragraph"><p>This pass breaks large <a href="SSA2">SSA2</a> functions into zones, which are
connected subgraphs of the dominator tree.  For each zone, at the node
that dominates the zone (the "zone root"), it places a tuple
collecting all of the live variables at that node.  It replaces any
variables used in that zone with offsets from the tuple.  The goal is
to decrease the liveness information in large <a href="SSA">SSA</a> functions.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_implementation">Implementation</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/zone.fun"><span class="monospaced">zone.fun</span></a>
</p>
</li>
</ul></div>
</div>
</div>
<div class="sect1">
<h2 id="_details_and_notes">Details and Notes</h2>
<div class="sectionbody">
<div class="paragraph"><p>Compute strongly-connected components to avoid put tuple constructions
in loops.</p></div>
<div class="paragraph"><p>There are two (expert) flags that govern the use of this pass</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">-max-function-size &lt;n&gt;</span>
</p>
</li>
<li>
<p>
<span class="monospaced">-zone-cut-depth &lt;n&gt;</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>Zone splitting only works when the number of basic blocks in a
function is greater than <span class="monospaced">n</span>.  The <span class="monospaced">n</span> used to cut the dominator tree
is set by <span class="monospaced">-zone-cut-depth</span>.</p></div>
<div class="paragraph"><p>There is currently no attempt to be safe-for-space.  That is, the
tuples are not restricted to containing only "small" values.</p></div>
<div class="paragraph"><p>In the <span class="monospaced">HOL</span> program, the particular problem is the main function,
which has 161,783 blocks and 257,519 variables&#8201;&#8212;&#8201;the product of those
two numbers being about 41 billion.  Now, we&#8217;re not likely going to
need that much space since we use a sparse representation.  But even
1/100th would really hurt.  And of course this rules out bit vectors.</p></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>
