<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On 15 June 2017 at 23:12, John Regehr 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Peter, I don't see what you're driving at here. You can perhaps move the discussion forward with a complete, compilable example.<br>
<br>
John</blockquote><div><br></div><div>I don't KNOW for sure, but I think I understand, see below: </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On 6/15/17 11:27 AM, Peter Lawrence via llvm-dev wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Nuno,<br>
          One of your recent emails got me thinking about inlining.<br>
<br>
I say this function is always well defined,<br>
And it always executes statement S<br>
<br>
F(a)<br>
{<br>
   If (a == a) S;<br>
}<br></blockquote></div></div></blockquote><div><br></div><div>I think the problem can be seen as:<br>void F(int a)<br>{<br>    if (a == a) do_stuff();</div><div>}<br><br>....<br>main()<br>{<br>    int x;<br>    F(x);<br>}<br><br>If the compiler doesn't inline F, it will definitely call F, where the compiler doesn't KNOW that x is undef, and as a result, do_stuff is guaranteed to execute. If F is inlned, x is known as undef, so the compiler decides that the comparison is false (despite x always has to be equal to itself, no matter whether it's value is undef or not), and thus do_stuff wlll not be called.<br><br>Of course, it would be easy to fix this by initializing x, but with some more complex code, it may not be so easy to follow what is going on and what the effects will be.<br><br>I don't have a good answer as to what to do - I can sort of see both sides on this one.</div><div><br></div><div>--</div><div>Mats</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
And that if this function is inlined it must still be well defined,<br>
And still always execute statement S<br>
<br>
But if I read your example correctly you feel that the result<br>
of inlining is undefined behavior because “if (undef == undef)”<br>
and “if (poison == poison)” is undefined behavior  ?<br>
<br>
I say that if the compiler makes it so that the programmer cannot<br>
correctly reason about how their program executes then there is<br>
something wrong with the compiler.<br>
<br>
My own opinion about this is that it is yet another example of why<br>
"Since each use of ‘undef’ can yield a different result…”<br>
is such a bad definition, and should never have been accepted into<br>
the IR in the first place.<br>
<br>
IIUC, both “undef” and “poison” share this undesirable definition<br>
for which “freeze” is proposed as a fix, but if I understand your<br>
logic correctly there is no way to fix this example with “freeze” ?<br>
<br>
IMHO "freeze” is a bandaid over a bad definition, that doesn’t<br>
seem to solve the inlining problem, and we should fix the definition<br>
rather than add a bandaid.<br>
<br>
<br>
Peter Lawrence.<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div></div>