mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-11 14:33:41 +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
@@ -6,6 +6,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/tinygo-org/tinygo/compileopts"
|
||||
"tinygo.org/x/go-llvm"
|
||||
)
|
||||
|
||||
@@ -22,7 +23,7 @@ import (
|
||||
// simply call the registered handlers. This might seem like it causes extra
|
||||
// overhead, but in fact inlining and const propagation will eliminate most if
|
||||
// not all of that.
|
||||
func LowerInterrupts(mod llvm.Module, sizeLevel int) []error {
|
||||
func LowerInterrupts(mod llvm.Module, config *compileopts.Config) []error {
|
||||
var errs []error
|
||||
|
||||
// Discover interrupts. The runtime/interrupt.Register call is a compiler
|
||||
@@ -174,9 +175,7 @@ func LowerInterrupts(mod llvm.Module, sizeLevel int) []error {
|
||||
// Create the wrapper function which is the actual interrupt handler
|
||||
// that is inserted in the interrupt vector.
|
||||
fn.SetUnnamedAddr(true)
|
||||
if sizeLevel >= 2 {
|
||||
fn.AddFunctionAttr(ctx.CreateEnumAttribute(llvm.AttributeKindID("optsize"), 0))
|
||||
}
|
||||
AddStandardAttributes(fn, config)
|
||||
fn.SetSection(".text." + name)
|
||||
if isSoftwareVectored {
|
||||
fn.SetLinkage(llvm.InternalLinkage)
|
||||
|
||||
Reference in New Issue
Block a user