<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br><div><div><br></div><div>  // For all predecessors of this MBB, find the set of VarLocs that</div><div>  // can be joined.</div><div>  for (auto p : MBB.predecessors()) {</div><div>    auto OL = OutLocs.find(p);</div><div>    // Join is null in case of empty OutLocs from any of the pred.</div><div>    if (OL == OutLocs.end())</div><div>      return false;</div></div></div><div><br></div><div><br></div><div>This is wrong  if the block is unvisited (as you say)<br></div></div></div></div></blockquote><div><br></div><div>This is actually non-trivial to fix, IMHO.</div><div><br></div><div>For example, the following looks kinda right:<br></div><div>  </div><div>for (auto p : MBB.predecessors()) {</div><div>    if (p is not visited)</div><div>     continue;</div><div>    auto OL = OutLocs.find(p);</div><div>    // Join is null in case of empty OutLocs from any of the pred.</div><div>    if (OL == OutLocs.end())</div><div>      return false;</div></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">(and will work in a lot of cases)</div><div class="gmail_extra"><br></div><div class="gmail_extra">This can be wrong, however, if you have more than a single backedge in the program.</div><div class="gmail_extra">(it may be possible to have a block that has multiple uninited predecessors that will require multiple iterations to resolve)</div><div class="gmail_extra"><br></div><div class="gmail_extra">The problem here is that to get the maximal answer in an intersection problem, you *must* initialize the sets to contain every value.  You can look at dataflow algorithm papers for formal proofs if you want.</div><div class="gmail_extra"><br></div><div class="gmail_extra">So you *actually* have to treat the default state of every unvisited block as the equivalent of "containing every value" to get the maximal answer.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">How to achieve this for real is ... not obvious at a glance.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div>