SSA/Control flow analysis Flashcards
A dominates B
to reach block B, must have gone through block A
dominance frontier
For a block X, the set of nodes Y s.t. X dominates an immediate predecessor of Y but does not strictly dominate Y
SSA
static single assignment form
Goal of SSA form
build an intermediate representation of the program in which each variable is assigned a value in at most 1 program point
How to convert to SSA form?
make new variables to carry over the effect of the original program
Phi Functions
If have conditions and two different branches that assign different values to the same variable, then must pick one
How to compute Phi function replacement
want to figure out where there are multiple assignments that reach a node; can put a phi func for each assignment at every node in dominance frontier
Pruned Phi Functions
Suppose useless phi function nodes (cases where the result is never used downstream)
meet operation
union of sets (of
Why are reaching definitions useful?
Answers the question, where could this variable have been defined
Forward analysis
Start at the beginning of a function’s CFG, work along the control edges (reaching definitions)
Backward anlysis
Start at the end of a function’s CFG, work against the control edges (live variables)