Debian Codegraph @

doc/guide/src/Useless.adoc

raw
1 = Useless
2
3 <<Useless#>> is an optimization pass for the <<SSA#>>
4 <<IntermediateLanguage#>>, invoked from <<SSASimplify#>>.
5
6 == Description
7
8 This pass:
9
10 * builds some kind of dependence graph where
11 ** a value of ground type is useful if it is an arg to a primitive
12 ** a tuple is useful if it contains a useful component
13 ** a constructor is useful if it contains a useful component or is used in a `Case` transfer
14
15 If a useful tuple is coerced to another useful tuple, then all of
16 their components must agree (exactly). It is trivial to convert a
17 useful value to a useless one.
18
19 == Implementation
20
21 * https://github.com/MLton/mlton/blob/master/mlton/ssa/useless.fun[`useless.fun`]
22
23 == Details and Notes
24
25 It is also trivial to convert a useful tuple to one of its useful
26 components -- but this seems hard.
27
28 Suppose that you have a `ref`/`array`/`vector` that is useful, but the
29 components aren't -- then the components are converted to type `unit`,
30 and any primitive args must be as well.