4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta name="generator" content="AsciiDoc 8.6.9">
7 <link rel="stylesheet" href="./asciidoc.css" type="text/css">
8 <link rel="stylesheet" href="./pygments.css" type="text/css">
11 <script type="text/javascript" src="./asciidoc.js"></script>
12 <script type="text/javascript">
17 <link rel="stylesheet" href="./mlton.css" type="text/css">
19 <body class="article">
21 <div id="banner-home">
22 <a href="./Home">MLton 20180207</a>
30 <div class="sectionbody">
31 <div class="paragraph"><p><a href="Useless">Useless</a> is an optimization pass for the <a href="SSA">SSA</a>
32 <a href="IntermediateLanguage">IntermediateLanguage</a>, invoked from <a href="SSASimplify">SSASimplify</a>.</p></div>
36 <h2 id="_description">Description</h2>
37 <div class="sectionbody">
38 <div class="paragraph"><p>This pass:</p></div>
39 <div class="ulist"><ul>
42 removes components of tuples that are constants (use unification)
47 removes function arguments that are constants
52 builds some kind of dependence graph where
54 <div class="ulist"><ul>
57 a value of ground type is useful if it is an arg to a primitive
62 a tuple is useful if it contains a useful component
67 a constructor is useful if it contains a useful component or is used in a <span class="monospaced">Case</span> transfer
73 <div class="paragraph"><p>If a useful tuple is coerced to another useful tuple, then all of
74 their components must agree (exactly). It is trivial to convert a
75 useful value to a useless one.</p></div>
79 <h2 id="_implementation">Implementation</h2>
80 <div class="sectionbody">
81 <div class="ulist"><ul>
84 <a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/useless.fun"><span class="monospaced">useless.fun</span></a>
91 <h2 id="_details_and_notes">Details and Notes</h2>
92 <div class="sectionbody">
93 <div class="paragraph"><p>It is also trivial to convert a useful tuple to one of its useful
94 components — but this seems hard.</p></div>
95 <div class="paragraph"><p>Suppose that you have a <span class="monospaced">ref</span>/<span class="monospaced">array</span>/<span class="monospaced">vector</span> that is useful, but the
96 components aren’t — then the components are converted to type <span class="monospaced">unit</span>,
97 and any primitive args must be as well.</p></div>
98 <div class="paragraph"><p>Unify all handler arguments so that <span class="monospaced">raise</span>/<span class="monospaced">handle</span> has a consistent
99 calling convention.</p></div>
103 <div id="footnotes"><hr></div>
105 <div id="footer-text">
107 <div id="footer-badges">