<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">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 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><br></div><div>I understand that we can't get a fully general thing, but given that we control both the function definition and the use of the address, it seems reasonable to try quite hard to get the aligned pointer. This seems especially true given that there will always be *many* empty bits in a function pointer.</div><div><br></div><div>I really don't want to use separate storage for the flag because that will use not one byte, but in practice 8 bytes.</div><div><br></div><div>I really don't want to use a double indirection because of the performance hit.</div><div><br></div><div>I'm happy to fallback on double indirection when we don't have a reasonably compliant ABI / compiler though.</div><div><br></div><div>Does that make sense? (Hans already sent the patch w/ the explicit alignment attribute...)</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
-Eli<br>
<br>
-- <br>
Employee of Qualcomm Innovation Center, Inc.<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project<br>
<br>
</blockquote></div></div>