Browse files

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

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
Run-TryBot: Daniel Martí <>
TryBot-Result: Gobot Gobot <>
Reviewed-by: Matthew Dempsky <>
Reviewed-by: Keith Randall <>
  • Loading branch information...
mvdan committed Sep 22, 2017
1 parent 6db6979 commit f366379d847274158bd14e160c85c7e2bc0f2bc1
Showing with 42 additions and 5 deletions.
  1. +42 −5 src/cmd/compile/internal/gc/inl_test.go
@@ -29,16 +29,39 @@ func TestIntendedInlining(t *testing.T) {
// be inlined.
want := map[string][]string{
"runtime": {
//"adjustctxt", TODO(mvdan): fix and re-enable
"runtime/internal/sys": {},
"unicode/utf8": {
@@ -52,14 +75,28 @@ 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)
pkgs := make([]string, 0, len(want))
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"

0 comments on commit f366379

Please sign in to comment.