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.