Page MenuHomePhabricator

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

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

Details

Summary

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, https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00001.html. 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, https://sourceware.org/ml/binutils/2016-05/msg00322.html

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

Diff Detail

Repository
rL LLVM

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.