<div dir="ltr">GlobalOpt already does this with fastcc, use it as a guide if you want to do this:<div><a href="https://github.com/llvm-mirror/llvm/blob/63b34cdf342b8265d98357008765b2563dd04e6c/lib/Transforms/IPO/GlobalOpt.cpp#L2023">https://github.com/llvm-mirror/llvm/blob/63b34cdf342b8265d98357008765b2563dd04e6c/lib/Transforms/IPO/GlobalOpt.cpp#L2023</a><br></div><div><br></div><div>You can't just change the convention of F, you need to update the convention used at F's call sites.</div><div><br></div><div>Unfortunately, while LLVM has PreserveMost and PreservesAll calling conventions, it does not appear to have an equivalent PreservesNone/Least.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 20, 2016 at 7:39 AM, vivek pandya via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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><font face="monospace, monospace">if (F->hasLocalLinkage() <span style="font-size:12.499999046325684px"> </span><span style="font-size:12.499999046325684px">&& !F->hasAddressTaken()</span>) {</font></div><div><font face="monospace, monospace">   DEBUG(dbgs() << "Function has LocalLinkage \n");</font></div><div><font face="monospace, monospace">F->setCallingConv(CallingConv::GHC); </font></div><div><font face="monospace, monospace"> }</font></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 style="font-size:12.499999046325684px"><font face="monospace, monospace">if (F->hasLocalLinkage() && !F->hasAddressTaken()) {</font></div><span style="font-size:12.499999046325684px"><font face="monospace, monospace">    DEBUG(dbgs() << "Function has LocalLinkage \n");</font></span><div style="font-size:12.499999046325684px"><font face="monospace, monospace">    F->setCallingConv(CallingConv::NO_Callee_Saved);</font></div><div style="font-size:12.499999046325684px"><font face="monospace, monospace">  }</font></div><div style="font-size:12.499999046325684px"><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.499999046325684px">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></font></div></div></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.499999046325684px"><br></span></font></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.499999046325684px">Other alternative that I have thought was to add new attribute for function and use it like following in TargetFrameLowering::determineCalleeSaves()</span></font></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.499999046325684px"><br></span></font></div><div><div style="font-size:12.499999046325684px"> <font face="monospace, monospace">// In Naked functions we aren't going to save any registers.</font></div><div style="font-size:12.499999046325684px"><font face="monospace, monospace">  if (MF.getFunction()->hasFnAttribute(Attribute::Naked))</font></div><div style="font-size:12.499999046325684px"><font face="monospace, monospace">    return;</font></div></div><div style="font-size:12.499999046325684px"><font face="monospace, monospace"><br></font></div><div style="font-size:12.499999046325684px"><font face="arial, helvetica, sans-serif">Any suggestions / thoughts are welcomed !</font></div><div style="font-size:12.499999046325684px"><font face="arial, helvetica, sans-serif"><br></font></div><div style="font-size:12.499999046325684px"><font face="arial, helvetica, sans-serif">Sincerely,</font></div><div style="font-size:12.499999046325684px"><font face="arial, helvetica, sans-serif">Vivek</font></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>