From 569def31fae0bc5f6a6868a50160da77e6e5c27a Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Thu, 17 Aug 2023 22:04:49 -0700 Subject: [PATCH] cmd/compile: prune some deadcode around ODCLFUNC An *ir.Func is always ODCLFUNC, so no need to double-check this anymore. The type system statically ensures we have the right Op. Also, pkginit.initRequiredForCoverage appears to be unused, so we can get rid of it completely. Change-Id: If1abb35672b40f705f23c365ad2a828c2661e9c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/520603 Run-TryBot: Matthew Dempsky TryBot-Result: Gopher Robot Reviewed-by: Cuong Manh Le Auto-Submit: Matthew Dempsky Reviewed-by: Dmitri Shuralyov --- src/cmd/compile/internal/escape/escape.go | 6 ------ src/cmd/compile/internal/pkginit/init.go | 15 --------------- src/cmd/compile/internal/ssagen/nowb.go | 3 --- 3 files changed, 24 deletions(-) diff --git a/src/cmd/compile/internal/escape/escape.go b/src/cmd/compile/internal/escape/escape.go index 25136c242b..f38bcadb3e 100644 --- a/src/cmd/compile/internal/escape/escape.go +++ b/src/cmd/compile/internal/escape/escape.go @@ -125,12 +125,6 @@ func Funcs(all []*ir.Func) { // Batch performs escape analysis on a minimal batch of // functions. func Batch(fns []*ir.Func, recursive bool) { - for _, fn := range fns { - if fn.Op() != ir.ODCLFUNC { - base.Fatalf("unexpected node: %v", fn) - } - } - var b batch b.heapLoc.attrs = attrEscapes | attrPersists | attrMutates | attrCalls b.mutatorLoc.attrs = attrMutates diff --git a/src/cmd/compile/internal/pkginit/init.go b/src/cmd/compile/internal/pkginit/init.go index 7d2e4ce076..3b7efba434 100644 --- a/src/cmd/compile/internal/pkginit/init.go +++ b/src/cmd/compile/internal/pkginit/init.go @@ -199,18 +199,3 @@ func MakeTask() { // It's not quite read only, the state field must be modifiable. objw.Global(lsym, int32(ot), obj.NOPTR) } - -// initRequiredForCoverage returns TRUE if we need to force creation -// of an init function for the package so as to insert a coverage -// runtime registration call. -func initRequiredForCoverage(l []ir.Node) bool { - if base.Flag.Cfg.CoverageInfo == nil { - return false - } - for _, n := range l { - if n.Op() == ir.ODCLFUNC { - return true - } - } - return false -} diff --git a/src/cmd/compile/internal/ssagen/nowb.go b/src/cmd/compile/internal/ssagen/nowb.go index 8a020611df..3ef0952eff 100644 --- a/src/cmd/compile/internal/ssagen/nowb.go +++ b/src/cmd/compile/internal/ssagen/nowb.go @@ -98,9 +98,6 @@ func (c *nowritebarrierrecChecker) findExtraCalls(nn ir.Node) { default: base.Fatalf("expected ONAME or OCLOSURE node, got %+v", arg) } - if callee.Op() != ir.ODCLFUNC { - base.Fatalf("expected ODCLFUNC node, got %+v", callee) - } c.extraCalls[c.curfn] = append(c.extraCalls[c.curfn], nowritebarrierrecCall{callee, n.Pos()}) } -- 2.50.0