[PATCH] D42216: Use New Module Metadata String "AvoidPLT" to avoid calls via PLT

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 17 17:24:37 PST 2018


On Wed, Jan 17, 2018 at 5:07 PM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Sriraman Tallam via Phabricator <reviews at reviews.llvm.org> writes:
>
> > tmsriram created this revision.
> > tmsriram added reviewers: rnk, rafael.
> >
> > Introduce a Module Metadata String "AvoidPLT" to avoid calls via PLT.
> >
> > 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.
>
> It is not possible to add "options" to intrinsics? That will be annoying

for the transition to dso_local.
>

It isn't. I suggested using module flags like we do for -mregparm.

> Index: lib/Target/X86/X86ISelLowering.cpp
> > ===================================================================
> > --- lib/Target/X86/X86ISelLowering.cpp
> > +++ lib/Target/X86/X86ISelLowering.cpp
> > @@ -3732,11 +3732,23 @@
> >      }
> >    } else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee))
> {
> >      const Module *Mod = DAG.getMachineFunction().
> getFunction().getParent();
> > -    unsigned char OpFlags =
> > -        Subtarget.classifyGlobalFunctionReference(nullptr, *Mod);
> > +    // If PLT must be avoided then the call should be via GOTPCREL.
> > +    unsigned char OpFlags = X86II::MO_GOTPCREL;
> > +
> > +    if (!Mod->getAvoidPLT()) {
> > +      OpFlags = Subtarget.classifyGlobalFunctionReference(nullptr,
> *Mod);
> > +    }
> >
> >      Callee = DAG.getTargetExternalSymbol(
> >          S->getSymbol(), getPointerTy(DAG.getDataLayout()), OpFlags);
> > +
> > +    if (OpFlags == X86II::MO_GOTPCREL) {
> > +      Callee = DAG.getNode(X86ISD::WrapperRIP, dl,
> > +          getPointerTy(DAG.getDataLayout()), Callee);
> > +      Callee = DAG.getLoad(
> > +          getPointerTy(DAG.getDataLayout()), dl, DAG.getEntryNode(),
> Callee,
> > +          MachinePointerInfo::getGOT(DAG.getMachineFunction()));
> > +    }
>
> The logic should be added to shouldAssumeDSOLocal.
>

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180117/de55af74/attachment.html>


More information about the llvm-commits mailing list