mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 21:43:40 +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
@@ -11,3 +11,18 @@
|
||||
// lowering pass, which replaces stub runtime calls to get an interface method
|
||||
// with the method implementation (either a direct call or a thunk).
|
||||
package transform
|
||||
|
||||
import (
|
||||
"github.com/tinygo-org/tinygo/compileopts"
|
||||
"tinygo.org/x/go-llvm"
|
||||
)
|
||||
|
||||
// AddStandardAttributes is a helper function to add standard function
|
||||
// attributes to a function. For example, it adds optsize when requested from
|
||||
// the -opt= compiler flag.
|
||||
func AddStandardAttributes(fn llvm.Value, config *compileopts.Config) {
|
||||
_, sizeLevel, _ := config.OptLevels()
|
||||
if sizeLevel >= 2 {
|
||||
fn.AddFunctionAttr(fn.Type().Context().CreateEnumAttribute(llvm.AttributeKindID("optsize"), 0))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user