From 97842b367c0fc92499f73b9b63014247906f9190 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 30 May 2022 14:55:14 +0200 Subject: [PATCH] transform: run OptimizeMaps during package optimizations This shrinks transform.Optimize() a little bit, working towards the goal of https://github.com/tinygo-org/tinygo/issues/2870. I ran the smoke tests and there is no practical downside: one test got smaller (??) and one had a different .hex hash, but other than that there was no difference. This should also make TinyGo a liiitle bit faster but it's probably not even measurable. --- transform/optimizer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/transform/optimizer.go b/transform/optimizer.go index 66ad43f4ba..e688a53947 100644 --- a/transform/optimizer.go +++ b/transform/optimizer.go @@ -37,6 +37,11 @@ func OptimizePackage(mod llvm.Module, config *compileopts.Config) { funcPasses.RunFunc(fn) } funcPasses.FinalizeFunc() + + // Run TinyGo-specific optimization passes. + if optLevel > 0 { + OptimizeMaps(mod) + } } // Optimize runs a number of optimization and transformation passes over the @@ -92,7 +97,6 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i goPasses.Run(mod) // Run TinyGo-specific optimization passes. - OptimizeMaps(mod) OptimizeStringToBytes(mod) OptimizeReflectImplements(mod) OptimizeAllocs(mod, nil, nil)