diff options
author | Egon Elbre <egonelbre@gmail.com> | 2021-01-02 16:28:11 +0200 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2021-02-24 17:00:14 +0000 |
commit | adb467ffd2d82b796de12bdd8effa2cfefe01f29 (patch) | |
tree | 5aedd704525f3103c568813e9fd9a6078680efce /src/cmd/compile/internal/inline | |
parent | 27684ea195641ead8a8f08cb345925da889a12ed (diff) | |
download | go-adb467ffd2d82b796de12bdd8effa2cfefe01f29.tar.gz go-adb467ffd2d82b796de12bdd8effa2cfefe01f29.zip |
cmd/compile: reduce inline cost of OCONVOP
OCONVOP doesn't have effect in the compiled code so, it can be safely
excluded from inline cost calculation.
Also make sequence ODEREF OCONVNOP* OADDR cost 1. This is rather common
conversion, such as *(*uint32)(unsafe.Pointer(&x)).
Fixes #42788
Change-Id: I5001f7e89d985c198b6405694cdd5b819cf3f47a
Reviewed-on: https://go-review.googlesource.com/c/go/+/281232
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Elias Naur <mail@eliasnaur.com>
Diffstat (limited to 'src/cmd/compile/internal/inline')
-rw-r--r-- | src/cmd/compile/internal/inline/inl.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index 7d70fca6c9..0e57c17667 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -384,6 +384,22 @@ func (v *hairyVisitor) doNode(n ir.Node) bool { case ir.OAPPEND: v.budget -= inlineExtraAppendCost + case ir.ODEREF: + // *(*X)(unsafe.Pointer(&x)) is low-cost + n := n.(*ir.StarExpr) + + ptr := n.X + for ptr.Op() == ir.OCONVNOP { + ptr = ptr.(*ir.ConvExpr).X + } + if ptr.Op() == ir.OADDR { + v.budget += 1 // undo half of default cost of ir.ODEREF+ir.OADDR + } + + case ir.OCONVNOP: + // This doesn't produce code, but the children might. + v.budget++ // undo default cost + case ir.ODCLCONST, ir.OFALL: // These nodes don't produce code; omit from inlining budget. return false |