[LLD][ThinLTO] Add --thinlto-single-module to allow compiling partial modules.
authorHongtao Yu <hoy@fb.com>
Thu, 21 May 2020 20:19:44 +0000 (13:19 -0700)
committerHongtao Yu <hoy@fb.com>
Wed, 10 Jun 2020 22:32:30 +0000 (15:32 -0700)
commit2638aafe1203f64983017f8998fb09ce986a1b28
tree158521bc2de7dba1e5bfcd4c51215706bacc4abe
parent7e06cf0011a8af96f8c983bcf7a31b952e698de9
[LLD][ThinLTO] Add --thinlto-single-module to allow compiling partial modules.

This change introduces an LLD switch --thinlto-single-module to allow compiling only a part of the input modules. This is specifically enables:

  1. Fast investigating/debugging modules of interest without spending time on compiling unrelated modules.
  2. Compiler debug dump with -mllvm -debug-only= for specific modules.

It will be useful for large applications which has 1K+ input modules for thinLTO.

The switch can be combined with `--lto-obj-path=` or `--lto-emit-asm` to obtain intermediate object files or assembly files. So far the module name matching is implemented as a fuzzy name lookup where the modules with name containing the switch value are compiled.

E.g,
Command:
     ld.lld main.o thin.a --thinlto-single-module=thin.a --lto-obj-path=single.o
log:
     [ThinLTO] Selecting thin.a(thin1.o at 168) to compile
     [ThinLTO] Selecting thin.a(thin2.o at 228) to compile
Command:
     ld.lld main.o thin.a --thinlto-single-module=thin1.o --lto-obj-path=single.o
log:
     [ThinLTO] Selecting thin.a(thin1.o at 168) to compile

Differential Revision: https://reviews.llvm.org/D80406
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/LTO.cpp
lld/ELF/Options.td
lld/test/ELF/lto/thinlto-single-module.ll [new file with mode: 0644]
llvm/include/llvm/LTO/Config.h
llvm/include/llvm/LTO/LTO.h
llvm/lib/LTO/LTO.cpp