<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 1 August 2013 00:11, Travis Cross <span dir="ltr"><<a href="mailto:tc@travislists.com" target="_blank">tc@travislists.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">
On 2013-07-30 22:11, Eli Bendersky wrote:<br>
> we've published an initial version of the PNaCl bitcode reference<br>
> manual online -<br>
> <a href="http://www.chromium.org/nativeclient/pnacl/bitcode-abi" target="_blank">http://www.chromium.org/nativeclient/pnacl/bitcode-abi</a>. The PNaCl<br>
> bitcode is a restricted subset of LLVM IR.<br>
><br>
> Any comments would be most welcome.<br>
<br>
Hi Eli,<br>
<br>
I appreciate you for opening the process for input and comments. One<br>
question stood out to me while reading the document:<br>
<br>
The document [1] indicates that only the 'ccc' calling convention will<br>
be supported. The LLVM documentation [2] prominently notes that,<br>
"tail calls can only be optimized when [fastcc], the GHC or the HiPE<br>
convention is used."</blockquote><div><br></div><div>That note in the documentation seems to be incorrect, because LLVM will do tail call optimisations on at least x86 when using the "ccc" calling convention. For example:<br>
</div><div><br>$ cat tail_call1.c<br>void foo(int arg);<br>void bar(int arg) {<br> foo(arg);<br>}<br><br>$ clang tail_call1.c -S -o - -O2<br>...<br>bar: # @bar<br>...<br> jmp foo # TAILCALL<br>
...<br><br></div><div>However, LLVM doesn't emit a tail call at -O0.<br></div><div><br></div><div>Maybe what the documentation means to say is that tail call optimisations are only guaranteed to be done when using fastcc etc.?<br>
<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Further, I notice that the document includes<br>
"call" but not "tail call" in the list of supported instructions.<br></blockquote><div><br></div><div>That's an omission in the document. We do actually allow the "tail call" instruction in PNaCl.<br>
<br>However, we haven't specified any guarantees that a tail call optimisation will happen. I suppose we could specify some guarantees if people want this. Maybe we could say that a "tail call" instruction is guaranteed to be turned into a real tail call if the callee function has the same number of arguments as the caller function or fewer? I think that would work on all the architectures PNaCl targets.<br>
<br></div><div>Then we would have to change -O0 translation so that the guarantee is provided consistently at all optimisation levels.<br></div><br></div><div class="gmail_quote">Cheers,<br></div><div class="gmail_quote">
Mark<br><br></div></div></div>