mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-17 11:13:27 +00:00
compiler: refactor when the optsize attribute is set
This commit has a few related changes:
* It sets the optsize attribute immediately in the compiler instead of
adding it to each function afterwards in a loop. This seems to me
like the more appropriate way to do it.
* It centralizes setting the optsize attribute in the transform
package, to make later changes easier.
* It sets the optsize in a few more places: to runtime.initAll and to
WebAssembly i64 wrappers.
This commit does not affect the binary size of any of the smoke tests,
so should be risk-free.
This commit is contained in:
committed by
Ron Evans
parent
1869efe954
commit
d7b7583e83
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/tinygo-org/tinygo/compileopts"
|
||||
"tinygo.org/x/go-llvm"
|
||||
)
|
||||
|
||||
@@ -15,7 +16,7 @@ import (
|
||||
//
|
||||
// This pass can be enabled/disabled with the -wasm-abi flag, and is enabled by
|
||||
// default as of december 2019.
|
||||
func ExternalInt64AsPtr(mod llvm.Module) error {
|
||||
func ExternalInt64AsPtr(mod llvm.Module, config *compileopts.Config) error {
|
||||
ctx := mod.Context()
|
||||
builder := ctx.NewBuilder()
|
||||
defer builder.Dispose()
|
||||
@@ -79,10 +80,7 @@ func ExternalInt64AsPtr(mod llvm.Module) error {
|
||||
fn.SetName(name + "$i64wrap")
|
||||
externalFnType := llvm.FunctionType(returnType, paramTypes, fnType.IsFunctionVarArg())
|
||||
externalFn := llvm.AddFunction(mod, name, externalFnType)
|
||||
optsize := fn.GetEnumFunctionAttribute(llvm.AttributeKindID("optsize"))
|
||||
if !optsize.IsNil() {
|
||||
fn.AddFunctionAttr(optsize)
|
||||
}
|
||||
AddStandardAttributes(fn, config)
|
||||
|
||||
if fn.IsDeclaration() {
|
||||
// Just a declaration: the definition doesn't exist on the Go side
|
||||
|
||||
Reference in New Issue
Block a user