From 352d76b2912b20ede8b3238fc2ed7b697bc2695b Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 8 Apr 2026 19:47:28 +0700 Subject: cmd/compile: remove unused inNonInitFunction context CL 737821 removed the last functional use of inNonInitFunction. This field and its associated logic are now dead code and can be safely deleted. Change-Id: I4023ec7ef5d10c94ef54b9726f18cda863ee2ff4 Reviewed-on: https://go-review.googlesource.com/c/go/+/764020 LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall Reviewed-by: David Chase Auto-Submit: Cuong Manh Le Reviewed-by: Keith Randall --- src/cmd/compile/internal/walk/complit.go | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/compile/internal/walk/complit.go b/src/cmd/compile/internal/walk/complit.go index e0ffca86ce..1d66ecde82 100644 --- a/src/cmd/compile/internal/walk/complit.go +++ b/src/cmd/compile/internal/walk/complit.go @@ -246,19 +246,8 @@ func fixedlit(ctxt initContext, kind initKind, n *ir.CompLitExpr, var_ ir.Node, switch value.Op() { case ir.OSLICELIT: value := value.(*ir.CompLitExpr) - if (kind == initKindStatic && ctxt == inNonInitFunction) || (kind == initKindDynamic && ctxt == inInitFunction) { - var sinit ir.Nodes - slicelit(ctxt, value, a, &sinit) - if kind == initKindStatic { - // When doing static initialization, init statements may contain dynamic - // expression, which will be initialized later, causing liveness analysis - // confuses about variables lifetime. So making sure those expressions - // are ordered correctly here. See issue #52673. - orderBlock(&sinit, map[string][]*ir.Name{}) - typecheck.Stmts(sinit) - walkStmtList(sinit) - } - init.Append(sinit...) + if kind == initKindDynamic && ctxt == inInitFunction { + slicelit(ctxt, value, a, init) continue } @@ -302,23 +291,6 @@ func slicelit(ctxt initContext, n *ir.CompLitExpr, var_ ir.Node, init *ir.Nodes) t := types.NewArray(n.Type().Elem(), n.Len) types.CalcSize(t) - if ctxt == inNonInitFunction { - // put everything into static array - vstat := staticinit.StaticName(t) - - fixedlit(ctxt, initKindStatic, n, vstat, init) - fixedlit(ctxt, initKindDynamic, n, vstat, init) - - // copy static to slice - var_ = typecheck.AssignExpr(var_) - name, offset, ok := staticinit.StaticLoc(var_) - if !ok || name.Class != ir.PEXTERN { - base.Fatalf("slicelit: %v", var_) - } - staticdata.InitSlice(name, offset, vstat.Linksym(), t.NumElem()) - return - } - // recipe for var = []t{...} // 1. make a static array // var vstat [...]t -- cgit v1.3-5-g9baa