[cfe-dev] trivial conditions and dataflow solver

Maarten Wiggers mwiggers at us.fujitsu.com
Wed Oct 19 18:40:48 PDT 2011


I am experimenting with the dataflow solver and am wondering whether the following is expected behavior.

I took a function with a trivially true if condition. When constructing the CFG, clang seems to take this into account and does not generate a successor/predecessor relationship between blocks B1 and B3 (see below). However, when running the dataflow solver, I get that {field3, field2} and {field1} are possible sets of accesses to fields, while I would expect that either {field3,field1} or nothing is reported instead of {field1}. Currently, it seems block B1 is visited and its results are propagated, but it does not receive input values from B3.

Is this the intended behavior? I would expect that blocks without predecessors and that are not entry blocks would be skipped?


Example function:

void func1()
field3 = 5
field2 = 2;
field1 = 2;

A dump of the CFG gives:

[B4 (Entry) ]
Predecessors (0):
Successors (1): B3

1: this->field1 = 2
Predecessors (0);
Successors (1): B0

1: this->field2 = 2

1: this->field3 = 5
2: 1
T: if [B3.2]
Predecessors (1): B4
Successors(2): B2 Null

[B0 (Exit) ]
Predecessors(2):B1 B2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111019/81472584/attachment.html>

More information about the cfe-dev mailing list