[llvm-dev] How lld invoke LTO or thinLTO and is there some cases and some method to get the step-by-step message for me to understand how LTO worked?
Teresa Johnson via llvm-dev
llvm-dev at lists.llvm.org
Thu Sep 24 08:20:40 PDT 2020
Hi ZhengXianLi,
The main entry point into the LTO LLVM code from lld is in
https://github.com/llvm/llvm-project/blob/master/lld/ELF/LTO.cpp.
Specifically see the call to ltoObj->run which launches the main LTO
handling after all of the setup here:
https://github.com/llvm/llvm-project/blob/master/lld/ELF/LTO.cpp#L309. Most
of the actual LTO handling is in the LLVM LTO code here:
https://github.com/llvm/llvm-project/blob/master/llvm/lib/LTO/LTO.cpp
and here:
https://github.com/llvm/llvm-project/blob/master/llvm/lib/LTO/LTOBackend.cpp
Note there is an old LTO API implementation in LTOModule.cpp and
*LTOCodeGenerator.cpp that is not used by lld, gold or bfd (just ld64 and
some custom linkers nowadays that haven't yet migrated). The newer LTO API
implementation in LTO.cpp and LTOBackend.cpp relies on linker resolutions
passed by lld (or gold/bfd via gold-plugin.cpp) via that lld file I pointed
to.
The following lld test contain some simple test cases for thinLTO:
https://github.com/llvm/llvm-project/blob/master/lld/test/ELF/lto/thinlto.ll
To run them with regular LTO instead of ThinLTO, just remove the
-module-summary from the opt invocations.
There's clang documentation on ThinLTO here:
https://clang.llvm.org/docs/ThinLTO.html
and an old blog post on ThinLTO here:
https://blog.llvm.org/posts/2016-06-21-thinlto-scalable-and-incremental-lto/
but they don't get into the details of the code implementation.
Hope that helps,
Teresa
On Thu, Sep 24, 2020 at 7:43 AM 半缘君 via llvm-dev <llvm-dev at lists.llvm.org>
wrote:
> Hi:
> I want to learn how LTO and thinLTO work? But I'm confused how lld
> invoked either library. How can I find it in lld. Should i be familiar with
> lld source code? And i also think if there is some easy test case and with
> step-by- step debugging or some log messages can help me learn this? Is
> there some method can do stuff like this?
> Thank you very much.
> ZhengXianLi
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
--
Teresa Johnson | Software Engineer | tejohnson at google.com |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200924/04035dfe/attachment-0001.html>
More information about the llvm-dev
mailing list