Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / doc / guide / localhost / DeadCode
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta name="generator" content="AsciiDoc 8.6.9">
6 <title>DeadCode</title>
7 <link rel="stylesheet" href="./asciidoc.css" type="text/css">
8 <link rel="stylesheet" href="./pygments.css" type="text/css">
9
10
11 <script type="text/javascript" src="./asciidoc.js"></script>
12 <script type="text/javascript">
13 /*<![CDATA[*/
14 asciidoc.install();
15 /*]]>*/
16 </script>
17 <link rel="stylesheet" href="./mlton.css" type="text/css">
18 </head>
19 <body class="article">
20 <div id="banner">
21 <div id="banner-home">
22 <a href="./Home">MLton 20180207</a>
23 </div>
24 </div>
25 <div id="header">
26 <h1>DeadCode</h1>
27 </div>
28 <div id="content">
29 <div id="preamble">
30 <div class="sectionbody">
31 <div class="paragraph"><p><a href="DeadCode">DeadCode</a> is an optimization pass for the <a href="CoreML">CoreML</a>
32 <a href="IntermediateLanguage">IntermediateLanguage</a>, invoked from <a href="CoreMLSimplify">CoreMLSimplify</a>.</p></div>
33 </div>
34 </div>
35 <div class="sect1">
36 <h2 id="_description">Description</h2>
37 <div class="sectionbody">
38 <div class="paragraph"><p>This pass eliminates declarations from the
39 <a href="BasisLibrary">Basis Library</a> not needed by the user program.</p></div>
40 </div>
41 </div>
42 <div class="sect1">
43 <h2 id="_implementation">Implementation</h2>
44 <div class="sectionbody">
45 <div class="ulist"><ul>
46 <li>
47 <p>
48 <a href="https://github.com/MLton/mlton/blob/master/mlton/core-ml/dead-code.sig"><span class="monospaced">dead-code.sig</span></a>
49 </p>
50 </li>
51 <li>
52 <p>
53 <a href="https://github.com/MLton/mlton/blob/master/mlton/core-ml/dead-code.fun"><span class="monospaced">dead-code.fun</span></a>
54 </p>
55 </li>
56 </ul></div>
57 </div>
58 </div>
59 <div class="sect1">
60 <h2 id="_details_and_notes">Details and Notes</h2>
61 <div class="sectionbody">
62 <div class="paragraph"><p>In order to compile small programs rapidly, a pass of dead code
63 elimination is run in order to eliminate as much of the Basis Library
64 as possible. The dead code elimination algorithm used is not safe in
65 general, and only works because the Basis Library implementation has
66 special properties:</p></div>
67 <div class="ulist"><ul>
68 <li>
69 <p>
70 it terminates
71 </p>
72 </li>
73 <li>
74 <p>
75 it performs no I/O
76 </p>
77 </li>
78 </ul></div>
79 <div class="paragraph"><p>The dead code elimination includes the minimal set of
80 declarations from the Basis Library so that there are no free
81 variables in the user program (or remaining Basis Library
82 implementation). It has a special hack to include all
83 bindings of the form:</p></div>
84 <div class="listingblock">
85 <div class="content"><div class="highlight"><pre><span class="w"> </span><span class="k">val</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="p">...</span><span class="w"></span>
86 </pre></div></div></div>
87 <div class="paragraph"><p>There is an <a href="MLBasisAnnotations">ML Basis annotation</a>,
88 <span class="monospaced">deadCode true</span>, that governs which code is subject to this unsafe
89 dead-code elimination.</p></div>
90 </div>
91 </div>
92 </div>
93 <div id="footnotes"><hr></div>
94 <div id="footer">
95 <div id="footer-text">
96 </div>
97 <div id="footer-badges">
98 </div>
99 </div>
100 </body>
101 </html>