aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2017-09-22 12:21:36 +0100
committerDaniel Martí <mvdan@mvdan.cc>2017-09-22 17:19:01 +0000
commitf366379d847274158bd14e160c85c7e2bc0f2bc1 (patch)
tree7d88bbf85dc3dbc9e925390a0345d84735990ce5
parent6db697950eeab6d6ea4076bd97f6572918a2d5a7 (diff)
downloadgo-f366379d847274158bd14e160c85c7e2bc0f2bc1.tar.xz
cmd/compile: add more runtime funcs to inline test
This is based from a list that Keith Randall provided in mid-2016. These are all funcs that, at the time, were important and small enough that they should be clearly inlined. The runtime has changed a bit since then. Ctz16 and Ctz8 were removed, so don't add them. stringtoslicebytetmp was moved to the backend, so it's no longer a Go function. And itabhash was moved to itabHashFunc. The only other outlier is adjustctxt, which is not inlineable at the moment. I've added a TODO and will address it myself in a separate commit. While at it, error if any funcs in the input table are duplicated. They're never useful and typos could lead to unintentionally thinking a function is inlineable when it actually isn't. And, since the lists are getting long, start sorting alphabetically. Finally, rotl_31 is only defined on 64-bit architectures, and the added runtime/internal/sys funcs are assembly on 386 and thus non-inlineable in that case. Updates #21851. Change-Id: Ib99ab53d777860270e8fd4aefc41adb448f13662 Reviewed-on: https://go-review.googlesource.com/65351 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
-rw-r--r--src/cmd/compile/internal/gc/inl_test.go47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/gc/inl_test.go b/src/cmd/compile/internal/gc/inl_test.go
index 03dbd13b06..cbcd96a7b9 100644
--- a/src/cmd/compile/internal/gc/inl_test.go
+++ b/src/cmd/compile/internal/gc/inl_test.go
@@ -29,16 +29,39 @@ func TestIntendedInlining(t *testing.T) {
// be inlined.
want := map[string][]string{
"runtime": {
- "tophash",
"add",
"addb",
- "subtractb",
- "(*bmap).keys",
- "bucketShift",
+ "adjustpanics",
+ "adjustpointer",
"bucketMask",
+ "bucketShift",
+ "chanbuf",
+ "deferArgs",
+ "deferclass",
+ "evacuated",
+ "fastlog2",
"fastrand",
+ "float64bits",
+ "getm",
+ "isDirectIface",
+ "itabHashFunc",
+ "maxSliceCap",
"noescape",
+ "readUnaligned32",
+ "readUnaligned64",
+ "round",
+ "roundupsize",
+ "stringStructOf",
+ "subtractb",
+ "tophash",
+ "totaldefersize",
+ "(*bmap).keys",
+ "(*bmap).overflow",
+ "(*waitq).enqueue",
+
+ //"adjustctxt", TODO(mvdan): fix and re-enable
},
+ "runtime/internal/sys": {},
"unicode/utf8": {
"FullRune",
"FullRuneInString",
@@ -52,6 +75,16 @@ func TestIntendedInlining(t *testing.T) {
// We currently don't have midstack inlining so nextFreeFast is also not inlinable on 386.
// So check for it only on non-386 platforms.
want["runtime"] = append(want["runtime"], "nextFreeFast")
+ // As explained above, Ctz64 and Ctz32 are not Go code on 386.
+ // The same applies to Bswap32.
+ want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Ctz64")
+ want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Ctz32")
+ want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Bswap32")
+ }
+ switch runtime.GOARCH {
+ case "amd64", "amd64p32", "arm64", "mips64", "mips64le", "ppc64", "ppc64le", "s390x":
+ // rotl_31 is only defined on 64-bit architectures
+ want["runtime"] = append(want["runtime"], "rotl_31")
}
notInlinedReason := make(map[string]string)
@@ -59,7 +92,11 @@ func TestIntendedInlining(t *testing.T) {
for pname, fnames := range want {
pkgs = append(pkgs, pname)
for _, fname := range fnames {
- notInlinedReason[pname+"."+fname] = "unknown reason"
+ fullName := pname + "." + fname
+ if _, ok := notInlinedReason[fullName]; ok {
+ t.Errorf("duplicate func: %s", fullName)
+ }
+ notInlinedReason[fullName] = "unknown reason"
}
}