<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"></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="Signature"><br>
</div>
</div>
</body>
</html>