llvm-project/llvm/lib/LTO
Alexandre Ganea 617d64f6c5 Re-land [ThinLTO] Re-order modules for optimal multi-threaded processing
This reverts 9b5b305023 and fixes the unwanted re-ordering when generating ThinLTO indexes.

The goal of this patch is to better balance thread utilization during ThinLTO in-process linking (in llvm-lto2 or in LLD). Before this patch, large modules would often be scheduled late during execution, taking a long time to complete, thus starving the thread pool.

We now sort modules in descending order, based on each module's bitcode size, so that larger modules are processed first. By doing so, smaller modules have a better chance to keep the thread pool active, and thus avoid starvation when the bitcode compilation is almost complete.

In our case (on dual Intel Xeon Gold 6140, Windows 10 version 2004, two-stage build), this saves 15 sec when linking `clang.exe` with LLD & -flto=thin, /opt:lldltojobs=all, no ThinLTO cache, -DLLVM_INTEGRATED_CRT_ALLOC=d:\git\rpmalloc.

Before patch: 100 sec
After patch: 85 sec

Inspired by the work done by David Callahan in D60495.

Differential Revision: https://reviews.llvm.org/D87966
2020-10-13 21:54:15 -04:00
..
CMakeLists.txt Update compiler extension integration into the build system 2020-04-24 09:40:14 +02:00
Caching.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
LLVMBuild.txt Update compiler extension integration into the build system 2020-04-24 09:40:14 +02:00
LTO.cpp Re-land [ThinLTO] Re-order modules for optimal multi-threaded processing 2020-10-13 21:54:15 -04:00
LTOBackend.cpp [ThinLTO] Option to bypass function importing. 2020-09-22 13:12:11 -07:00
LTOCodeGenerator.cpp [LTO] Don't apply LTOPostLink module flag during writeMergedModule 2020-08-26 11:17:45 -07:00
LTOModule.cpp Remove GlobalValue::getAlignment(). 2020-06-23 19:13:42 -07:00
SummaryBasedOptimizations.cpp Add missing includes needed to prune LLVMContext.h include, NFC 2019-11-14 15:23:15 -08:00
ThinLTOCodeGenerator.cpp Re-land [ThinLTO] Re-order modules for optimal multi-threaded processing 2020-10-13 21:54:15 -04:00
UpdateCompilerUsed.cpp TargetLowering.h - remove unnecessary TargetMachine.h include. NFC 2020-05-23 19:49:38 +01:00