diff options
author | Ayke van Laethem <[email protected]> | 2024-05-18 12:55:35 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2024-05-24 19:12:26 +0200 |
commit | 81ce7fb738142361afba119f1f531cf6ffddc6d1 (patch) | |
tree | 68559a44ba49457b5ef9a5f2381fab1eae0276ff /transform | |
parent | c2776dcf78125abb86e3e7b4a110bb0d07386d09 (diff) | |
download | tinygo-81ce7fb738142361afba119f1f531cf6ffddc6d1.tar.gz tinygo-81ce7fb738142361afba119f1f531cf6ffddc6d1.zip |
LLVM 18 support
Diffstat (limited to 'transform')
-rw-r--r-- | transform/optimizer.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/transform/optimizer.go b/transform/optimizer.go index 4c0ccfc2e..05533b6a4 100644 --- a/transform/optimizer.go +++ b/transform/optimizer.go @@ -8,6 +8,7 @@ import ( "github.com/tinygo-org/tinygo/compileopts" "github.com/tinygo-org/tinygo/compiler/ircheck" + "github.com/tinygo-org/tinygo/compiler/llvmutil" "tinygo.org/x/go-llvm" ) @@ -52,7 +53,12 @@ func Optimize(mod llvm.Module, config *compileopts.Config) []error { // Run some preparatory passes for the Go optimizer. po := llvm.NewPassBuilderOptions() defer po.Dispose() - err := mod.RunPasses("globaldce,globalopt,ipsccp,instcombine,adce,function-attrs", llvm.TargetMachine{}, po) + optPasses := "globaldce,globalopt,ipsccp,instcombine<no-verify-fixpoint>,adce,function-attrs" + if llvmutil.Version() < 18 { + // LLVM 17 doesn't have the no-verify-fixpoint flag. + optPasses = "globaldce,globalopt,ipsccp,instcombine,adce,function-attrs" + } + err := mod.RunPasses(optPasses, llvm.TargetMachine{}, po) if err != nil { return []error{fmt.Errorf("could not build pass pipeline: %w", err)} } @@ -75,7 +81,7 @@ func Optimize(mod llvm.Module, config *compileopts.Config) []error { // After interfaces are lowered, there are many more opportunities for // interprocedural optimizations. To get them to work, function // attributes have to be updated first. - err = mod.RunPasses("globaldce,globalopt,ipsccp,instcombine,adce,function-attrs", llvm.TargetMachine{}, po) + err = mod.RunPasses(optPasses, llvm.TargetMachine{}, po) if err != nil { return []error{fmt.Errorf("could not build pass pipeline: %w", err)} } |