]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: change some unreachable code paths into Fatalf
authorMatthew Dempsky <mdempsky@google.com>
Fri, 2 Dec 2022 00:33:59 +0000 (16:33 -0800)
committerGopher Robot <gobot@golang.org>
Thu, 26 Jan 2023 00:29:56 +0000 (00:29 +0000)
Now that GOEXPERIMENT=nounified is removed, we can assume InlineCall
and HaveInlineBody will always be overridden with the unified
frontend's implementations. Similarly, we can assume expandDecl will
never be called.

This CL changes the code paths into Fatalfs, so subsequent CLs can
remove all the unreachable code.

Updates #57410.

Change-Id: I2a0c3edb32916c30dd63c4dce4f1bd6f18e07468
Reviewed-on: https://go-review.googlesource.com/c/go/+/458618
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/typecheck/iimport.go
src/cmd/compile/internal/typecheck/typecheck.go

index 59d97e9b0f911a515483eb8f4104522131c194b6..23fb254cfad7fd0094d525f7191cdff9ccd044cd 100644 (file)
@@ -904,7 +904,10 @@ var SSADumpInline = func(*ir.Func) {}
 
 // InlineCall allows the inliner implementation to be overridden.
 // If it returns nil, the function will not be inlined.
-var InlineCall = oldInlineCall
+var InlineCall = func(call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCallExpr {
+       base.Fatalf("inline.InlineCall not overridden")
+       panic("unreachable")
+}
 
 // If n is a OCALLFUNC node, and fn is an ONAME node for a
 // function with an inlinable body, return an OINLCALL node that can replace n.
index c55b4093905cd8bcde38e58b01e3ff73142dd351..0a817cc215e511ee85ecd86c6496dab2720d5127 100644 (file)
@@ -87,16 +87,8 @@ func ImportBody(fn *ir.Func) {
 // It's a function literal so that it can be overridden for
 // GOEXPERIMENT=unified.
 var HaveInlineBody = func(fn *ir.Func) bool {
-       if fn.Inl == nil {
-               return false
-       }
-
-       if fn.Inl.Body != nil {
-               return true
-       }
-
-       _, ok := inlineImporter[fn.Nname.Sym()]
-       return ok
+       base.Fatalf("HaveInlineBody not overridden")
+       panic("unreachable")
 }
 
 func importReaderFor(sym *types.Sym, importers map[*types.Sym]iimporterAndOffset) *importReader {
index 57dc5a39ec413b3bc55f8e9667a0156299b86f57..17c4e70f06ed45ccba0f0f796c99f69a2a43d80d 100644 (file)
@@ -126,21 +126,8 @@ func Resolve(n ir.Node) (res ir.Node) {
                return n
        }
 
-       // only trace if there's work to do
-       if base.EnableTrace && base.Flag.LowerT {
-               defer tracePrint("resolve", n)(&res)
-       }
-
-       if sym := n.Sym(); sym.Pkg != types.LocalPkg {
-               return expandDecl(n)
-       }
-
-       r := ir.AsNode(n.Sym().Def)
-       if r == nil {
-               return n
-       }
-
-       return r
+       base.Fatalf("unexpected NONAME node: %+v", n)
+       panic("unreachable")
 }
 
 func typecheckslice(l []ir.Node, top int) {