Optimization
SSA (Static Single Assignment)
In many optimizations we need to disambiguate between names. The SSA form is a way to express IR so it becomes easy to optimize. In SSA every variable is assigned only once. Static refers to the textual representation of the IR.
|
|
In places where control flow joins, "phony" phi
functions are inserted.
|
|
Both Swift IR (SIL) and LLVM IR use SSA.
Building SSA
Key concept for building SSA is dominance frontier.
- GopherCon 2017: Keith Randall - Generating Better Machine Code with SSA - YouTube
- Before version 1.5 the Go compiler relied only on AST, and fully moved to the SSA form in 1.7.
- All SSA rewrite rules expressed as DSL
.rules
file used by the rewrite engine.