<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jan 17, 2018 at 5:07 PM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Sriraman Tallam via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> writes:<br>
<br>
> tmsriram created this revision.<br>
> tmsriram added reviewers: rnk, rafael.<br>
><br>
> Introduce a Module Metadata String "AvoidPLT" to avoid calls via PLT.<br>
><br>
> Annotating functions with nonlazybind attribute to avoid the PLT does not work for intrinsics. Intrinsics need to be handled specially and it seems easier to handle them by just annotating the module.<br>
<br>
</span>It is not possible to add "options" to intrinsics? That will be annoying </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">for the transition to dso_local.<br></blockquote><div><br></div><div>It isn't. I suggested using module flags like we do for -mregparm. </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> Index: lib/Target/X86/<wbr>X86ISelLowering.cpp<br>
> ==============================<wbr>==============================<wbr>=======<br>
> --- lib/Target/X86/<wbr>X86ISelLowering.cpp<br>
> +++ lib/Target/X86/<wbr>X86ISelLowering.cpp<br>
> @@ -3732,11 +3732,23 @@<br>
> }<br>
> } else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode><wbr>(Callee)) {<br>
> const Module *Mod = DAG.getMachineFunction().<wbr>getFunction().getParent();<br>
> - unsigned char OpFlags =<br>
> - Subtarget.<wbr>classifyGlobalFunctionReferenc<wbr>e(nullptr, *Mod);<br>
> + // If PLT must be avoided then the call should be via GOTPCREL.<br>
> + unsigned char OpFlags = X86II::MO_GOTPCREL;<br>
> +<br>
> + if (!Mod->getAvoidPLT()) {<br>
> + OpFlags = Subtarget.<wbr>classifyGlobalFunctionReferenc<wbr>e(nullptr, *Mod);<br>
> + }<br>
><br>
> Callee = DAG.getTargetExternalSymbol(<br>
> S->getSymbol(), getPointerTy(DAG.<wbr>getDataLayout()), OpFlags);<br>
> +<br>
> + if (OpFlags == X86II::MO_GOTPCREL) {<br>
> + Callee = DAG.getNode(X86ISD::<wbr>WrapperRIP, dl,<br>
> + getPointerTy(DAG.<wbr>getDataLayout()), Callee);<br>
> + Callee = DAG.getLoad(<br>
> + getPointerTy(DAG.<wbr>getDataLayout()), dl, DAG.getEntryNode(), Callee,<br>
> + MachinePointerInfo::getGOT(<wbr>DAG.getMachineFunction()));<br>
> + }<br>
<br>
The logic should be added to shouldAssumeDSOLocal.<br></blockquote><div><br></div><div>We might need to extend shouldAssumeDSOLocal to know that we are calling a function. We only have an ExternalSymbol in this case, not a GlobalValue, so GV there will be null. </div></div></div></div>