<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 3, 2017 at 10:58 AM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-m_-1068428660065499679gmail-">Sriraman Tallam <<a href="mailto:tmsriram@google.com" target="_blank">tmsriram@google.com</a>> writes:<br>
<br>
>> The check for plt versus got should at the very least be after the<br>
>> shouldAssumeDSOLocal call.<br>
>><br>
><br>
> I tried doing this after shouldAssumeDSOLocal and this does not work well<br>
> non-PIC binaries. The external call will be considered local and generated<br>
> without the @PLT but the linker will convert the call to PLT. This is the<br>
> reason why I did it before "shouldAssumeDSOLocal". Let me take another look<br>
> and see what I can do here.<br>
<br>
</span>Ah, that is why!<br>
<br>
Yes, the linker hack of creating a dummy plt entry is really annoying.<br>
<br>
I would say that what needs changing is shouldAssumeDSOLocal. It looks<br>
like<br>
<br>
------------------------------<wbr>------------------------------<wbr>-<br>
// If the IR producer requested that this GV be treated as dso local, obey.<br>
if (GV && GV->isDSOLocal())<br>
return true;<br>
<br>
// According to the llvm language reference, we should be able to just return<br>
// false in here if we have a GV, as we know it is dso_preemptable.<br>
// At this point in time, the various IR producers have not been transitioned<br>
// to always produce a dso_local when it is possible to do so. As a result we<br>
// still have some pre-dso_local logic in here to improve the quality of the<br>
// generated code:<br>
....<br>
------------------------------<wbr>------------------------------<wbr>-<br>
<br>
So any addition that returns false in more cases is going on the right<br>
direction. In particular, I think you a hitting the case inside<br>
<br>
if (IsExecutable) {<br>
...<br>
}<br>
<br>
And it should return false for NonLazyBind (with a comment why).<br></blockquote><div><br></div><div>I could do it this way but I must add an arch check here as this is x86_64 specific, atleast for now. OTOH, I could keep this entirely in X86Subtarget.cpp and add a check like this:</div><div><div>diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp</div><div>index 9e060f97df3..f7ca3be483f 100644</div><div>--- a/lib/Target/X86/X86Subtarget.cpp</div><div>+++ b/lib/Target/X86/X86Subtarget.cpp</div><div>@@ -150,6 +150,7 @@ X86Subtarget::classifyGlobalFunctionReference(const GlobalValue *GV,</div><div> // target.</div><div> if (isTargetELF() && is64Bit() && F &&</div><div> F->hasFnAttribute(Attribute::NonLazyBind) &&</div><div>+ !GV->hasLocalLinkage() && GV->hasDefaultVisibility() &&</div><div> GV->isDeclarationForLinker())</div><div> return X86II::MO_GOTPCREL;</div></div><div><br></div><div>Any preference? </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div></div>