Algorithm 3.3 Reaching-Definitions

Input: CFG (killBkill_B and genBgen_B computed for each basic block BB)

Output: IN[B]IN[B] and OUT[B]OUT[B] for each basic block BB

1:OUT[ENTRY]=OUT[ENTRY] = \empty

2:for each basic block BV(CFG){ENTRY}B\in V(CFG) - \{ENTRY\} do

3:OUT[B]=OUT[B] = \empty

4:end for

5:repeat

6:for each basic block BV(CFG){ENTRY}B\in V(CFG) - \{ENTRY\} do

7:IN[B]=Ppre(B)OUT[P]IN[B] = \bigcup\limits_{P\in pre(B)} OUT[P]

8:OUT[B]=genB(IN[B]killB)OUT[B] = gen_B\cup (IN[B] - kill_B)

9:end for

10:until no changes to any OUT[B]OUT[B] of basic block BV(CFG){ENTRY}B\in V(CFG) - \{ENTRY\} occur