Debian Codegraph @

doc/guide/src/DeadCode.adoc

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