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.
(fn llvm.Value, config *compileopts.Config)
| 21 | // attributes to a function. For example, it adds optsize when requested from |
| 22 | // the -opt= compiler flag. |
| 23 | func AddStandardAttributes(fn llvm.Value, config *compileopts.Config) { |
| 24 | ctx := fn.Type().Context() |
| 25 | _, _, sizeLevel := config.OptLevel() |
| 26 | if sizeLevel >= 1 { |
| 27 | fn.AddFunctionAttr(ctx.CreateEnumAttribute(llvm.AttributeKindID("optsize"), 0)) |
| 28 | } |
| 29 | if sizeLevel >= 2 { |
| 30 | fn.AddFunctionAttr(ctx.CreateEnumAttribute(llvm.AttributeKindID("minsize"), 0)) |
| 31 | } |
| 32 | if config.CPU() != "" { |
| 33 | fn.AddFunctionAttr(ctx.CreateStringAttribute("target-cpu", config.CPU())) |
| 34 | } |
| 35 | if config.Features() != "" { |
| 36 | fn.AddFunctionAttr(ctx.CreateStringAttribute("target-features", config.Features())) |
| 37 | } |
| 38 | } |
no test coverage detected