<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 6/20/16 9:39 AM, vivek pandya via
      llvm-dev wrote:<br>
    </div>
    <blockquote
cite="mid:CAHYgpoJchoADK+FfzWfw3QcrEMOUawfyq9anKkiBTp0F7mkssw@mail.gmail.com"
      type="cite">
      <meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
      <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>
    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.<br>
    <br>
    <br>
    <blockquote
cite="mid:CAHYgpoJchoADK+FfzWfw3QcrEMOUawfyq9anKkiBTp0F7mkssw@mail.gmail.com"
      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 class="im">    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>
    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>
    <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
cite="mid:CAHYgpoJchoADK+FfzWfw3QcrEMOUawfyq9anKkiBTp0F7mkssw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Sincerely,</div>
        <div>Vivek</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
    <br>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a class="moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell">http://www.cs.rochester.edu/u/criswell</a></pre>
  </body>
</html>