Abhishek Ghosh
Abhishek Ghosh

Reputation: 665

`IN[BB] = ∅` for all BB instead of `IN[BB] = U , for all other BB != BB_EXIT` in Init of Anticipated Expression Dataflow analysis in SSA form

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:

Anticipated Expressions Dataflow Equations

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

Question

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.


Discussion Point

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

Answers (0)

Related Questions