This is an archive of the discontinued LLVM Phabricator instance.

Support nonlazybind attribute for X86 64-bit ELF (invoked via -fno-plt)

Authored by tmsriram on Oct 18 2017, 11:32 AM.



GCC supports option -fno-plt to avoid calls via the PLT. Allow the same in clang/llvm.

This llvm patch does not use the PLT and calls indirectly via the GOT if the function is declared as external. GCC supports this feature via option -fno-plt, We noticed that, for large binaries, avoiding the PLT helps reduce the iTLB misses and improves performance of some of our critical benchmarks by more than 0.5%.

This patch generates indirect calls for all external functions. For non-LTO, if the external function ends up linked with the binary, the linker can convert these indirect calls to direct. GNU ld and gold already support this,

I will make a separate clang patch to add option -fno-plt which will annotate external functions with the "nonlazybind" attribute.

Diff Detail


Event Timeline

tmsriram created this revision.Oct 18 2017, 11:32 AM
rnk accepted this revision.Oct 23 2017, 1:52 PM

Looks good!

This revision is now accepted and ready to land.Oct 23 2017, 1:52 PM
This revision was automatically updated to reflect the committed changes.