tinygo/transform/maps_test.go
Ayke van Laethem 3b1913ac57 all: use the new LLVM pass manager
The old LLVM pass manager is deprecated and should not be used anymore.
Moreover, the pass manager builder (which we used to set up a pass
pipeline) is actually removed from LLVM entirely in LLVM 17:
https://reviews.llvm.org/D145387
https://reviews.llvm.org/D145835

The new pass manager does change the binary size in many cases: both
growing and shrinking it. However, on average the binary size remains
more or less the same.

This is needed as a preparation for LLVM 17.
2023-10-04 13:05:58 +02:00

25 строки
598 Б
Go

package transform_test
import (
"testing"
"github.com/tinygo-org/tinygo/transform"
"tinygo.org/x/go-llvm"
)
func TestOptimizeMaps(t *testing.T) {
t.Parallel()
testTransform(t, "testdata/maps", func(mod llvm.Module) {
// Run optimization pass.
transform.OptimizeMaps(mod)
// Run an optimization pass, to clean up the result.
// This shows that all code related to the map is really eliminated.
po := llvm.NewPassBuilderOptions()
defer po.Dispose()
err := mod.RunPasses("dse,adce", llvm.TargetMachine{}, po)
if err != nil {
t.Error("failed to run passes:", err)
}
})
}