Download Paper - STS

Transcript
3.5 Correctness
3.5 Correctness
In this section, we have a look at the correctness of our bidirectional predicate propagation. Our propagation consists of two must analyses. To start, we have a look at
examples showing what it means for a predicate to be in the flow data having a must
analysis. Afterwards, we discuss for both the backward and the forward analysis under
which circumstances a predicate is allowed to be in the flow data. Lastly, we still have
to check that we use the result of the analyses correctly.
3.5.1 Must Analysis
Having a CFG without any branches, the result would be the same independent of having
a must or a may analysis. Therefore, we have a look at a few CFGs with branches in
the following to see why our analyses need to be must analyses.
{}
{}
h = 1/x 1
h = 1/x 1
{x 6= 0}
{x 6= 0}
{x 6= 0}
x 6= 0 2
x 6= 0 2
{x 6= 0}
{x 6= 0}
h=13
h=14
{x 6= 0}
{x 6= 0}
{x 6= 0}
5
{x 6= 0}
{x 6= 0}
{x 6= 0}
x=13
h=14
{}
{x 6= 0}
5
{}
Figure 3.19: Example of Must Analysis Figure 3.20: Example of Must Analysis
without Reassignment
with Reassignment
Figure 3.19 has one warning before the branching in the CFG. In neither of the
branches, we reassign the variable of the warning. The predicate remains in both
branches until we reach the combination. For a must analysis, a property has to hold
on every path before the combination to still hold after the combination. Therefore, the
predicate x 6= 0 still is in the flow data after we combine the branches. That means
that we definitely had a warning that asserted x 6= 0 on every path reaching this point,
without x being reassigned in between. Thus, the predicate still has to hold.
Figure 3.20 shows a CFG very similar to the one in Figure 3.19. The only difference is
that we reassign x in one of the branches. Thereby, when we reach the point of combining
the branches again, the predicate x 6= 0 is not in the flow data of both branches anymore.
In one branch, we have empty flow data. In the other, we have the flow data with the
predicate x 6= 0 in it. Combining these flow data with a must analysis results in taking
41