[GSoC] LTO support progress report

I'm working on the GSoC project LTO support for Swift with @compnerd.

Here is my implementation plan for this project.

I'll post a weekly progress report every Monday as @augusto2112 does on GSOC Linux debugger support progress report.

Until now, I've worked on the following things.

  • Addressed code review comments by @compnerd for apple/swift#31146 and spent much time on retrying CI.
  • Reading LLD and Swift codebase to get a deeper understanding of each architecture.
  • Start implementing libswiftLTO pipeline (WIP)

I'm spending much time to investigate which information in ASTContext is required after SILGen.

Since ASTContext is used through the compiler process, it has so much information. But LTO plugin is used in linker process, so it can't derive ASTContext state from the compiler process and needs to create and setup ASTContext again.

For this reason, I'm investigating which information in ASTContext should be serialized in SIB.

13 Likes

Thanks for the update and sharing the detailed plan @kateinoigakukun. I can't wait to have proper LTO working for all platforms that Swift supports and producing smaller Swift binaries! (Especially as this is critical for the WebAssembly target).

After #31146 is merged, as far as I understand one could start using the -lto=llvm flag with the master nightlies. Or would it need lld built in some special way? Also, does it already yield some reductions in size of produced binaries, or do we need to wait for language-specific LTO to kick in to start seeing any noticeable reduction?

1 Like

After #31146 is merged, as far as I understand one could start using the -lto=llvm flag with the master nightlies. Or would it need lld built in some special way? Also, does it already yield some reductions in size of produced binaries, or do we need to wait for language-specific LTO to kick in to start seeing any noticeable reduction?

@Max_Desiatov wasm-ld already support bitcode LTO, so we can use it without special work after the PR merged. And I've not tried yet for wasm but I think llvm level lto can reduce size of produced binaries more than wasm-opt can.

2 Likes

You may also want to investigate the existing -function-sections flag which will allow you to drop unused functions as on MachO and PE/COFF targets.

2 Likes

Hey everyone!

Last week, I opened a PR to bootstrap LTO pipeline in the compiler side. It contains a very basis for transforming SIL into LLVM IR and does not contain any optimization at this time.

(And I'm sorry that I couldn't do a lot of things for GSoC because of too many assignments from my university.)

This week, I'll address the reviewed points of the PR and fix some remaining issues.

One of the issues is that my current implementation depends on the order of input modules.

In the usual compiler process, all dependent modules are loaded by need after the main module that uses them.

On the other hand, the current implementation load the input module immediately, so it depends on the order of input modules and fails if the dependent libraries are not loaded before user-module.
So I need to implement lazy module loading mechanism for serialized on memory modules.

4 Likes

Hello :wave:

Last week, I made some PRs to extend SIL pass manager to be available for multiple modules optimization.

But due to some regression, #32237 was reverted.

This week I'll focus these PRs get to be merged.

3 Likes

Hello everyone.

Last week, I split the LLVM LTO changes into several PRs to get it back to master.

But they are still in review. I hope we'll be able to merge them this week.

1 Like

Hello.

Since last week, I'm prototyping michael's architecture for further discussion. The architecture is similar to LLVM thin LTO.

#32462 was merged into master and #32429 is almost ready to merge.

I couldn't spend much time last week since I was not feeling well, but it got to be better now.

This week, I'll continue to prototype the architecture and work on merging the remaining LLVM LTO PRs.

6 Likes
Terms of Service

Privacy Policy

Cookie Policy