<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Feb 5, 2014 at 10:05 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@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 class="im">On 5 February 2014 12:13, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br>

> Hi nlewycky,<br>
><br>
> There's no real reason we shouldn't be doing this, so far as I know.<br>
><br>
> <a href="http://llvm-reviews.chandlerc.com/D2705" target="_blank">http://llvm-reviews.chandlerc.com/D2705</a><br>
><br>
> Files:<br>
>   lib/Transforms/IPO/GlobalOpt.cpp<br>
>   test/Transforms/GlobalOpt/fastcc.ll<br>
><br>
> Index: lib/Transforms/IPO/GlobalOpt.cpp<br>
> ===================================================================<br>
> --- lib/Transforms/IPO/GlobalOpt.cpp<br>
> +++ lib/Transforms/IPO/GlobalOpt.cpp<br>
> @@ -1898,6 +1898,15 @@<br>
>    }<br>
>  }<br>
><br>
> +/// Return true if this is a calling convention that we'd like to change.  The<br>
> +/// idea here is that we don't want to mess with the convention if the user<br>
> +/// explicitly requested something interesting like coldcc, GHC, or anyregcc.<br>
> +static bool shouldTransformCC(Function *F) {<br>
> +  CallingConv::ID CC = F->getCallingConv();<br>
> +  // FIXME: Is it worth transforming x86_stdcallcc and x86_fastcallcc?<br>
> +  return CC == CallingConv::C || CC == CallingConv::X86_ThisCall;<br>
> +}<br>
<br>
</div>It seems strange to base the legality on the CC. The language<br>
reference has no extra guarantees for one CC over the other (like it<br>
will not be turned into fastcc). Maybe we should explicitly say that<br>
it is legal to change the CC of any internal/private function that is<br>
not llvm.used or llvm.compiler_used?<br>
<br>
Profitability based on CC makes sense. Like not converting coldcc for example.<br></blockquote><div><br></div><div>What about things like the WebKit JS CC?  I assume the reason they do it that way is so that they can get GC roots in memory on the stack, and changing something like this to fastcc would break their GC.  The same might apply to the GHC convention, although I doubt it.  Changing the CC feels a lot like eliminating frame pointers, in that could mess with unwinders.</div>
<div><br></div><div>I agree that LLVM IR semantics *allow* us to do this, but I didn't feel the need to rock this particular boat.</div><div><br></div><div>If you just want to flip the naming around here to something like isProfitableToMakeFastCC() then that works for me.</div>
</div></div></div>