[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?
半缘君 via llvm-dev
llvm-dev at lists.llvm.org
Thu Sep 24 16:38:43 PDT 2020
Hi Teresa:
Thank you, It's very help for me.
ZhengxianLi
------------------ 原始邮件 ------------------
发件人: "Teresa Johnson" <tejohnson at google.com>;
发送时间: 2020年9月24日(星期四) 晚上11:20
收件人: "半缘君"<eng.lzx at foxmail.com>;
抄送: "llvm-dev"<llvm-dev at lists.llvm.org>;
主题: Re: [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?
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/20200925/c5b309d6/attachment.html>
More information about the llvm-dev
mailing list