aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-03-30 16:03:26 -0700
committerDan Scales <danscales@google.com>2021-03-31 00:52:58 +0000
commit6d2a557a4d09b6f60e2522fb740b5d7d1d8dc8e2 (patch)
tree19796914f268ea5a4f6a77d83f668c2eddb926e7 /src
parentf2717b31b5cf235457631fea1afd6d9df578737c (diff)
downloadgo-6d2a557a4d09b6f60e2522fb740b5d7d1d8dc8e2.tar.xz
cmd/compile: deal with call.Use correctly for noder2, allow inlining of stenciled functions
The setting of n.Use for a call node in transformCall() (and previously in Call()), was not corrrect, since it was trying to use the number of results of the call, rather than whether the call result was actually used. We are already setting n.Use to ir.CallUseStmt if the call node is directly a statement, so we just need to initialize n.Use to ir.CallExprStmt in Call(), which will get changed to ir.CallUseStmt at the statement level if it's used as a statement. Enable inlining of stenciled functions (just disabled for testing, easier debugging). The above n.Use fix was required for the inlining to work for two cases. Change-Id: Ie4ef6cd53fd4b20a4f3be31e629280909a545b7d Reviewed-on: https://go-review.googlesource.com/c/go/+/305913 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/noder/helpers.go3
-rw-r--r--src/cmd/compile/internal/noder/stencil.go2
-rw-r--r--src/cmd/compile/internal/noder/transform.go5
3 files changed, 3 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/noder/helpers.go b/src/cmd/compile/internal/noder/helpers.go
index e5a6dbcb01..6320b30e50 100644
--- a/src/cmd/compile/internal/noder/helpers.go
+++ b/src/cmd/compile/internal/noder/helpers.go
@@ -87,6 +87,9 @@ func Binary(pos src.XPos, op ir.Op, typ *types.Type, x, y ir.Node) ir.Node {
func Call(pos src.XPos, typ *types.Type, fun ir.Node, args []ir.Node, dots bool) ir.Node {
n := ir.NewCallExpr(pos, ir.OCALL, fun, args)
n.IsDDD = dots
+ // n.Use will be changed to ir.CallUseStmt in g.stmt() if this call is
+ // just a statement (any return values are ignored).
+ n.Use = ir.CallUseExpr
if fun.Op() == ir.OTYPE {
// Actually a type conversion, not a function call.
diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go
index 1dff4e294c..350f8f8c2a 100644
--- a/src/cmd/compile/internal/noder/stencil.go
+++ b/src/cmd/compile/internal/noder/stencil.go
@@ -303,8 +303,6 @@ func (g *irgen) genericSubst(newsym *types.Sym, nameNode *ir.Name, targs []ir.No
ir.MarkFunc(newf.Nname)
newf.SetTypecheck(1)
newf.Nname.SetTypecheck(1)
- // TODO(danscales) - remove later, but avoid confusion for now.
- newf.Pragma = ir.Noinline
// Make sure name/type of newf is set before substituting the body.
newf.Body = subst.list(gf.Body)
diff --git a/src/cmd/compile/internal/noder/transform.go b/src/cmd/compile/internal/noder/transform.go
index 7f926dc70a..021d3a9fa7 100644
--- a/src/cmd/compile/internal/noder/transform.go
+++ b/src/cmd/compile/internal/noder/transform.go
@@ -143,11 +143,6 @@ func transformCall(n *ir.CallExpr) {
}
typecheckaste(ir.OCALL, n.X, n.IsDDD, t.Params(), n.Args)
- if t.NumResults() == 0 {
- n.Use = ir.CallUseStmt
- return
- }
- n.Use = ir.CallUseExpr
if t.NumResults() == 1 {
n.SetType(l.Type().Results().Field(0).Type)