Skip to content

Commit f351dbf

Browse files
committed
cmd/compile: expand inlining test to multiple pkgs
Rework the test to work with any number of std packages. This was done to include a few funcs from unicode/utf8. Adding more will be much simpler too. While at it, add more runtime funcs by searching for "inlined" or "inlining" in the git log of its directory. These are: addb, subtractb, fastrand and noescape. Updates #21851. Change-Id: I4fb2bd8aa6a5054218f9b36cb19d897ac533710e Reviewed-on: https://go-review.googlesource.com/63611 Run-TryBot: Daniel Martí <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 99414a5 commit f351dbf

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

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

+41-9
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,60 @@ func TestIntendedInlining(t *testing.T) {
2121
testenv.MustHaveGoRun(t)
2222
t.Parallel()
2323

24-
// want is the list of function names that should be inlined.
25-
want := []string{"tophash", "add", "(*bmap).keys", "bucketShift", "bucketMask"}
24+
// want is the list of function names (by package) that should
25+
// be inlined.
26+
want := map[string][]string{
27+
"runtime": {
28+
"tophash",
29+
"add",
30+
"addb",
31+
"subtractb",
32+
"(*bmap).keys",
33+
"bucketShift",
34+
"bucketMask",
35+
"fastrand",
36+
"noescape",
2637

27-
m := make(map[string]bool, len(want))
28-
for _, s := range want {
29-
m[s] = true
38+
// TODO: These were modified at some point to be
39+
// made inlineable, but have since been broken.
40+
// "nextFreeFast",
41+
},
42+
"unicode/utf8": {
43+
"FullRune",
44+
"FullRuneInString",
45+
"RuneLen",
46+
"ValidRune",
47+
},
3048
}
3149

32-
cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), "build", "-a", "-gcflags=-m", "runtime"))
50+
m := make(map[string]bool)
51+
pkgs := make([]string, 0, len(want))
52+
for pname, fnames := range want {
53+
pkgs = append(pkgs, pname)
54+
for _, fname := range fnames {
55+
m[pname+"."+fname] = true
56+
}
57+
}
58+
59+
args := append([]string{"build", "-a", "-gcflags=-m"}, pkgs...)
60+
cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), args...))
3361
out, err := cmd.CombinedOutput()
3462
if err != nil {
3563
t.Logf("%s", out)
3664
t.Fatal(err)
3765
}
3866
lines := bytes.Split(out, []byte{'\n'})
39-
for _, x := range lines {
40-
f := bytes.Split(x, []byte(": can inline "))
67+
curPkg := ""
68+
for _, l := range lines {
69+
if bytes.HasPrefix(l, []byte("# ")) {
70+
curPkg = string(l[2:])
71+
}
72+
f := bytes.Split(l, []byte(": can inline "))
4173
if len(f) < 2 {
4274
continue
4375
}
4476
fn := bytes.TrimSpace(f[1])
45-
delete(m, string(fn))
77+
delete(m, curPkg+"."+string(fn))
4678
}
4779

4880
for s := range m {

0 commit comments

Comments
 (0)