1
0
mirror of https://github.com/golang/go synced 2024-11-17 00:04:40 -07:00

cmd/compile: change some unreachable code paths into Fatalf

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>
This commit is contained in:
Matthew Dempsky 2022-12-01 16:33:59 -08:00 committed by Gopher Robot
parent 532e34dd38
commit de9bffb5f1
3 changed files with 8 additions and 26 deletions

View 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.

View 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 {

View 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) {