mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: use HaveInlineBody for unified IR
In go.dev/cl/419674 I added a mechanism to the inliner to allow inlining to fail gracefully when a function body is missing, but I missed we already have a mechanism for that: typecheck.HaveInlineBody. This CL makes it overridable so that unified IR can plug in its appropriate logic, like it does with the logic for building the ir.InlinedCallExpr node. While here, rename inline.NewInline to inline.InlineCall, because the name "NewInline" is now a misnomer since we initialize it to oldInline (now named oldInlineCall). Change-Id: I4e65618d3725919f69e6f43cf409699d20fb797c Reviewed-on: https://go-review.googlesource.com/c/go/+/427234 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
33a7e5a4b4
commit
e4b624eae5
4 changed files with 26 additions and 22 deletions
|
|
@ -689,9 +689,9 @@ var inlgen int
|
|||
// when producing output for debugging the compiler itself.
|
||||
var SSADumpInline = func(*ir.Func) {}
|
||||
|
||||
// NewInline 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.
|
||||
var NewInline = oldInline
|
||||
var InlineCall = oldInlineCall
|
||||
|
||||
// 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.
|
||||
|
|
@ -817,9 +817,9 @@ func mkinlcall(n *ir.CallExpr, fn *ir.Func, maxCost int32, inlCalls *[]*ir.Inlin
|
|||
fmt.Printf("%v: Before inlining: %+v\n", ir.Line(n), n)
|
||||
}
|
||||
|
||||
res := NewInline(n, fn, inlIndex)
|
||||
res := InlineCall(n, fn, inlIndex)
|
||||
if res == nil {
|
||||
return n
|
||||
base.FatalfAt(n.Pos(), "inlining call to %v failed", fn)
|
||||
}
|
||||
|
||||
if base.Flag.LowerM > 2 {
|
||||
|
|
@ -855,11 +855,11 @@ func CalleeEffects(init *ir.Nodes, callee ir.Node) {
|
|||
}
|
||||
}
|
||||
|
||||
// oldInline creates an InlinedCallExpr to replace the given call
|
||||
// oldInlineCall creates an InlinedCallExpr to replace the given call
|
||||
// expression. fn is the callee function to be inlined. inlIndex is
|
||||
// the inlining tree position index, for use with src.NewInliningBase
|
||||
// when rewriting positions.
|
||||
func oldInline(call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCallExpr {
|
||||
func oldInlineCall(call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCallExpr {
|
||||
if base.Debug.TypecheckInl == 0 {
|
||||
typecheck.ImportedBody(fn)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue