From 5af4b3487011f8e88accf06131c3f6e64e58cb2a Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Fri, 11 Aug 2023 15:16:12 -0700 Subject: [PATCH] cmd/compile: move IsDeadcodeClosure check into enqueueFunc Keeps the top-level loop in Main slightly cleaner. Change-Id: I9c8d38d4bbb34d53edc0796893534763e9eef2f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/518957 Run-TryBot: Matthew Dempsky Auto-Submit: Matthew Dempsky TryBot-Result: Gopher Robot Reviewed-by: Cuong Manh Le Reviewed-by: Than McIntosh --- src/cmd/compile/internal/gc/compile.go | 5 +++++ src/cmd/compile/internal/gc/main.go | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cmd/compile/internal/gc/compile.go b/src/cmd/compile/internal/gc/compile.go index 4795297e7e..47cc71df1e 100644 --- a/src/cmd/compile/internal/gc/compile.go +++ b/src/cmd/compile/internal/gc/compile.go @@ -39,6 +39,11 @@ func enqueueFunc(fn *ir.Func) { return } + // Don't try compiling dead hidden closure. + if fn.IsDeadcodeClosure() { + return + } + if clo := fn.OClosure; clo != nil && !ir.IsTrivialClosure(clo) { return // we'll get this as part of its enclosing function } diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 94043719aa..4d28504360 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -304,10 +304,6 @@ func Main(archInit func(*ssagen.ArchInfo)) { fcount := int64(0) for i := 0; i < len(typecheck.Target.Funcs); i++ { fn := typecheck.Target.Funcs[i] - // Don't try compiling dead hidden closure. - if fn.IsDeadcodeClosure() { - continue - } enqueueFunc(fn) fcount++ } -- 2.50.0