Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | DeadCode |
2 | ======== | |
3 | ||
4 | <:DeadCode:> is an optimization pass for the <:CoreML:> | |
5 | <:IntermediateLanguage:>, invoked from <:CoreMLSimplify:>. | |
6 | ||
7 | == Description == | |
8 | ||
9 | This pass eliminates declarations from the | |
10 | <:BasisLibrary:Basis Library> not needed by the user program. | |
11 | ||
12 | == Implementation == | |
13 | ||
14 | * <!ViewGitFile(mlton,master,mlton/core-ml/dead-code.sig)> | |
15 | * <!ViewGitFile(mlton,master,mlton/core-ml/dead-code.fun)> | |
16 | ||
17 | == Details and Notes == | |
18 | ||
19 | In order to compile small programs rapidly, a pass of dead code | |
20 | elimination is run in order to eliminate as much of the Basis Library | |
21 | as possible. The dead code elimination algorithm used is not safe in | |
22 | general, and only works because the Basis Library implementation has | |
23 | special properties: | |
24 | ||
25 | * it terminates | |
26 | * it performs no I/O | |
27 | ||
28 | The dead code elimination includes the minimal set of | |
29 | declarations from the Basis Library so that there are no free | |
30 | variables in the user program (or remaining Basis Library | |
31 | implementation). It has a special hack to include all | |
32 | bindings of the form: | |
33 | [source,sml] | |
34 | ---- | |
35 | val _ = ... | |
36 | ---- | |
37 | ||
38 | There is an <:MLBasisAnnotations:ML Basis annotation>, | |
39 | `deadCode true`, that governs which code is subject to this unsafe | |
40 | dead-code elimination. |