<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 25, 2015 at 9:35 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.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"><span class="">On 25 February 2015 at 10:58, Daniel Berlin <<a href="mailto:dberlin@dberlin.org">dberlin@dberlin.org</a>> wrote:<br>
><br>
><br>
> On Wed, Feb 25, 2015 at 6:26 AM, Rafael Espíndola<br>
> <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
>><br>
>> > Maybe.<br>
>> > My view is the ideal is either no-unreachable code, or unreachable<br>
>> > blocks<br>
>> > only contain terminators.<br>
>><br>
>> I am definitely happy with both. What worries me is introducing a<br>
>> special dominance rule for unreachable blocks.<br>
>><br>
>> >> I don't think that rejecting<br>
>> >><br>
>> >>   %a = getelementptr inbounds i8* %a, i64 1<br>
>> >><br>
>> >> but accepting<br>
>> >><br>
>> >>   %a = getelementptr inbounds i8* %b, i64 1<br>
>> >>   %b = getelementptr inbounds i8* %a, i64 1<br>
>> >><br>
>> ><br>
>> > Does the verifier accept the latter right now?<br>
>><br>
>> Yes. %a dominates %b and %b dominates %a, so it is valid.<br>
>><br>
><br>
> So i'm confused.<br>
><br>
> How does %b dominate %a?<br>
<br>
</span>all the zero paths from entry to %a pass by %b.<br></blockquote><div><br></div><div>That is a graph-wise definition, sure.</div><div>So, this is an interesting definition, and maybe this is part of the source of the problem.</div><div><br></div><div>For SSA, at least GCC requires that both "definition block dominates use block" (which would be true here), *and*</div><div>that "definition appears before use in block" (IE definition locally dominates use).</div><div><br></div><div>IE it has to pass both DT->dominates(block(%b), block(%a)) and DT->dominates(%b, %a).</div><div><br></div><div>LLVM special cases "not reachable from entry", and says that no matter what, #2 is true if %a is unreachable.</div><div><br></div><div>The code is, IMHO, not even self-consistent</div><div><div><br></div><div><br></div><div>   // Any unreachable use is dominated, even if Def == User.</div><div>   if (!isReachableFromEntry(UseBB))</div><div>     return true;</div><div><br></div><div>   // Unreachable definitions don't dominate anything.</div><div>   if (!isReachableFromEntry(DefBB))</div><div>     return false;</div></div><div><br></div><div><br></div><div><br></div><div>Riddle me this: If unreachable definitions dominate nothing, how are unreachable uses always dominated by their unreachable defs?<br><br></div></div></div></div>