<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 1, 2017 at 5:39 PM, Matt Arsenault via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I'm trying to solve a problem from StructurizeCFG not actually handling regions with multiple exits. </blockquote><div><br></div><div>SEME or MEME or both?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Sample IR attached.<br></blockquote><div><br></div><div>This is an example that just exhibits undefined behavior.<br>Is there one that doesn't?</div><div>IE if i change the unreachables to ret something, is that still an example of something you care about? </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
StructurizeCFG doesn't touch this function, exiting early on the isTopLevelRegion check.</blockquote><div><br>FWIW: I'm not sure it should care whether it's a top level region, only whether it's SESE, SEME, etc.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> SIAnnotateControlFlow then gets confused and ends up inserting an if into one of the blocks, and the matching <a href="http://end.cf" rel="noreferrer" target="_blank">end.cf</a> into one of the return/unreachable blocks. The input to the <a href="http://end.cf" rel="noreferrer" target="_blank">end.cf</a> is then not dominated by the condition which fails the verifier.<br>
<br>
I'm not sure exactly about how to go about fixing this. I see a few options:<br>
<br>
- Try to make the annotator aware of multi exit regions and insert the necessary phis for the input mask values for the <a href="http://end.cf" rel="noreferrer" target="_blank">end.cf</a> calls. This seems undesirable and I'm not sure works in all cases.<br></blockquote><div><br></div><div>It's possible to always find a unique entering/exiting condition for any of the multiple-entrance/exit, and to transform it into a bunch of SESE regions.</div><div>see, e.g, <a href="https://net.cs.uni-bonn.de/fileadmin/ag/martini/Staff/yakdan/dream_ndss2015.pdf">https://net.cs.uni-bonn.de/fileadmin/ag/martini/Staff/yakdan/dream_ndss2015.pdf</a></div><div><br></div><div>  <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
- Make StructurizeCFG duplicate blocks to get simple regions. Is there already code to do this somewhere? CodeExtractor seems to do something similar, but not quite the same. Can this be done in the region pass, or does StructurizeCFG need to be converted to a function pass? RegionInfo mentions support for "extended" regions with multiple exits, but I don't think this helps any here.</blockquote><div><br></div><div>This also would work.</div><div> </div><div> <br></div></div></div></div>