aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-07-28 10:48:31 +0200
committerAyke <[email protected]>2024-07-31 21:07:20 +0200
commit84c376160f7a127d1beecf3f09f0f8e5caff641c (patch)
treec68b3cbb0d37c5cf5736f78be1219e0fa7fa7214
parent6184a6cd35d04dac86e1cbb33bef686c9d7087de (diff)
downloadtinygo-84c376160f7a127d1beecf3f09f0f8e5caff641c.tar.gz
tinygo-84c376160f7a127d1beecf3f09f0f8e5caff641c.zip
transform: use thinlto-pre-link passes
This improves compilation performance by about 5% in my quick test, while increasing binary size on average by 0.13% when comparing the smoke tests in the drivers repo (and about two thirds of that 0.13% is actually caused by a single smoke test). I think this is a good idea because it aligns the TinyGo optimization sequence with what ThinLTO expects.
-rw-r--r--transform/optimizer.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/transform/optimizer.go b/transform/optimizer.go
index 05533b6a4..54f9762bc 100644
--- a/transform/optimizer.go
+++ b/transform/optimizer.go
@@ -142,11 +142,13 @@ func Optimize(mod llvm.Module, config *compileopts.Config) []error {
fn.SetLinkage(llvm.InternalLinkage)
}
- // Run the default pass pipeline.
- // TODO: set the PrepareForThinLTO flag somehow.
+ // Run the ThinLTO pre-link passes, meant to be run on each individual
+ // module. This saves compilation time compared to "default<#>" and is meant
+ // to better match the optimization passes that are happening during
+ // ThinLTO.
po := llvm.NewPassBuilderOptions()
defer po.Dispose()
- passes := fmt.Sprintf("default<%s>", optLevel)
+ passes := fmt.Sprintf("thinlto-pre-link<%s>", optLevel)
err := mod.RunPasses(passes, llvm.TargetMachine{}, po)
if err != nil {
return []error{fmt.Errorf("could not build pass pipeline: %w", err)}