You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context: I am adding additional information to runtime.inlinedCall (function start line), which I am plumbing via the FuncInfo. In the linker, thisFuncInfo.Valid() got me thinking that (IMO) inlined functions ought to always have a FuncInfo, since they must be Go functions, so I switched the check to panic if it is missing.
The first closure (fn) has a FuncInfo, but the second does not. This seems like a bug to me, though it probably had low impact before because FuncID would default to FuncID_normal anyways.
I am still digging, but it looks like this is somewhere in the compiler, as func2 never makes it to ssagen.InitLSym, which sets up the FuncInfo.
Note to self: enqueueFunc skips both func1 and func2 because they aren't trivial closures. When enqueueing main.main, the later loop prepares func1, but for some reason func2 never ends up in next.Closures.
@prattmic Without looking too closely, I think it's because the directly called closure gets inlined and then we know there won't be any other references to it, so we intentionally drop references to it from the AST because we know we don't need to compile its function body on its own. (Contrast that the indirectly called closure gets inlined too, but we don't do any frontend analysis to realize that was the only possible use.)
Activity
prattmic commentedon Sep 8, 2022
Note to self:
enqueueFuncskips both func1 and func2 because they aren't trivial closures. When enqueueingmain.main, the later loop prepares func1, but for some reason func2 never ends up innext.Closures.mdempsky commentedon Sep 8, 2022
@prattmic Without looking too closely, I think it's because the directly called closure gets inlined and then we know there won't be any other references to it, so we intentionally drop references to it from the AST because we know we don't need to compile its function body on its own. (Contrast that the indirectly called closure gets inlined too, but we don't do any frontend analysis to realize that was the only possible use.)
cuonglm commentedon Sep 9, 2022
The place where the direct call closure is replaced: https://cs.opensource.google/go/go/+/refs/tags/go1.19.1:src/cmd/compile/internal/inline/inl.go;l=596
Maybe we can mark it as need lsym and call ssagen.IniLSym in enqueueFunc if the closure was marked.
gopherbot commentedon Sep 9, 2022
Change https://go.dev/cl/429637 mentions this issue:
cmd/link/internal/ld: panic if inlined functions missing funcinfogopherbot commentedon Sep 29, 2022
Change https://go.dev/cl/436240 mentions this issue:
cmd/compile: eagerly create LSym for closurescmd/link/internal/ld: panic if inlined functions missing FuncInfo
cmd/compile: eagerly create LSym for closures