[llvm] r317292 - Avoid PLT for external calls when attribute nonlazybind is used.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 07:58:11 PDT 2017


Sriraman Tallam <tmsriram at google.com> writes:

> On Thu, Nov 2, 2017 at 5:43 PM, Rafael Avila de Espindola
> <rafael.espindola at gmail.com> wrote:
>> Why force a call via the got when a direct one could be used?
>>
>> With -fno-plt -fPIC gcc compiles
>>
>> __attribute__((visibility("hidden"))) void foo(void);
>> void bar(void);
>> void zed(void) {
>>   foo();
>>   bar();
>> }
>>
>> to
>>
>>         call    foo
>>         call    *bar at GOTPCREL(%rip)
>>
>> But this patch will use the got for both calls, no?
>
> I did not test this case and if it is true that foo can never be
> external in this case then I got it wrong.  But what if foo was not
> defined by the DSO?

It would be a bug in the program as it is hidden.

The check for plt versus got should at the very least be after the
shouldAssumeDSOLocal call.

Cheers,
Rafael


More information about the llvm-commits mailing list