File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -251,10 +251,14 @@ func (c *compilerContext) getFunctionInfo(f *ssa.Function) functionInfo {
251
251
// parsePragmas is used by getFunctionInfo to parse function pragmas such as
252
252
// //export or //go:noinline.
253
253
func (info * functionInfo ) parsePragmas (f * ssa.Function ) {
254
- if f .Syntax () == nil {
254
+ syntax := f .Syntax ()
255
+ if f .Origin () != nil {
256
+ syntax = f .Origin ().Syntax ()
257
+ }
258
+ if syntax == nil {
255
259
return
256
260
}
257
- if decl , ok := f . Syntax () .(* ast.FuncDecl ); ok && decl .Doc != nil {
261
+ if decl , ok := syntax .(* ast.FuncDecl ); ok && decl .Doc != nil {
258
262
259
263
// Our importName for a wasm module (if we are compiling to wasm), or llvm link name
260
264
var importName string
Original file line number Diff line number Diff line change @@ -48,6 +48,22 @@ func inlineFunc() {
48
48
func noinlineFunc () {
49
49
}
50
50
51
+ type Int interface {
52
+ int8 | int16
53
+ }
54
+
55
+ // Same for generic functions (but the compiler may miss the pragma due to it
56
+ // being generic).
57
+ //
58
+ //go:noinline
59
+ func noinlineGenericFunc [T Int ]() {
60
+ }
61
+
62
+ func useGeneric () {
63
+ // Make sure the generic function above is instantiated.
64
+ noinlineGenericFunc [int8 ]()
65
+ }
66
+
51
67
// This function should have the specified section.
52
68
//
53
69
//go:section .special_function_section
Original file line number Diff line number Diff line change @@ -48,6 +48,19 @@ entry:
48
48
ret void
49
49
}
50
50
51
+ ; Function Attrs: nounwind
52
+ define hidden void @main.useGeneric (ptr %context ) unnamed_addr #2 {
53
+ entry:
54
+ call void @"main.noinlineGenericFunc[int8]" (ptr undef )
55
+ ret void
56
+ }
57
+
58
+ ; Function Attrs: noinline nounwind
59
+ define linkonce_odr hidden void @"main.noinlineGenericFunc[int8]" (ptr %context ) unnamed_addr #5 {
60
+ entry:
61
+ ret void
62
+ }
63
+
51
64
; Function Attrs: noinline nounwind
52
65
define hidden void @main.functionInSection (ptr %context ) unnamed_addr #5 section ".special_function_section" {
53
66
entry:
You can’t perform that action at this time.
0 commit comments