Skip to content

Commit de9bffb

Browse files
mdempskygopherbot
authored andcommitted
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Keith Randall <[email protected]> Run-TryBot: Matthew Dempsky <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 532e34d commit de9bffb

File tree

3 files changed

+8
-26
lines changed

3 files changed

+8
-26
lines changed

src/cmd/compile/internal/inline/inl.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,10 @@ var SSADumpInline = func(*ir.Func) {}
904904

905905
// InlineCall allows the inliner implementation to be overridden.
906906
// If it returns nil, the function will not be inlined.
907-
var InlineCall = oldInlineCall
907+
var InlineCall = func(call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCallExpr {
908+
base.Fatalf("inline.InlineCall not overridden")
909+
panic("unreachable")
910+
}
908911

909912
// If n is a OCALLFUNC node, and fn is an ONAME node for a
910913
// function with an inlinable body, return an OINLCALL node that can replace n.

src/cmd/compile/internal/typecheck/iimport.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,8 @@ func ImportBody(fn *ir.Func) {
8787
// It's a function literal so that it can be overridden for
8888
// GOEXPERIMENT=unified.
8989
var HaveInlineBody = func(fn *ir.Func) bool {
90-
if fn.Inl == nil {
91-
return false
92-
}
93-
94-
if fn.Inl.Body != nil {
95-
return true
96-
}
97-
98-
_, ok := inlineImporter[fn.Nname.Sym()]
99-
return ok
90+
base.Fatalf("HaveInlineBody not overridden")
91+
panic("unreachable")
10092
}
10193

10294
func importReaderFor(sym *types.Sym, importers map[*types.Sym]iimporterAndOffset) *importReader {

src/cmd/compile/internal/typecheck/typecheck.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,8 @@ func Resolve(n ir.Node) (res ir.Node) {
126126
return n
127127
}
128128

129-
// only trace if there's work to do
130-
if base.EnableTrace && base.Flag.LowerT {
131-
defer tracePrint("resolve", n)(&res)
132-
}
133-
134-
if sym := n.Sym(); sym.Pkg != types.LocalPkg {
135-
return expandDecl(n)
136-
}
137-
138-
r := ir.AsNode(n.Sym().Def)
139-
if r == nil {
140-
return n
141-
}
142-
143-
return r
129+
base.Fatalf("unexpected NONAME node: %+v", n)
130+
panic("unreachable")
144131
}
145132

146133
func typecheckslice(l []ir.Node, top int) {

0 commit comments

Comments
 (0)