<div dir="ltr"><div>Hello!<br><br></div>Here is a patch for this bug, as it is still unresolved and the behavior can still be reproduced in trunk.<br><br><div><div><div class="gmail_extra">It looks like it is simply an issue with the return type deduction of __atomic_* builtins. They are not using an unqualified version of the value type, whereas the __sync_* builtins are.</div><div class="gmail_extra"><div><br></div><div>Regards,<br></div><div><div>--<br>Beren Minor</div></div>
<br><div class="gmail_quote">On Wed, Nov 20, 2013 at 12:07 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</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"><div dir="ltr">I think that's this bug here:<div><a href="http://llvm.org/bugs/show_bug.cgi?id=17306" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=17306</a><br></div><div><br></div><div>Probably it's a bug in Clang's builtin IR generation.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Tue, Nov 19, 2013 at 3:11 AM, Beren Minor <span dir="ltr"><<a href="mailto:beren.minor@gmail.com" target="_blank">beren.minor@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div dir="ltr"><div><div><div><div><div>Hello,<br><br></div>I found some strange codegen output when playing with Clang's implementation of GCC atomic builtins and would like to know if this is some expected behavior or known issue.<br>
<br>The test case is very simple, and the disassembly can be seen here:<br><a href="http://bit.ly/18LED7t" target="_blank">http://bit.ly/18LED7t</a><br><br></div>It looks to me that these instructions after the load are unnecessary, and GCC does not generate them:<br>
movl %eax, -4(%rsp)<br> movl -4(%rsp), %eax<br><br></div>After investigating, it appears that this is caused by the volatile qualifier of the pointer parameter. Without it, the generated code is the same as GCC.<br>
<br></div>It looks like the volatile qualifier is propagated to some temporary variable that Clang uses in the LLVM IR, and after storing the atomic load result in this temporary, it has to reload it again before returning it. Showing the IR with -emit-llvm exhibits clearly this issue.<br>
<br></div>It seems to me that is is unnecessary to make this temporary volatile, isn't it?<br clear="all"><div><div><div><div><div><div><div><div><div><div>--<br>Beren Minor</div>
</div></div></div></div></div></div></div></div></div></div>
<br></div></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div></div></div>