Add basic LLVM support for the -fthinlto option, which will
be passed to LLVM via the EmitThinLTOIndex code gen option. This will
be used to guard the ThinLTO bitcode writing in WriteModule shown in
|132 ↗||(On Diff #31676)|
I experimented with a large source file (>400K loc, >51K functions), and measured how long it took to skip all blocks/records and just check whether it contained a thinlto block. It was negligible (~0.1s), so I think this is the way to go. I will update the patch to remove the change to gold-plugin.cpp and the change to pass in the new plugin option.
It seems a bit intrusive to make the BitcodeWriter aware of LTO. It seems you want it to handle your specific information at the end of a module block right?
Can we have a generic hook mechanism? For instance, we might provide a std::function callback instead of this ad-hoc boolean.
Interesting idea. The boolean is passed down from clang (based on the -fthinlto option) when it calls createBitcodeWriterPass. I'm trying to envision how a callback would work - I guess save the bool passed from clang on the WriteBitcodePass object (as it is already done in this patch), and then have a static WriteBitcodePass method that returns the bool value? But then we would need to pass this function into WriteBitcodeToFile as a std::function, and that would have to be passed down to WriteModule (instead of the bool) and invoked there. Am I missing a better way to do this via a callback? It seems like we end up either passing down a bool or a std::function callback.
Will upload new patch in a min that updates doxygen.