Download Paper - STS
Transcript
3 Data Flow Analyses for Bidirectional Predicate Propagation
3.3.3 Drawbacks
Let us have a look at the if then else example from Subsection 2.2.1.
{x 6= 0}
h = 1/x 1
{x 6= 0}
h = 1/x 1
{x 6= 0}
{x 6= 0}
{x 6= 0}
x 6= 0 2
{y 6= 0, x 6= 0}
{x 6= 0}
x 6= 0 2
{x 6= 0}
h = 1/x 3
h = 1/x 5
{y 6= 0, x 6= 0}
{x 6= 0}
{x 6= 0}
{y 6= 0}
{y 6= 0}
{y 6= 0}
{x 6= 0}
{x 6= 0}
h = 1/x 3
h = 1/x 5
{x 6= 0}
{y 6= 0}
h = 1/y
{}
4
{}
{y 6= 0}
h = 1/y
{}
4
{}
6
6
{}
{}
Figure 3.14: Backwards Analysis Applied Figure 3.15: If Then Else Example from
to the CFG of If Then
Subsection 2.2.1 with Inserted
Else Example from SubsecWarning
tion 2.2.1
Figure 3.15 shows the result of the application of the backwards analysis to the example. The interesting part is that we generate the predicate y 6= 0 in the fourth block.
In the second block, we combine the flow data from the third and fifth block. In the
combination, the predicate y 6= 0 gets removed. Hence, y 6= 0 still has to hold in the
third block but does not have to hold in the second block anymore. Further, in the third
block there is no corresponding warning with the predicate y 6= 0. Due to these facts,
we can insert a corresponding warning with the predicate y 6= 0 to the third block.
Inserting the warning, we unfortunately only propagated the warning one statement
upwards. Even though we could propagate it a bit upwards and thereby closer to the last
assignment of the variable, this propagation is not of big help. However, the propagation
also does not increase the overall number of warnings. Applying the forward analysis, we
would remove the warning corresponding to the fourth statement again, which otherwise
we could not. Thus, we inserted one warning to be able to remove a warning.
The if then else example shows that the backward analysis is not always helpful
but did not really have a drawback since it did not increase the number of warnings.
Figure 3.16 shows the application of the backwards analysis to an example with drawbacks.
38