File tree Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -865,6 +865,10 @@ func (c *Compiler) parseFunc(frame *Frame) {
865
865
// Add LLVM inline hint to functions with //go:inline pragma.
866
866
inline := c .ctx .CreateEnumAttribute (llvm .AttributeKindID ("inlinehint" ), 0 )
867
867
frame .fn .LLVMFn .AddFunctionAttr (inline )
868
+ case ir .InlineNone :
869
+ // Add LLVM attribute to always avoid inlining this function.
870
+ noinline := c .ctx .CreateEnumAttribute (llvm .AttributeKindID ("noinline" ), 0 )
871
+ frame .fn .LLVMFn .AddFunctionAttr (noinline )
868
872
}
869
873
870
874
// Add debug info, if needed.
Original file line number Diff line number Diff line change @@ -56,6 +56,10 @@ const (
56
56
// //go:inline). The compiler will be more likely to inline this function,
57
57
// but it is not a guarantee.
58
58
InlineHint
59
+
60
+ // Don't inline, just like the GCC noinline attribute. Signalled using
61
+ // //go:noinline.
62
+ InlineNone
59
63
)
60
64
61
65
// Create and initialize a new *Program from a *ssa.Program.
@@ -227,6 +231,8 @@ func (f *Function) parsePragmas() {
227
231
f .exported = true
228
232
case "//go:inline" :
229
233
f .inline = InlineHint
234
+ case "//go:noinline" :
235
+ f .inline = InlineNone
230
236
case "//go:interrupt" :
231
237
if len (parts ) != 2 {
232
238
continue
Original file line number Diff line number Diff line change @@ -203,6 +203,7 @@ func init() {
203
203
204
204
// alloc tries to find some free space on the heap, possibly doing a garbage
205
205
// collection cycle if needed. If no space is free, it panics.
206
+ //go:noinline
206
207
func alloc (size uintptr ) unsafe.Pointer {
207
208
if size == 0 {
208
209
return unsafe .Pointer (& zeroSizedAlloc )
You can’t perform that action at this time.
0 commit comments