Skip to content

Commit f366379

Browse files
committed
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í <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 6db6979 commit f366379

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

src/cmd/compile/internal/gc/inl_test.go

+42-5
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,39 @@ func TestIntendedInlining(t *testing.T) {
2929
// be inlined.
3030
want := map[string][]string{
3131
"runtime": {
32-
"tophash",
3332
"add",
3433
"addb",
35-
"subtractb",
36-
"(*bmap).keys",
37-
"bucketShift",
34+
"adjustpanics",
35+
"adjustpointer",
3836
"bucketMask",
37+
"bucketShift",
38+
"chanbuf",
39+
"deferArgs",
40+
"deferclass",
41+
"evacuated",
42+
"fastlog2",
3943
"fastrand",
44+
"float64bits",
45+
"getm",
46+
"isDirectIface",
47+
"itabHashFunc",
48+
"maxSliceCap",
4049
"noescape",
50+
"readUnaligned32",
51+
"readUnaligned64",
52+
"round",
53+
"roundupsize",
54+
"stringStructOf",
55+
"subtractb",
56+
"tophash",
57+
"totaldefersize",
58+
"(*bmap).keys",
59+
"(*bmap).overflow",
60+
"(*waitq).enqueue",
61+
62+
//"adjustctxt", TODO(mvdan): fix and re-enable
4163
},
64+
"runtime/internal/sys": {},
4265
"unicode/utf8": {
4366
"FullRune",
4467
"FullRuneInString",
@@ -52,14 +75,28 @@ func TestIntendedInlining(t *testing.T) {
5275
// We currently don't have midstack inlining so nextFreeFast is also not inlinable on 386.
5376
// So check for it only on non-386 platforms.
5477
want["runtime"] = append(want["runtime"], "nextFreeFast")
78+
// As explained above, Ctz64 and Ctz32 are not Go code on 386.
79+
// The same applies to Bswap32.
80+
want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Ctz64")
81+
want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Ctz32")
82+
want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Bswap32")
83+
}
84+
switch runtime.GOARCH {
85+
case "amd64", "amd64p32", "arm64", "mips64", "mips64le", "ppc64", "ppc64le", "s390x":
86+
// rotl_31 is only defined on 64-bit architectures
87+
want["runtime"] = append(want["runtime"], "rotl_31")
5588
}
5689

5790
notInlinedReason := make(map[string]string)
5891
pkgs := make([]string, 0, len(want))
5992
for pname, fnames := range want {
6093
pkgs = append(pkgs, pname)
6194
for _, fname := range fnames {
62-
notInlinedReason[pname+"."+fname] = "unknown reason"
95+
fullName := pname + "." + fname
96+
if _, ok := notInlinedReason[fullName]; ok {
97+
t.Errorf("duplicate func: %s", fullName)
98+
}
99+
notInlinedReason[fullName] = "unknown reason"
63100
}
64101
}
65102

0 commit comments

Comments
 (0)