]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.unified] cmd/compile: allow inlining to fail gracefully
authorMatthew Dempsky <mdempsky@google.com>
Tue, 26 Jul 2022 04:37:30 +0000 (21:37 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 28 Jul 2022 07:31:42 +0000 (07:31 +0000)
Change-Id: I20c7df52d110fb88eb22d57bdad9264d0c5e22fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/419674
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

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

index b6f80a17231d9357d778cc9e516946c2b03dbc4f..77848577c6b5ced3690565055d09b12426e3d20a 100644 (file)
@@ -685,9 +685,8 @@ var inlgen int
 var SSADumpInline = func(*ir.Func) {}
 
 // NewInline allows the inliner implementation to be overridden.
-// If it returns nil, the legacy inliner will handle this call
-// instead.
-var NewInline = func(call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCallExpr { return nil }
+// If it returns nil, the function will not be inlined.
+var NewInline = oldInline
 
 // 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.
@@ -807,7 +806,7 @@ func mkinlcall(n *ir.CallExpr, fn *ir.Func, maxCost int32, inlMap map[*ir.Func]b
 
        res := NewInline(n, fn, inlIndex)
        if res == nil {
-               res = oldInline(n, fn, inlIndex)
+               return n
        }
 
        // transitive inlining
index a8ef0a8e25edf7446fcf17241401fcd5e5ad83b3..0a382e1c9b04233170cfdefca09f9c1100a024e4 100644 (file)
@@ -2227,7 +2227,12 @@ func InlineCall(call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCallExp
 
        pri, ok := bodyReader[fn]
        if !ok {
-               base.FatalfAt(call.Pos(), "missing function body for call to %v", fn)
+               // 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
        }
 
        if fn.Inl.Body == nil {