diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index c1f51e4f1d..2ea614e17f 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -213,6 +213,14 @@ func Main(archInit func(*ssagen.ArchInfo)) { typecheck.Export(initTask) } + // Eliminate some obviously dead code. + // Must happen after typechecking. + for _, n := range typecheck.Target.Decls { + if n.Op() == ir.ODCLFUNC { + deadcode.Func(n.(*ir.Func)) + } + } + // Compute Addrtaken for names. // We need to wait until typechecking is done so that when we see &x[i] // we know that x has its address taken if x is an array, but not if x is a slice. @@ -224,14 +232,6 @@ func Main(archInit func(*ssagen.ArchInfo)) { } typecheck.IncrementalAddrtaken = true - // Eliminate some obviously dead code. - // Must happen after typechecking. - for _, n := range typecheck.Target.Decls { - if n.Op() == ir.ODCLFUNC { - deadcode.Func(n.(*ir.Func)) - } - } - // Decide how to capture closed variables. // This needs to run before escape analysis, // because variables captured by value do not escape.