Commit f366379d authored by Daniel Martí's avatar Daniel Martí

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: default avatarMatthew Dempsky <mdempsky@google.com>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 6db69795
...@@ -29,16 +29,39 @@ func TestIntendedInlining(t *testing.T) { ...@@ -29,16 +29,39 @@ func TestIntendedInlining(t *testing.T) {
// be inlined. // be inlined.
want := map[string][]string{ want := map[string][]string{
"runtime": { "runtime": {
"tophash",
"add", "add",
"addb", "addb",
"subtractb", "adjustpanics",
"(*bmap).keys", "adjustpointer",
"bucketShift",
"bucketMask", "bucketMask",
"bucketShift",
"chanbuf",
"deferArgs",
"deferclass",
"evacuated",
"fastlog2",
"fastrand", "fastrand",
"float64bits",
"getm",
"isDirectIface",
"itabHashFunc",
"maxSliceCap",
"noescape", "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": { "unicode/utf8": {
"FullRune", "FullRune",
"FullRuneInString", "FullRuneInString",
...@@ -52,6 +75,16 @@ func TestIntendedInlining(t *testing.T) { ...@@ -52,6 +75,16 @@ func TestIntendedInlining(t *testing.T) {
// We currently don't have midstack inlining so nextFreeFast is also not inlinable on 386. // We currently don't have midstack inlining so nextFreeFast is also not inlinable on 386.
// So check for it only on non-386 platforms. // So check for it only on non-386 platforms.
want["runtime"] = append(want["runtime"], "nextFreeFast") 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) notInlinedReason := make(map[string]string)
...@@ -59,7 +92,11 @@ func TestIntendedInlining(t *testing.T) { ...@@ -59,7 +92,11 @@ func TestIntendedInlining(t *testing.T) {
for pname, fnames := range want { for pname, fnames := range want {
pkgs = append(pkgs, pname) pkgs = append(pkgs, pname)
for _, fname := range fnames { 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"
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment