Efficient data flow analysis
Introduction
The following two algorithms are used for data flow analysis:
• Depth first ordering in iterative algorithm
• Structure based data flow analysis
Depth first ordering in iterative algorithm:
• Iterative algorithm can be used to track their acyclic nature
• In this algorithm, depth is defined as the maximum number of
retreating edges in any acyclic path
• Interval depth is defined as the number of times the interval
partition must be applies to reach the limit of the flow graph
Example: perform the depth first traversal of the given tree
5 6
7
Contd.,
• The depth first ordering is the reverse of the order in which we
last visit the nodes in the pre order traversal
• i.e., visit the root node of the tree first
• In case of ambiguity where no root node is present visit the
node in the right hand side
• The order of visiting the edges in the above tree is:
1346764543121
Structure based data flow analysis:
• This algorithm is time saving
• This focuses on the multiple exits in the blocks
• Gen r,b indicates the definitions that were generated in the
region R of the basic block B
• Kill R,B indicates the definition that were killed in the region R
of the basic block B
• Transfer function trans R,B of a set S, is the set of definitions
that travel within the region R.
contd.,
The data flow equation is
trans R,B (S)=Gen R,B U (S-Kill R,B)
The working of the algorithm can be analysed in two cases
Case 1:
If the transformation does not alter any definitions in the basic
block B, then the transfer function of region R, is same as the
transfer function of the block B
Gen B,B = Gen [B]
Kill B.B = Kill[B]
Case 2:
The region R is formed when R1 consumes R2. There are no
edges from R2 to R1. Header of R is the header of R1, R2 does
not affect the transfer function of R1
Contd.,
Gen R,B = Gen R1,B
Kill R,B = Kill R1,B
For B in R2, a definition can reach the end of B if any of the
following conditions hold
• The definition is generated within R2
• The definition is generated within R1, reaches the end of
predecessor of the header of R2 and is not killed going from
the header of R2 to B
• The definition is in the set S available at the header of R1, not
killed going to some predecessor of the header of R2, and not
killed going from the header of R2 to B