mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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í <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
99414a5b1d
commit
f351dbfa4d
1 changed files with 41 additions and 9 deletions
|
|
@ -21,28 +21,60 @@ func TestIntendedInlining(t *testing.T) {
|
|||
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue