<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Jul 3, 2018 at 2:12 PM Friedman, Eli <<a href="mailto:efriedma@codeaurora.org">efriedma@codeaurora.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
    <div class="m_-6507581124731221056moz-cite-prefix">On 7/3/2018 1:25 PM, Chandler Carruth
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_quote">
          <div dir="ltr">On Tue, Jul 3, 2018 at 1:05 PM Friedman, Eli
            <<a href="mailto:efriedma@codeaurora.org" target="_blank">efriedma@codeaurora.org</a>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On
            7/3/2018 1:19 AM, Chandler Carruth via llvm-commits wrote:<br>
            > Author: chandlerc<br>
            > Date: Tue Jul  3 01:19:10 2018<br>
            > New Revision: 336178<br>
            ><br>
            > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=336178&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=336178&view=rev</a><br>
            > Log:<br>
            > [ADT] Disable the single callback optimization on
            Windows.<br>
            ><br>
            > It appears that the function pointer we use there isn't
            reliably 4-byte<br>
            > aligned. I have no idea why or how we could correct
            this, so for now we<br>
            > just regress the Windows performance some.<br>
            <br>
            I don't know why you'd expect functions to be aligned; x86
            doesn't <br>
            require any alignment. clang usually prefers to align
            functions to 16 <br>
            bytes because the instruction decoder fetches 16 bytes at a
            time, but it <br>
            won't align the entry point at all at -Oz.</blockquote>
          <div><br>
          </div>
          <div>I thought there was at least some ABI requirements, but
            I'm happy to add an explicit alignment attribute which
            should be sufficient outside of Windows?</div>
        </div>
      </div>
    </blockquote>
    <br></div><div text="#000000" bgcolor="#FFFFFF">
    The alignment attribute should work on most targets, yes...</div></blockquote><div><br></div><div>One interesting problem with the alignment attribute, and the reason I didn't use it initially, is that it may *reduce* the alignment.</div><div><br></div><div>For example, I don't really want to use `__attribute__((aligned(4))))` because while that's all the alignment we *require*, I think that will actually override any default alignment that is likely higher, and result in worse performance.</div><div><br></div><div>I guess I can use `__attribute__((aligned(16)))` for now and that won't likely regress performance on any targets, but it will result in a small amount of binary bloat at -Oz and such.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"> but it
    won't work on ARM or certain MIPS variants.</div><div text="#000000" bgcolor="#FFFFFF"><br>
    <br>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_quote">
          <div> </div>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">And even
            on platforms where <br>
            functions are aligned, function pointers might not be
            aligned; for <br>
            example, ARM uses the bottom bit for interworking.<br>
          </blockquote>
          <div><br>
          </div>
          <div>Yes, but I think we can just insist "don't use such
            function pointers here"?</div>
        </div>
      </div>
    </blockquote>
    <br></div><div text="#000000" bgcolor="#FFFFFF">
    I would guess most users of LLVM on ARM use Thumb2, since it's
    smaller (and therefore faster). So functions pointers will generally
    have the least significant bit set.  But we can work around that
    with some target-specific hacks if we control the callee.<br>
    <br>
    Not sure about the details for MIPS.</div><div text="#000000" bgcolor="#FFFFFF"><br>
    <br>
    -Eli<br>
    <pre class="m_-6507581124731221056moz-signature" cols="72">-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
  </div></blockquote></div></div>