<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 class="im" 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>