This class provides a generic facility to implement iterative Data Flow Analysis (DFA) as presented in "Aho, Sethi, Ullman, Compilers:
Principles, Techniques, and Tools, Addison Wesley 1986".
More...
template<class Problem, class Set, class Iter = Predecessor>
class otawa::dfa::IterativeDFA< Problem, Set, Iter >
This class provides a generic facility to implement iterative Data Flow Analysis (DFA) as presented in "Aho, Sethi, Ullman, Compilers:
Principles, Techniques, and Tools, Addison Wesley 1986".
An iterative DFA perform a static analysis that computes for each BB of a CFG two value sets (the set may be whatever value handled in the analyzed program):
- IN set before the BB execution (union of previous BB sets),
- OUT set after the BB execution (IN after update of the BB).
To compute IN and OUT, the recursive formulae below are used:
IN(BB) = U(BBi) / BBi is predecessor of BB
OUT(BB) = IN(BB) - KILL(BB) U GEN(BB)
Where KILL(BB) represents the items removed by the execution of BB and GEN(BB) the added items. Finally, we need default set value to initialize the OUT of the BB and to perform a fixpoint computation on the whole CFG.
The final algorithm is described below:
foreach BB do OUT(BB) <- INIT(BB)
change <- true
change <- false
foreach BB do
IN(BB) = U(BBi) / BBi is predecessor of BB
OUT(BB) = IN(BB) - KILL(BB) U GEN(BB)
if OUT(BB) <> old_out then change <- true
done
done
Notice that thanks to Iter type paremeter, we may have forward or backward traversal of the CFG (IN may be union of predecessors or of successors).
An efficient way to implement the handled set is provided by the otawa::dfa::BitSet class.
- Parameters
-
Problem | DFA problem to solve. It must implements the concept otawa::concept::IterativeDFAProblem. |
Set | Type of set used to implements the problem (depends on the problem). |
Iter | Kind of iterator to get predecessor sets of the current computation (default to Predecessor for forward traversal, possibly Successor for backward traversal). |