mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 21:43:40 +00:00
LLVM 18 support
This commit is contained in:
committed by
Ron Evans
parent
c2776dcf78
commit
81ce7fb738
@@ -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)}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user