<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 20, 2016 at 8:42 PM, John Criswell <span dir="ltr"><<a href="mailto:jtcriswel@gmail.com" target="_blank">jtcriswel@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 bgcolor="#FFFFFF" text="#000000"><span class="">
<div>On 6/20/16 9:39 AM, vivek pandya via
llvm-dev wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Dear Community,
<div><br>
</div>
<div>To improve current interprocedural register allocation
(IPRA) , we have planned to set callee saved registers to none
for local functions, currently I am doing it in following way:</div>
<div><br>
</div>
<div>if (F->hasLocalLinkage() <span> </span><span>&&
!F->hasAddressTaken()</span>) {</div>
</div>
</blockquote>
<br></span>
As an aside, you might want to analyze how many functions have both
local linkage and are not address taken. I recall that many
functions returned false for hasAddressTaken() because some direct
calls casted the function to a different function type before
calling it. Such functions are still not address taken, but the
simple hasAddressTaken() method can't determine it.<br>
<br>
If you see that happening, you can simply scan through a function's
def-use chains and see if any "indirect calls" are really direct
calls that cast the function pointer. I believe SAFECode has some
code somewhere that does this if you need it.<span class=""><br>
<br></span></div></blockquote><div>Dear Professor John,</div><div><br></div><div>Thanks for pointing out this , but I wonder that how many such cases may be there on average in a module? Is it too frequently seen?</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span class="">
<br>
<blockquote type="cite">
<div dir="ltr">
<div> DEBUG(dbgs() << "Function has LocalLinkage \n");</div>
<div>F->setCallingConv(CallingConv::GHC); </div>
<div> }</div>
<div><br>
</div>
<div>but we think threre should be clean and properway to do
this perhaps like:</div>
<div><br>
</div>
<div>
<div>
<div>if (F->hasLocalLinkage() &&
!F->hasAddressTaken()) {</div>
<span> DEBUG(dbgs() << "Function has
LocalLinkage \n");</span>
<div> F->setCallingConv(CallingConv::NO_Callee_Saved);</div>
<div> }</div>
<div><br>
</div>
<div><span>So I would like to know any better suggestions
and if it is better to add a new CC for this purpose
then what aspects should be considered while defining a
new CC. Actually in this case the new CC does not really
required to define how parameters should be passed or
any special rule for return value etc , it just required
to set callee saved registers to be none. So what are
the minimal things required to define such a CC?</span></div>
</div>
</div>
<div><span><br>
</span></div>
<div><span>Other alternative that I have thought was to add new
attribute for function and use it like following in
TargetFrameLowering::determineCalleeSaves()</span></div>
<div><span><br>
</span></div>
<div>
<div> // In Naked functions we aren't going to save any
registers.</div>
<div> if
(MF.getFunction()->hasFnAttribute(Attribute::Naked))</div>
<div> return;</div>
</div>
<div><br>
</div>
<div>Any suggestions / thoughts are welcomed !</div>
</div>
</blockquote>
<br></span>
My humble opinion is that you should avoid hacks as they will likely
break as LLVM changes. If the GHC calling convention or the naked
function attribute guarantee that you will always get the behavior
that you want on all architectures, then go ahead and use them; just
make sure to add a clear and conspicuous comment explaining why are
you using them as it is not obvious.<br>
<br>
If the GHC calling convention or the naked attribute does not
guarantee to give you what you need, I'd add an attribute or a
calling convention.<br></div></blockquote><div>Actually I am not really in favor of using this kind of hack because using GHC CC or naked attribute have there other rules (in addition to no callee saved registers) and that are not really wanted. So it is desired to add new CC or attribute to achieve the required effect.</div><div><br></div><div>Sincerely,</div><div>Vivek</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
<br>
That said, I'm not familiar enough with the code generator or these
attributes/calling conventions to tell you what you should do.
You'll need input from others more familiar with them.<br>
<br>
My two cents,<br>
<br>
John Criswell<br>
<br>
<blockquote type="cite">
<div dir="ltr">
<div><br>
</div>
<div>Sincerely,</div>
<div>Vivek</div>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><span class="HOEnZb"><font color="#888888">
</font></span></pre><span class="HOEnZb"><font color="#888888">
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
<p><br>
</p>
<pre cols="72">--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/criswell</a></pre>
</font></span></div>
</blockquote></div><br></div></div>