mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 13:33:39 +00:00
compiler: add minsize attribute for -Oz
This matches the behavior of Clang, which uses optsize for -Os and adds minsize for -Oz. The code size change is all over the map, but using a hacked together size comparison tool I've found that there is a slight reduction in binary size overall (-1.6% with the tinygo smoke tests and -0.8% for the drivers smoke test).
This commit is contained in:
committed by
Ron Evans
parent
d7b7583e83
commit
7c24925aa7
@@ -22,7 +22,10 @@ import (
|
||||
// the -opt= compiler flag.
|
||||
func AddStandardAttributes(fn llvm.Value, config *compileopts.Config) {
|
||||
_, sizeLevel, _ := config.OptLevels()
|
||||
if sizeLevel >= 2 {
|
||||
if sizeLevel >= 1 {
|
||||
fn.AddFunctionAttr(fn.Type().Context().CreateEnumAttribute(llvm.AttributeKindID("optsize"), 0))
|
||||
}
|
||||
if sizeLevel >= 2 {
|
||||
fn.AddFunctionAttr(fn.Type().Context().CreateEnumAttribute(llvm.AttributeKindID("minsize"), 0))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user