<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Jacques,<div class=""><br class=""></div><div class="">Looked at the MIs you sent me and +1 to all that Philip said.</div><div class="">I is live across the call of foo, and since we do not have any CSR to preserve it, we must spill.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Q.<br class=""><div><blockquote type="cite" class=""><div class="">On Sep 1, 2015, at 9:13 AM, Philip Reames via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
  
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" class="">
  
  <div bgcolor="#FFFFFF" text="#000000" class="">
    <br class="">
    <br class="">
    <div class="moz-cite-prefix">On 09/01/2015 08:52 AM, Jacques Pienaar
      via llvm-dev wrote:<br class="">
    </div>
    <blockquote cite="mid:CAM4W+YeX20p2sAwtwbaWKR_-FuzV7eQ=KTFGWuiAovxN1Zs-Jg@mail.gmail.com" type="cite" class="">
      <div dir="ltr" class="">
        <div class="gmail_quote">
          <div dir="ltr" class="">Hey,
            <div class=""><br class="">
            </div>
            <div class="">I'm playing around with a backend with no callee saved
              registers and noticed more spilling than seems needed. I
              tried digging into the spilling code but with limited
              success. I also tried removing all the callee saved
              registers in the X86 backend and saw the same effect
              (basically making CSRs equal to CSR_NoRegs). So I seem to
              be misunderstanding something or missing something simple,
              and thought I'd ask.</div>
            <div class=""><br class="">
            </div>
            <div class="">Consider this program as an example:</div>
            <div class=""><br class="">
            </div>
            <div class="">
              <div class="">volatile int x;</div>
              <div class=""><br class="">
              </div>
              <div class="">int __attribute__((noinline)) foo() { return x; }</div>
              <div class=""><br class="">
              </div>
              <div class="">int main() {</div>
              <div class="">  for (int i = 0; i < 10; ++i) {</div>
              <div class="">    foo();</div>
              <div class="">  }</div>
              <div class="">}</div>
            </div>
            <div class=""><br class="">
            </div>
            <div class="">The resultant output code spills 'i' within the loop (I
              have to compile with -fno-unroll-loops else the loop and
              'i' gets optimized
              <!--
-->away) while 'i' is assigned to a register that is used nowhere else
              in the generated program and I would consider 'foo' easy
              to analyse. At the call site of 'foo' the debugging output
              reports that the stack pointer and return value registers
              are "imp-use" and "imp-def" and no other registers are
              used.</div>
            <div class=""><br class="">
            </div>
            <div class="">Should the spilling have occurred? Or this due to some
              feature in the backend that is missing?</div>
          </div>
        </div>
      </div>
    </blockquote>
    What are you expectating here?  Are you expecting the backend to
    recognize that foo doesn't actually clobber any registers?  I don't
    believe we do that today.  Without callee saved registers, if the
    value 'i' needs to be preserved across the call, it will need to be
    spilled.  There's no register we can put it in without it being
    clobbered.<br class="">
    <blockquote cite="mid:CAM4W+YeX20p2sAwtwbaWKR_-FuzV7eQ=KTFGWuiAovxN1Zs-Jg@mail.gmail.com" type="cite" class="">
      <div dir="ltr" class="">
        <div class="gmail_quote">
          <div dir="ltr" class="">
            <div class=""><br class="">
            </div>
            <div class="">Thanks,</div>
            <div class=""><br class="">
            </div>
            <div class="">Jacques</div>
          </div>
        </div>
        <br class="">
      </div>
      <br class="">
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br class="">
      <pre wrap="" class="">_______________________________________________
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 class="">
  </div>

_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></body></html>