<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 15 May 2014 09:42, Sasa Stankovic <span dir="ltr"><<a href="mailto:Sasa.Stankovic@imgtec.com" target="_blank">Sasa.Stankovic@imgtec.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>> I was wondering whether tail calls to other functions would become jumps that would > need handling via MipsLongBranch. The answer seems to be that LLVM always<br>


</div><div>
> compiles function calls to indirect jumps on MIPS. (However, GCC does compile tail > calls to direct jumps.) That answer seems a bit crazy, so I'm not sure if it's right. You> should check. Does the MIPS linker insert veneers to handle long direct jumps the<br>



> same way ARM linkers do?<br>
<br>
</div>I checked tail calls on LLVM and GCC, and they generate similar code when given explicit relocation model on the command line. When relocation model is omitted the code differs because default for MIPS GCC is non-pic, and for MIPS LLVM is pic. For pic code (which this patch handles) tail calls are replaced by load from GOT and indirect jump:<br>



<br>
lw      $t9, %call16(func)($gp)<br>
jr      $t9<br>
<br>
and this doesn't need long branch.</blockquote><div><br></div><div>OK.  And the non-PIC (-relocation-model=static) case is OK because it generates "j" or "jal" (taking a 26-bit absolute address) for a function call rather than "b" or "bal" (taking a 16-bit relative address, for which expanding using MipsLongBranch was necessary).  Looks like function calls aren't affected by this change, then.  LGTM still.</div>

<div><br></div><div>Cheers,</div><div>Mark</div><div><br></div></div></div></div>