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. // InlineCall allows the inliner implementation to be overridden.
// If it returns nil, the function will not be inlined. // 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 // 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. // 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 // It's a function literal so that it can be overridden for
// GOEXPERIMENT=unified. // GOEXPERIMENT=unified.
var HaveInlineBody = func(fn *ir.Func) bool { var HaveInlineBody = func(fn *ir.Func) bool {
if fn.Inl == nil { base.Fatalf("HaveInlineBody not overridden")
return false panic("unreachable")
}
if fn.Inl.Body != nil {
return true
}
_, ok := inlineImporter[fn.Nname.Sym()]
return ok
} }
func importReaderFor(sym *types.Sym, importers map[*types.Sym]iimporterAndOffset) *importReader { 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 return n
} }
// only trace if there's work to do base.Fatalf("unexpected NONAME node: %+v", n)
if base.EnableTrace && base.Flag.LowerT { panic("unreachable")
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
} }
func typecheckslice(l []ir.Node, top int) { func typecheckslice(l []ir.Node, top int) {