From f366379d847274158bd14e160c85c7e2bc0f2bc1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=AD?= Date: Fri, 22 Sep 2017 12:21:36 +0100 Subject: [PATCH] cmd/compile: add more runtime funcs to inline test MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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í TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky Reviewed-by: Keith Randall --- src/cmd/compile/internal/gc/inl_test.go | 47 ++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/cmd/compile/internal/gc/inl_test.go b/src/cmd/compile/internal/gc/inl_test.go index 03dbd13b06..cbcd96a7b9 100644 --- a/src/cmd/compile/internal/gc/inl_test.go +++ b/src/cmd/compile/internal/gc/inl_test.go @@ -29,16 +29,39 @@ func TestIntendedInlining(t *testing.T) { // be inlined. want := map[string][]string{ "runtime": { - "tophash", "add", "addb", - "subtractb", - "(*bmap).keys", - "bucketShift", + "adjustpanics", + "adjustpointer", "bucketMask", + "bucketShift", + "chanbuf", + "deferArgs", + "deferclass", + "evacuated", + "fastlog2", "fastrand", + "float64bits", + "getm", + "isDirectIface", + "itabHashFunc", + "maxSliceCap", "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": { "FullRune", "FullRuneInString", @@ -52,6 +75,16 @@ func TestIntendedInlining(t *testing.T) { // We currently don't have midstack inlining so nextFreeFast is also not inlinable on 386. // So check for it only on non-386 platforms. 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) @@ -59,7 +92,11 @@ func TestIntendedInlining(t *testing.T) { for pname, fnames := range want { pkgs = append(pkgs, pname) 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" } } -- 2.48.1