There are two dataflow analyses to warn uninitialized values and find live variabels. These two examples are very good tutorials for dataflow analysis.<div><br></div><div>--</div><div>Guoping<br><div><br><div class="gmail_quote">
2011/10/20 Maarten Wiggers <span dir="ltr"><<a href="mailto:mwiggers@us.fujitsu.com">mwiggers@us.fujitsu.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word"><div><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Hi Ted,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Yes, I am using the DataflowSolver class. Thanks for the heads-up on potential removal of this class. I was under the impression that this was the default Flow Analysis engine, but will look at the current implementation of the analyses to understand alternative options.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Thanks,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Maarten<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:10.0pt">From:</span></b><span style="font-size:10.0pt"> Ted Kremenek [mailto:<a href="mailto:kremenek@apple.com" target="_blank">kremenek@apple.com</a>] <br>
<b>Sent:</b> Wednesday, October 19, 2011 10:05 PM<br><b>To:</b> Maarten Wiggers<br><b>Cc:</b> '<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>'<br><b>Subject:</b> Re: [cfe-dev] trivial conditions and dataflow solver<u></u><u></u></span></p>
</div></div><div><div></div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Hi Maarten,<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Can you be a bit more specific on what you are doing? Are you using the actual DataflowSolver class? If so, currently ALL blocks are currently enqueued by the solver, not just the roots. IRRC, this was to address an issue that previously existed with the solver and one of the analyses, but now no analyses use the solver anymore this behavior certainly can be changed.<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">FWIW, I was considering removing this class completely, since it is no longer used.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p>
</div><div><p class="MsoNormal">Ted<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p><div><div><div><p class="MsoNormal">On Oct 19, 2011, at 6:40 PM, Maarten Wiggers wrote:<u></u><u></u></p></div><p class="MsoNormal">
<br><br><u></u><u></u></p><div><div><p class="MsoNormal"><span style="font-size:11.0pt">Hi,<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt"> <u></u><u></u></span></p></div><div><p class="MsoNormal">
<span style="font-size:11.0pt">I am experimenting with the dataflow solver and am wondering whether the following is expected behavior.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt"> <u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size:11.0pt">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.<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size:11.0pt"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">Is this the intended behavior? I would expect that blocks without predecessors and that are not entry blocks would be skipped?<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size:11.0pt"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">Thanks,<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">Maarten<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size:11.0pt"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">Example function:<u></u><u></u></span></p></div><div><p class="MsoNormal">
<span style="font-size:11.0pt"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">void func1()<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">{<u></u><u></u></span></p>
</div><div><p class="MsoNormal" style="text-indent:.5in"><span style="font-size:11.0pt">field3 = 5<u></u><u></u></span></p></div><div><p class="MsoNormal" style="text-indent:.5in"><span style="font-size:11.0pt">if(1)<u></u><u></u></span></p>
</div><div style="margin-left:.5in"><p class="MsoNormal" style="text-indent:.5in"><span style="font-size:11.0pt">field2 = 2;<u></u><u></u></span></p></div><div style="margin-left:.5in"><p class="MsoNormal"><span style="font-size:11.0pt">else<u></u><u></u></span></p>
</div><div style="margin-left:.5in"><p class="MsoNormal" style="text-indent:.5in"><span style="font-size:11.0pt">field1 = 2;<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">}<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size:11.0pt"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">A dump of the CFG gives:<u></u><u></u></span></p></div><div><p class="MsoNormal">
<span style="font-size:11.0pt"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">[B4 (Entry) ]<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">Predecessors (0):<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size:11.0pt">Successors (1): B3<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt"> <u></u><u></u></span></p></div><div><p class="MsoNormal">
<span style="font-size:11.0pt">[B1]<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">1: this->field1 = 2<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">Predecessors (0);<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size:11.0pt">Successors (1): B0<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt"> <u></u><u></u></span></p></div><div><p class="MsoNormal">
<span style="font-size:11.0pt">[B2]<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">1: this->field2 = 2<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">Predecessors(1):B3<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size:11.0pt">Successors(1):B0<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt"> <u></u><u></u></span></p></div><div><p class="MsoNormal">
<span style="font-size:11.0pt">[B3]<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">1: this->field3 = 5<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">2: 1<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size:11.0pt">T: if [B3.2]<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">Predecessors (1): B4<u></u><u></u></span></p></div><div><p class="MsoNormal">
<span style="font-size:11.0pt">Successors(2): B2 Null<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">[B0 (Exit) ]<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size:11.0pt">Predecessors(2):B1 B2<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:11.0pt">Successors(0):<u></u><u></u></span></p></div><p class="MsoNormal">
<span style="font-size:13.5pt">_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><u></u><u></u></span></p>
</div></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div></div><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>