diff --git a/notes/8.md b/notes/8.md index 4096325..e86d7bb 100644 --- a/notes/8.md +++ b/notes/8.md @@ -64,4 +64,36 @@ Analysis of Reaching Definition Effect of an Instruction -`IN[b]` and `OUT[b]` \ No newline at end of file +`IN[b]` and `OUT[b]` + +Meet Operator + +`IN[b] = union(OUT[p1]...OUT[pn])` + +```c +// init +OUT[entry] = {} + + + +``` + +## Liveness Analysis + +Liveness is the concept the variable is used in the future. It helps **eliminating dead code**. + +Transfer function + +* `USE[b]` set of variables used in `b` +* `DEF[b]` set of variables defined in `b` + +so transfer function `f_b` for a basic block b: +```IN[b] = USE[b] + (OUT[b] - DEF[b])``` + +for reaching defintion + +```OUT[b] = union(INs)``` + +For supporting cyclic graphs, repeated computation is needed. + + diff --git a/notes/9.md b/notes/9.md new file mode 100644 index 0000000..33c5358 --- /dev/null +++ b/notes/9.md @@ -0,0 +1,28 @@ +# Control Flow Analysis + +Dominator + +for a given CFG **a node `x` dominates a node `y`** if every path from the Entry block to `y` contains `x`. + +* Each BB dominates itself +* If `x dom y` and `y dom z` then `x dom z` +* If `x dom z` and `y dom z` then either `x dom y` or `y dom x` + +Dominator Tree +* initial node is a root +* `x dom y` means that "`y` is a child of `x`" + + +Natural Loops + +How to Find Natural Loop?: Introduction Backedge + +Important concepts in a loop +* Header and Loop BB +* Back Edges +* Exit Edges +* Preheader (Preloop) + +Loop-Invariant Computation + + diff --git a/pdf/L9.pdf b/pdf/L9.pdf new file mode 100644 index 0000000..b8a706a Binary files /dev/null and b/pdf/L9.pdf differ