Reputation: 665
I am implementing an LLVM pass for anticipated expressions using dataflow analysis and code hoisting. The reference I am following is the Purple Dragon Book (Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi, and Ullman)[Section 9.5, pg.645]. The dataflow equations are as follows:
Category | Definition |
---|---|
Domain | Sets of expressions |
Direction | Backwards |
Transfer Function | f_B(x) = e_use_B ∪ (x - e_kill_B) |
Boundary Condition | IN[EXIT] = ∅ |
Meet (∧) | Intersection ( ∩ ) |
Equations | IN[B] = f_B(OUT[B]) OUT[B] = ∩ { IN[S] | S ∈ succ(B) } |
Initialization | IN[B] = U |
According to the book, the initialization condition is IN[BB] = ∅
for all blocks BB
except the exit block.
However, since I am implementing this pass on LLVM IR (SSA form), I have an intuition that setting IN[BB] = ∅
globally (for all blocks) shall work because in SSA, expressions naturally flow upwards due to the dominance property. This means that anticipated expressions should still propagate correctly, and the meet operation (intersection) will naturally refine the IN[B]
sets.
Would setting IN[B] = ∅
globally (for all blocks) still yield a correct solution for anticipated expressions in SSA form? Or does the original book’s condition hold significance even in SSA?
Looking for insights into whether this modification preserves correctness in SSA-based dataflow analysis. Any explanations or counterexamples would be appreciated.
Upvotes: 0
Views: 36