Repository navigation
cmd/compile: run FullLTO pre-link optimization before bitcode emission - #356
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LTO package compilation currently serializes prepared but unoptimized IR. Run LLVM's
lto-pre-link<O2>pipeline before writing the package bitcode, leaving whole-programlto<O2>and late pre-codegen lowering to the linker. Ordinary object compilation keeps its existing O0/O2 selection.The change reuses the compiler's existing optimization path. With
-llvm-keep-ir,.raw.llremains the frontend snapshot,.llremains prepared IR, and.opt.llnow records the pre-link optimized LTO input. Verify the optimized module before serialization. Existing unsupported-flag checks remain unchanged.The amd64/arm64 archive regression disables inlining and verifies that LLVM constant propagation removes a pure package-local call before bitcode serialization, while both definitions retain their original package symbol indices and the archive's export data remains usable. This regression fails against #355 before the change. Focused emission, early IR, optimization-mode and flag-rejection tests pass; ordinary CPU/FMV runtime behavior also passes.
End-to-end validation uses a separate checkout combining this patch with #347; the production PR remains based directly on the merged #355 commit
8053408d154c. The FullLTO CPU/FMV runtime and complete integration suite pass (265.422s), including content hashing, assembly, cache reuse, GC/stack growth, reflection, traceback, logical DWARF packages, linkname positive/negative cases, mixed ordinary objects, PIE and cgo automatic/external linking.Performance qualification is still open. One macOS arm64 sample of the 45-package runtime fixture, with package caches warmed and the link forced fresh, gave:
This is a single sample, not a statistical benchmark or a measured general speedup. The size increase is a reason to keep this PR in draft for review. There are no custom LLVM pass lists or relaxed Go symbol-identity checks.
Builds on #355; companion to #347. Do not merge automatically.