Optimising Compilers Past Paper
Control-flow
Unreachable code elimination
Reachability, control-flow property: will the control reach here?
Call graph
Data-flow analysis framework
Data-flow equations: relationship between values of that property immediately before in() and after out() each node n in a flow graph.
- y2017p9q10 (a)
- General framework, propagating information either forwards (AVAIL) or backwards (LVA) through the flowgraph.
- Operator: either the intersection ∩ (AVAIL) or union ∪ (LVA) is used, so as to under/over-approximate the property.
Let Position posi or posj be in(n) / out(n), the set of values setA(n) / setB(n) involved with the property immediately before / after the instruction. Depending on the property, one of the first or third equation with operator Op=⋃∣∣⋂ is used in the data-flow equations.
Nodes p
| pos = in(n)
Node n : setA(n) <=> setB(n) ...
| pos = out(n)
Nodes s
posi(n)=posj(n)=posi(n)={}∣∣Opp∈pred(n)posj(p)(posi(n)∖setI(n))∪setJ(n), depends on the propertyOps∈succ(n)posj(s)
Live variable analysis (LVA)
Liveness, data-flow property: will the value be used later?
...
↑ in(n)
Node n : def(n) => ref(n) ...
↑ out(n)
Nodes s
in−live(n)=(out−live(n)∖def(n))∪ref(n)out−live(n)=s∈succ(n)⋃in−live(s)
Data-flow anomalies
Clash / interference graph
Available expression analysis (AVAIL)
Availability, data-flow property: will the value be assigned before?
Nodes p
↓ in(n)
Node n : gen(n) <= kill(n) ...
↓ out(n)
...
in−avail(n)={}∣∣p∈pred(n)⋂out−avail(p)out−avail(n)=(in−avail(n)∖kill(n))∪gen(n)
Redundancy elimination
Common sub-expression elimination
Copy propagation
Code motion optimisation
Register allocation
Static single assignment (SSA) and Strength reduction
Higher-level opt
Abstract interpretation
Strictness analysis
Constraint-based analysis (0CFA)
Inference-based analysis
Effect system
Alias and points-to analysis
Instruction scheduling
target code level for different architectures
Register allocation vs instruction scheduling
Decompilation
General opt
Phase ordering
General optimisations