<div dir="ltr">Should be fixed in r273711.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 24, 2016 at 11:29 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This looks like a bug to me...  It seems that callers of SimplifyInstruction are not checking to see if the replaced instruction is side-effect free.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 24, 2016 at 10:37 AM, u3shit via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-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">Hello,<br>
<br>
[Please CC me when replying, I'm not on the list]<br>
<br>
I've been experimenting with replacing assert with __builtin_assume in<br>
release builds, and I've hit a problem. I did not open a bug because I'm<br>
not sure if this is really a bug, or just the documentation is not clear<br>
enough. Anyway, look at this simple program:<br>
<br>
#include <stdio.h><br>
<br>
int global;<br>
<br>
int foo()<br>
{<br>
    global = 1;<br>
    return 3;<br>
}<br>
<br>
int main()<br>
{<br>
    int x = foo();<br>
    __builtin_assume(x == 3);<br>
    printf("%d %d\n", x, global);<br>
    return 0;<br>
}<br>
<br>
<br>
If I try to run it:<br>
$ clang++ -O2 foo.cpp && ./a.out<br>
3 0<br>
<br>
(If I compile with -O0, I get the expected "3 1" as output). The<br>
documentation itself says "The argument itself is never evaluated, so<br>
any side effects of the expression will be discarded.", but the argument<br>
here is "x == 3", not "foo() == 3", so IMHO it shouldn't eliminate the<br>
function call here. Am I right here?<br>
<br>
I get the same result from clang 3.8.0 from gentoo and from the git master.<br>
<br>
Thanks.<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>