testenv.MustHaveGoRun(t)
t.Parallel()
- // want is the list of function names that should be inlined.
- want := []string{"tophash", "add", "(*bmap).keys", "bucketShift", "bucketMask"}
+ // want is the list of function names (by package) that should
+ // be inlined.
+ want := map[string][]string{
+ "runtime": {
+ "tophash",
+ "add",
+ "addb",
+ "subtractb",
+ "(*bmap).keys",
+ "bucketShift",
+ "bucketMask",
+ "fastrand",
+ "noescape",
- m := make(map[string]bool, len(want))
- for _, s := range want {
- m[s] = true
+ // TODO: These were modified at some point to be
+ // made inlineable, but have since been broken.
+ // "nextFreeFast",
+ },
+ "unicode/utf8": {
+ "FullRune",
+ "FullRuneInString",
+ "RuneLen",
+ "ValidRune",
+ },
}
- cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), "build", "-a", "-gcflags=-m", "runtime"))
+ m := make(map[string]bool)
+ pkgs := make([]string, 0, len(want))
+ for pname, fnames := range want {
+ pkgs = append(pkgs, pname)
+ for _, fname := range fnames {
+ m[pname+"."+fname] = true
+ }
+ }
+
+ args := append([]string{"build", "-a", "-gcflags=-m"}, pkgs...)
+ cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), args...))
out, err := cmd.CombinedOutput()
if err != nil {
t.Logf("%s", out)
t.Fatal(err)
}
lines := bytes.Split(out, []byte{'\n'})
- for _, x := range lines {
- f := bytes.Split(x, []byte(": can inline "))
+ curPkg := ""
+ for _, l := range lines {
+ if bytes.HasPrefix(l, []byte("# ")) {
+ curPkg = string(l[2:])
+ }
+ f := bytes.Split(l, []byte(": can inline "))
if len(f) < 2 {
continue
}
fn := bytes.TrimSpace(f[1])
- delete(m, string(fn))
+ delete(m, curPkg+"."+string(fn))
}
for s := range m {