<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 23, 2015 at 10:51 PM, Sanjoy Das <span dir="ltr"><<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Is it fair (and correct) to say that the main issue with unreachable<br>
code is this:  if we allow unreachable code then the dom tree is no<br>
longer a tree, it can have components (disconnected from the root)<br>
that are cycles.  So no pass that wants to just work with unreachable<br>
code can depend on the dom tree actually being a tree.<br>
<br>
Or are there more fundamental issues (I realize the dom tree not being<br>
a tree is rather fundamental itself)?<br></blockquote><div><br></div><div>You can't rely on walking successors to generate correct code (IE you may have to later fix up code that you didn't see).</div><div>You can't rely on basic blocks you look at actually having otherwise-valid code.<br></div><div>You can't rely on phi nodes having predecessors that are valid (IE if you walk up the graph, you can validly hit invalid code).</div><div>etc</div><div><br></div><div>Essentially, you have *no guarantee*, at all, what is in an unreachable block.</div><div><br></div><div>You get instructions like this from jump threading:</div><div><pre style="white-space:pre-wrap;color:rgb(0,0,0)">  %2 = getelementptr inbounds i8* %2, i64 1
</pre></div><div><br></div><div>It's not clear what one is supposed to do with such an instruction, and in fact, a lot of the existing passes (beside GVN) will enter an infinite loop if you convince them to look at it.</div><div><br></div><div><br></div><div>It seems quite bad to say "well, you know, everywhere else you have well-formed code. But if you hit an unreachable block (and PS, you'll have to check yourself to see if you are in one of these magic blocks all of the sudden), all bets are off, and you should be prepared to hit anything".</div><div><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><font color="#888888"><br>
-- Sanjoy<br>
</font></span></blockquote></div><br></div></div>