The backward test identifies statements containing definitions of variable that reach a program point. We can use the control flow graph given in Figure 2(a) to give an example for backward test. Suppose the goal is top compute the set of statements containing of definitions of X can reach statement 7. The backward test begins at this point immediately before statement 7 in the control graph. It go back over edges (5,7) and (4,5) and locates statement 4, which contains a definition of X. Since no other definition of X can reach statement 7 along a path through statement 4, the search for definitions of X stops at statement 4. Since there are two backward paths from statement 5, the backward test also goes back over edge (6,5) and finds statement 6 that contains a definition of X. The backward test algorithm locates the statements containing definitions of a variable X that reach a point in the program, without computing data flow analysis for entire program.
Figure 2: Backward and forward test examples
The forward test identifies uses of a variable that are directly or
indirectly affected by either a change in a value of a variable at a
point in the program or a change in a predicate.
The def-use associations returns
triple the information
about variable v at statement s, affected by the change, is used
by statement u.
A def-use association is directly affected if the triple represents a
use of an altered definitions.
A def-use association is indirectly affected in one of two ways:
(1) the triple is in the transitive closure of the changed definition
or (2) the triple is control dependent on a changed or affected
predicate. In figure 2(b), if a forward test begins at statement 2 for
variable Y, the use of Y in statement 4 is found. Thus directly
affected def-use association from 2 to 4 is computed.
Additionally, since def-use association from 4 to 10 for variable J is
in the transitive closure of the definition of Y in statement 2, this
def-use association is indirectly affected.
If forward test begins at statement 1, the uses of X in statement
3,6,9 are located directly, so def-use associations from 1 to 2,6,9
are found.