<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Actually, this doesn't appear to be working on Darwin either. The issue is the call is turned into a fsin node and the "tailcall" property is apparently lost by the time legalizer expands it back into a call.  This needs to be fixed but I am not sure how.<div><br></div><div>Evan</div><div><br><div><div>On Nov 21, 2010, at 10:59 AM, Chris Lattner wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Author: lattner<br>Date: Sun Nov 21 12:59:20 2010<br>New Revision: 119947<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=119947&view=rev">http://llvm.org/viewvc/llvm-project?rev=119947&view=rev</a><br>Log:<br>apparently tailcalls are better on darwin/x86-64 than on linux?<br><br>Modified:<br>    llvm/trunk/lib/Target/X86/README.txt<br><br>Modified: llvm/trunk/lib/Target/X86/README.txt<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=119947&r1=119946&r2=119947&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=119947&r1=119946&r2=119947&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Target/X86/README.txt (original)<br>+++ llvm/trunk/lib/Target/X86/README.txt Sun Nov 21 12:59:20 2010<br>@@ -895,6 +895,24 @@<br><br> //===---------------------------------------------------------------------===//<br><br>+Linux is missing some basic tail call support:<br>+<br>+#include <math.h><br>+double foo(double a) {    return sin(a); }<br>+<br>+This compiles into this on x86-64 Linux (but not darwin):<br>+foo:<br>+<span class="Apple-tab-span" style="white-space:pre">       </span>subq<span class="Apple-tab-span" style="white-space:pre">        </span>$8, %rsp<br>+<span class="Apple-tab-span" style="white-space:pre"> </span>call<span class="Apple-tab-span" style="white-space:pre">        </span>sin<br>+<span class="Apple-tab-span" style="white-space:pre">      </span>addq<span class="Apple-tab-span" style="white-space:pre">        </span>$8, %rsp<br>+<span class="Apple-tab-span" style="white-space:pre"> </span>ret<br>+vs:<br>+<br>+foo:<br>+        jmp sin<br>+<br>+//===---------------------------------------------------------------------===//<br>+<br> Tail call optimization improvements: Tail call optimization currently<br> pushes all arguments on the top of the stack (their normal place for<br> non-tail call optimized calls) that source from the callers arguments<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></div></blockquote></div><br></div></body></html>