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
http://reviews.llvm.org/D11722.
Details
- Reviewers
• rafael dexonsmith
Diff Detail
Event Timeline
tools/gold/gold-plugin.cpp | ||
---|---|---|
132 ↗ | (On Diff #31676) | Do we need a new plugin option? Would it not be possible to determine whether ThinLTO is needed by reading the intermediate files? |
tools/gold/gold-plugin.cpp | ||
---|---|---|
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.
include/llvm/Bitcode/BitcodeWriterPass.h | ||
---|---|---|
37 | Update doxygen? | |
include/llvm/Bitcode/ReaderWriter.h | ||
74 | ditto. |
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.
include/llvm/Bitcode/BitcodeWriterPass.h | ||
---|---|---|
37 | Will upload new patch in a min that updates doxygen. |
Update doxygen?