mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 05:53:39 +00:00
builder: add optsize attribute while building the package
This simplifies future changes. While the move itself is very simple, it required some other changes to a few transforms that create new functions to add the optsize attribute manually. It also required abstracting away the optimization level flags (based on the -opt flag) so that it can easily be retrieved from the config object. This commit does not impact binary size on baremetal and WebAssembly. I've seen a few tests on linux/amd64 grow slightly in size, but I'm not too worried about those.
This commit is contained in:
committed by
Ron Evans
parent
fa6c1b69ce
commit
49ec3eb58e
@@ -22,7 +22,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) []error {
|
||||
func LowerInterrupts(mod llvm.Module, sizeLevel int) []error {
|
||||
var errs []error
|
||||
|
||||
// Discover interrupts. The runtime/interrupt.Register call is a compiler
|
||||
@@ -182,6 +182,9 @@ func LowerInterrupts(mod llvm.Module) []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))
|
||||
}
|
||||
fn.SetSection(".text." + name)
|
||||
if isSoftwareVectored {
|
||||
fn.SetLinkage(llvm.InternalLinkage)
|
||||
|
||||
Reference in New Issue
Block a user