Hi ZhengXianLi,
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:
To run them with regular LTO instead of ThinLTO, just remove the -module-summary from the opt invocations.
but they don't get into the details of the code implementation.
Hope that helps,
Teresa