davidlattimore / wild

Apache License 2.0
468 stars 11 forks source link

About LTO #1

Open bjorn3 opened 7 months ago

bjorn3 commented 7 months ago

In the readme you said

What isn't yet supported?

  • [...]
  • LTO - although it's not clear that this is practical to be done incrementally
  • [...]

I've got two comments about this:

For rust specifically, LTO is normally done by rustc rather than the linker, so it would already work with wild. For C or when using -Clinker-plugin-lto with rustc (normally used for cross-language lto), wild would indeed need to add LTO support.

It is possible to do LTO incrementally. In fact ThinLTO already supports incremental optimizations and rustc wires this up to incr comp if you enable both ThinLTO and incr comp at the same time. ThinLTO works by first doing a small optimization pass on individual codegen units and extracting a "summary" from each codegen unit (done in parallel), merging all summaries together (serial step) and finally optimizing every codegen unit based on the information in the summary (done in parallel). LLVM is able to determine if a codegen unit would be affected by any given change in the summaries and if not the optimized version from the previous compilation of this codegen unit can be reused.

bjorn3 commented 7 months ago

In any case good luck with this project!