With D33921, we gained the ability to have module summaries in regular
LTO modules without triggering ThinLTO compilation. There is however,
currently, no way to trigger the emission of a module summary with
regular LTO in Clang. This patch adds a flag -femit-summary-index which
makes that possible.
Why would you want a summary with regular LTO?
The Qualcomm Linker performs a two-phase garbage collection (a.k.a. dead
stripping): firstly, before LTO compilation, and then again afterwards.
The key advantage of already running GC before LTO is that in links that
involve a heavy mix of ELF objects and bitcode (a critical use case for
us), we can prune some of the dependences between bitcode and ELF and
thus internalize more symbols in LTO.
For this to work, the linker needs to be able to inspect the reference
graphs for bitcode modules and the module summary provides exactly that.