<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Oh nevermind, that works.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"> - Jay</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block;width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font color="#000000" face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b> Jay K<br>
<b>Sent:</b> Wednesday, March 28, 2018 9:39 AM<br>
<b>To:</b> llvm-dev@lists.llvm.org<br>
<b>Subject:</b> Re: arm tailcall with many parameters?</font>
<div> </div>
</div>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p style="margin-top:0; margin-bottom:0">Sorry that also suffered from signature mismatch.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">So how about more like:</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0"></p>
<div><br>
typedef struct vtable_t {<br>
int (*pf4)(int a, int b, int c, int d);<br>
int (*pf5)(int a, int b, int c, int d, int e);<br>
} vtable_t;</div>
<div><br>
</div>
<div>int f3(int (*pf5)(int a, int b, int c, int d, int e), int a, int b, int c, int d)<br>
</div>
<div>{<br>
return pf5(a, b, c, d, d + d);<br>
}</div>
<div>int f4(vtable_t *vt, int a, int b, int c, int d)<br>
{<br>
return vt->pf5(a, b, c, d, d + d);<br>
}</div>
<div><br>
</div>
<br>
<p></p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0"> - Jay</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<div id="x_Signature"><br>
</div>
<br>
<br>
<div style="color:rgb(0,0,0)">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font color="#000000" face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b> Jay K<br>
<b>Sent:</b> Wednesday, March 28, 2018 9:29 AM<br>
<b>To:</b> llvm-dev@lists.llvm.org<br>
<b>Subject:</b> arm tailcall with many parameters?</font>
<div> </div>
</div>
<div dir="ltr">
<div id="x_x_divtagdefaultwrapper" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p style="margin-top:0; margin-bottom:0"></p>
<div>typedef struct vtable_t {<br>
int (*pf4)(int a, int b, int c, int d);<br>
int (*pf5)(int a, int b, int c, int d, int e);<br>
} vtable_t;</div>
<div><br>
</div>
<div><br>
</div>
<div>int f1(int (*pf4)(int a, int b, int c, int d))<br>
{<br>
return pf4(1, 2, 3, 4);<br>
}</div>
<div><br>
</div>
<div><br>
</div>
<div>int f2(vtable_t *vt)<br>
{<br>
return vt->pf4(1, 2, 3, 4);<br>
<br>
</div>
<div>}</div>
<div><br>
</div>
<div>gcc and clang will not tailcall these on arm with -O3.</div>
<div><br>
</div>
<div><br>
</div>
<div>int f3(int (*pf5)(int a, int b, int c, int d, int e))<br>
{<br>
return pf5(1, 2, 3, 4, 5);<br>
}</div>
<div><br>
</div>
<div>int f4(vtable_t *vt)<br>
{<br>
return vt->pf5(1, 2, 3, 4, 5);<br>
}</div>
<div><br>
</div>
<div><br>
Could you not allocate an extra word on the stack,<br>
in the first position, store the return address there, and pop<br>
it to pc (or ip and then move to pc) after restoring nonvolatiles and lr?</div>
<div>Is that not describable in unwind data?</div>
<div><br>
</div>
<div>I only tested Debian's 3.3 so far but I'll try to try 6.0.</div>
<br>
<p></p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">I ask because I'm working on tailcalls in another project.</p>
<p style="margin-top:0; margin-bottom:0">I figured I'd look at gcc/clang output for hints here.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">I understand there can be multiple exits of a function -- tailcalls of varying signatures and non-tailcalls.<br>
</p>
<p style="margin-top:0; margin-bottom:0"></p>
<p style="margin-top:0; margin-bottom:0"></p>
<p style="margin-top:0; margin-bottom:0">I don't think that breaks the idea.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0"></p>
<p style="margin-top:0; margin-bottom:0">Thank you,</p>
<p style="margin-top:0; margin-bottom:0"> - Jay</p>
<div id="x_x_Signature"><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>