Debian Codegraph @

doc/guide/src/CommonBlock.adoc

raw
1 = CommonBlock
2
3 <<CommonBlock#>> is an optimization pass for the <<SSA#>>
4 <<IntermediateLanguage#>>, invoked from <<SSASimplify#>>.
5
6 == Description
7
8 It eliminates equivalent blocks in a <<SSA#>> function. The
9 equivalence criteria requires blocks to have no arguments or
10 statements and transfer via `Raise`, `Return`, or `Goto` of a single
11 global variable.
12
13 == Implementation
14
15 * https://github.com/MLton/mlton/blob/master/mlton/ssa/common-block.fun[`common-block.fun`]
16
17 == Details and Notes
18
19 * Rewrites
20 +
21 ----
22 L_X ()
23 raise (global_Y)
24 ----
25 +
26 to
27 +
28 ----
29 L_X ()
30 L_Y' ()
31 ----
32 +
33 and adds
34 +
35 ----
36 L_Y' ()
37 raise (global_Y)
38 ----
39 +
40 to the <<SSA#>> function.
41
42 * Rewrites
43 +
44 ----
45 L_X ()
46 return (global_Y)
47 ----
48 +
49 to
50 +
51 ----
52 L_X ()
53 L_Y' ()
54 ----
55 +
56 and adds
57 +
58 ----
59 L_Y' ()
60 return (global_Y)
61 ----
62 +
63 to the <<SSA#>> function.
64
65 * Rewrites
66 +
67 ----
68 L_X ()
69 L_Z (global_Y)
70 ----
71 +
72 to
73 +
74 ----
75 L_X ()
76 L_Y' ()
77 ----
78 +
79 and adds
80 +
81 ----
82 L_Y' ()
83 L_Z (global_Y)
84 ----
85 +
86 to the <<SSA#>> function.
87
88 The <<Shrink#>> pass rewrites all uses of `L_X` to `L_Y'` and drops `L_X`.
89
90 For example, all uncaught `Overflow` exceptions in a <<SSA#>> function
91 share the same raising block.