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

Sriraman Tallam via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 20 11:29:53 PST 2018


On Tue, Feb 20, 2018 at 9:51 AM, Rafael Avila de Espindola
<rafael.espindola at gmail.com> wrote:
> Sriraman Tallam <tmsriram at google.com> writes:
>
>> On Mon, Jan 29, 2018 at 2:35 PM, Rafael Avila de Espindola
>> <rafael.espindola at gmail.com> wrote:
>>> Sriraman Tallam via Phabricator <reviews at reviews.llvm.org> writes:
>>>
>>> This LGTM with a llvm-link patch added.
>>>
>>>> --- lib/Target/X86/X86Subtarget.cpp
>>>> +++ lib/Target/X86/X86Subtarget.cpp
>>>> @@ -157,8 +157,11 @@
>>>>        // In Regcall calling convention those registers are used for passing
>>>>        // parameters. Thus we need to prevent lazy binding in Regcall.
>>>>        return X86II::MO_GOTPCREL;
>>>> -    if (F && F->hasFnAttribute(Attribute::NonLazyBind) && is64Bit())
>>>> -      return X86II::MO_GOTPCREL;
>>>> +    // If PLT must be avoided then the call should be via GOTPCREL.
>>>> +    if (((F && F->hasFnAttribute(Attribute::NonLazyBind)) ||
>>>> +         (!F && M.getRtLibUseGOT())) &&
>>>> +        is64Bit())
>>>> +       return X86II::MO_GOTPCREL;
>>>>      return X86II::MO_PLT;
>>>>    }
>>>
>>> Should we deprecate the non lazy bind attribute and always use the
>>> module flag?
>>
>> There is still a use case for the attribute.  I was hoping to expose a
>> function attribute in clang that can be used to set the nonlazybind
>> attribute only for a subset of functions.  Would be useful for linkers
>> which do not know how to undo indirect calls to direct for functions
>> that are not external or for 32-bit.
>
> Sounds reasonable.
>
> Still LGTM.


Updated the patch. Ok to commit?  Do I need an explicit approval on
Differential?

Thanks
Sri

>
> Cheers,
> Rafael


More information about the llvm-commits mailing list