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
|
|
@ -3374,22 +3374,28 @@ func (r *reader) pkgObjs(target *ir.Package) []*ir.Name {
|
|||
|
||||
// @@@ Inlining
|
||||
|
||||
// unifiedHaveInlineBody reports whether we have the function body for
|
||||
// fn, so we can inline it.
|
||||
func unifiedHaveInlineBody(fn *ir.Func) bool {
|
||||
if fn.Inl == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
_, ok := bodyReaderFor(fn)
|
||||
return ok
|
||||
}
|
||||
|
||||
var inlgen = 0
|
||||
|
||||
// InlineCall implements inline.NewInline by re-reading the function
|
||||
// unifiedInlineCall implements inline.NewInline by re-reading the function
|
||||
// body from its Unified IR export data.
|
||||
func InlineCall(call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCallExpr {
|
||||
func unifiedInlineCall(call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCallExpr {
|
||||
// TODO(mdempsky): Turn callerfn into an explicit parameter.
|
||||
callerfn := ir.CurFunc
|
||||
|
||||
pri, ok := bodyReaderFor(fn)
|
||||
if !ok {
|
||||
// TODO(mdempsky): Reconsider this diagnostic's wording, if it's
|
||||
// to be included in Go 1.20.
|
||||
if base.Flag.LowerM != 0 {
|
||||
base.WarnfAt(call.Pos(), "cannot inline call to %v: missing inline body", fn)
|
||||
}
|
||||
return nil
|
||||
base.FatalfAt(call.Pos(), "cannot inline call to %v: missing inline body", fn)
|
||||
}
|
||||
|
||||
if fn.Inl.Body == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue