Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / doc / guide / localhost / Shrink
CommitLineData
7f918cf1
CE
1<!DOCTYPE html>\r
2<html lang="en">\r
3<head>\r
4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
5<meta name="generator" content="AsciiDoc 8.6.9">\r
6<title>Shrink</title>\r
7<link rel="stylesheet" href="./asciidoc.css" type="text/css">\r
8<link rel="stylesheet" href="./pygments.css" type="text/css">\r
9\r
10\r
11<script type="text/javascript" src="./asciidoc.js"></script>\r
12<script type="text/javascript">\r
13/*<![CDATA[*/\r
14asciidoc.install();\r
15/*]]>*/\r
16</script>\r
17<link rel="stylesheet" href="./mlton.css" type="text/css">\r
18</head>\r
19<body class="article">\r
20<div id="banner">\r
21<div id="banner-home">\r
22<a href="./Home">MLton 20180207</a>\r
23</div>\r
24</div>\r
25<div id="header">\r
26<h1>Shrink</h1>\r
27</div>\r
28<div id="content">\r
29<div id="preamble">\r
30<div class="sectionbody">\r
31<div class="paragraph"><p><a href="Shrink">Shrink</a> is a rewrite pass for the <a href="SSA">SSA</a> and <a href="SSA2">SSA2</a>\r
32<a href="IntermediateLanguage">IntermediateLanguage</a>s, invoked from every optimization pass (see\r
33<a href="SSASimplify">SSASimplify</a> and <a href="SSA2Simplify">SSA2Simplify</a>).</p></div>\r
34</div>\r
35</div>\r
36<div class="sect1">\r
37<h2 id="_description">Description</h2>\r
38<div class="sectionbody">\r
39<div class="paragraph"><p>This pass implements a whole family of compile-time reductions, like:</p></div>\r
40<div class="ulist"><ul>\r
41<li>\r
42<p>\r
43<span class="monospaced">#1(a, b)</span> &#8658; <span class="monospaced">a</span>\r
44</p>\r
45</li>\r
46<li>\r
47<p>\r
48<span class="monospaced">case C x of C y =&gt; e</span> &#8658; <span class="monospaced">let y = x in e</span>\r
49</p>\r
50</li>\r
51<li>\r
52<p>\r
53constant folding, copy propagation\r
54</p>\r
55</li>\r
56<li>\r
57<p>\r
58eta blocks\r
59</p>\r
60</li>\r
61<li>\r
62<p>\r
63tuple reconstruction elimination\r
64</p>\r
65</li>\r
66</ul></div>\r
67</div>\r
68</div>\r
69<div class="sect1">\r
70<h2 id="_implementation">Implementation</h2>\r
71<div class="sectionbody">\r
72<div class="ulist"><ul>\r
73<li>\r
74<p>\r
75<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/shrink.sig"><span class="monospaced">shrink.sig</span></a>\r
76</p>\r
77</li>\r
78<li>\r
79<p>\r
80<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/shrink.fun"><span class="monospaced">shrink.fun</span></a>\r
81</p>\r
82</li>\r
83<li>\r
84<p>\r
85<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/shrink2.sig"><span class="monospaced">shrink2.sig</span></a>\r
86</p>\r
87</li>\r
88<li>\r
89<p>\r
90<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/shrink2.fun"><span class="monospaced">shrink2.fun</span></a>\r
91</p>\r
92</li>\r
93</ul></div>\r
94</div>\r
95</div>\r
96<div class="sect1">\r
97<h2 id="_details_and_notes">Details and Notes</h2>\r
98<div class="sectionbody">\r
99<div class="paragraph"><p>The <a href="Shrink">Shrink</a> pass is run after every <a href="SSA">SSA</a> and <a href="SSA2">SSA2</a>\r
100optimization pass.</p></div>\r
101<div class="paragraph"><p>The <a href="Shrink">Shrink</a> implementation also includes functions to eliminate\r
102unreachable blocks from a <a href="SSA">SSA</a> or <a href="SSA2">SSA2</a> program or function.\r
103The <a href="Shrink">Shrink</a> pass does not guarantee to eliminate all unreachable\r
104blocks. Doing so would unduly complicate the implementation, and it\r
105is almost always the case that all unreachable blocks are eliminated.\r
106However, a small number of optimization passes require that the input\r
107have no unreachable blocks (essentially, when the analysis works on\r
108the control flow graph and the rewrite iterates on the vector of\r
109blocks). These passes explicitly call <span class="monospaced">eliminateDeadBlocks</span>.</p></div>\r
110<div class="paragraph"><p>The <a href="Shrink">Shrink</a> pass has a special case to turn a non-tail call where\r
111the continuation and handler only do <span class="monospaced">Profile</span> statements into a tail\r
112call where the <span class="monospaced">Profile</span> statements precede the tail call.</p></div>\r
113</div>\r
114</div>\r
115</div>\r
116<div id="footnotes"><hr></div>\r
117<div id="footer">\r
118<div id="footer-text">\r
119</div>\r
120<div id="footer-badges">\r
121</div>\r
122</div>\r
123</body>\r
124</html>\r