2017-09-13 15:04:16 +02:00
|
|
|
// Copyright 2017 The Go Authors. All rights reserved.
|
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
package gc
|
|
|
|
|
|
|
|
|
|
import (
|
2017-09-14 15:51:18 +01:00
|
|
|
"bufio"
|
2017-09-13 15:04:16 +02:00
|
|
|
"internal/testenv"
|
2017-09-14 15:51:18 +01:00
|
|
|
"io"
|
2017-09-13 15:04:16 +02:00
|
|
|
"os/exec"
|
2017-09-14 15:51:18 +01:00
|
|
|
"regexp"
|
2017-09-20 13:09:08 -05:00
|
|
|
"runtime"
|
2017-09-14 15:51:18 +01:00
|
|
|
"strings"
|
2017-09-13 15:04:16 +02:00
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// TestIntendedInlining tests that specific runtime functions are inlined.
|
|
|
|
|
// This allows refactoring for code clarity and re-use without fear that
|
|
|
|
|
// changes to the compiler will cause silent performance regressions.
|
|
|
|
|
func TestIntendedInlining(t *testing.T) {
|
|
|
|
|
if testing.Short() && testenv.Builder() == "" {
|
|
|
|
|
t.Skip("skipping in short mode")
|
|
|
|
|
}
|
|
|
|
|
testenv.MustHaveGoRun(t)
|
|
|
|
|
t.Parallel()
|
|
|
|
|
|
2017-09-13 21:03:20 +02:00
|
|
|
// want is the list of function names (by package) that should
|
|
|
|
|
// be inlined.
|
|
|
|
|
want := map[string][]string{
|
|
|
|
|
"runtime": {
|
2017-09-23 12:22:10 +01:00
|
|
|
// TODO(mvdan): enable these once mid-stack
|
|
|
|
|
// inlining is available
|
|
|
|
|
// "adjustctxt",
|
|
|
|
|
|
2017-09-13 21:03:20 +02:00
|
|
|
"add",
|
2017-09-23 21:44:18 +01:00
|
|
|
"acquirem",
|
|
|
|
|
"add1",
|
2017-09-13 21:03:20 +02:00
|
|
|
"addb",
|
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
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 12:21:36 +01:00
|
|
|
"adjustpanics",
|
|
|
|
|
"adjustpointer",
|
2017-09-13 21:03:20 +02:00
|
|
|
"bucketMask",
|
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
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 12:21:36 +01:00
|
|
|
"bucketShift",
|
|
|
|
|
"chanbuf",
|
|
|
|
|
"deferArgs",
|
|
|
|
|
"deferclass",
|
|
|
|
|
"evacuated",
|
|
|
|
|
"fastlog2",
|
2017-09-13 21:03:20 +02:00
|
|
|
"fastrand",
|
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
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 12:21:36 +01:00
|
|
|
"float64bits",
|
2017-09-23 21:44:18 +01:00
|
|
|
"funcPC",
|
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
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 12:21:36 +01:00
|
|
|
"getm",
|
|
|
|
|
"isDirectIface",
|
|
|
|
|
"itabHashFunc",
|
|
|
|
|
"maxSliceCap",
|
2017-09-13 21:03:20 +02:00
|
|
|
"noescape",
|
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
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 12:21:36 +01:00
|
|
|
"readUnaligned32",
|
|
|
|
|
"readUnaligned64",
|
2017-09-23 21:44:18 +01:00
|
|
|
"releasem",
|
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
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 12:21:36 +01:00
|
|
|
"round",
|
|
|
|
|
"roundupsize",
|
2017-09-23 21:44:18 +01:00
|
|
|
"selectsize",
|
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
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 12:21:36 +01:00
|
|
|
"stringStructOf",
|
2017-09-23 21:44:18 +01:00
|
|
|
"subtract1",
|
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
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 12:21:36 +01:00
|
|
|
"subtractb",
|
|
|
|
|
"tophash",
|
|
|
|
|
"totaldefersize",
|
|
|
|
|
"(*bmap).keys",
|
|
|
|
|
"(*bmap).overflow",
|
|
|
|
|
"(*waitq).enqueue",
|
2017-09-23 21:44:18 +01:00
|
|
|
|
|
|
|
|
// GC-related ones
|
|
|
|
|
"cgoInRange",
|
|
|
|
|
"gclinkptr.ptr",
|
|
|
|
|
"guintptr.ptr",
|
|
|
|
|
"heapBits.bits",
|
|
|
|
|
"heapBits.isPointer",
|
|
|
|
|
"heapBits.morePointers",
|
|
|
|
|
"heapBits.next",
|
|
|
|
|
"heapBitsForAddr",
|
|
|
|
|
"inheap",
|
|
|
|
|
"markBits.isMarked",
|
|
|
|
|
"muintptr.ptr",
|
|
|
|
|
"puintptr.ptr",
|
|
|
|
|
"spanOfUnchecked",
|
|
|
|
|
"(*gcWork).putFast",
|
|
|
|
|
"(*gcWork).tryGetFast",
|
|
|
|
|
"(*guintptr).set",
|
|
|
|
|
"(*markBits).advance",
|
|
|
|
|
"(*mspan).allocBitsForIndex",
|
|
|
|
|
"(*mspan).base",
|
|
|
|
|
"(*mspan).markBitsForBase",
|
|
|
|
|
"(*mspan).markBitsForIndex",
|
|
|
|
|
"(*muintptr).set",
|
|
|
|
|
"(*puintptr).set",
|
2017-09-13 21:03:20 +02:00
|
|
|
},
|
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
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 12:21:36 +01:00
|
|
|
"runtime/internal/sys": {},
|
2017-09-24 17:55:19 +01:00
|
|
|
"bytes": {
|
|
|
|
|
"(*Buffer).Bytes",
|
|
|
|
|
"(*Buffer).Cap",
|
|
|
|
|
"(*Buffer).Len",
|
|
|
|
|
"(*Buffer).Next",
|
|
|
|
|
"(*Buffer).Read",
|
|
|
|
|
"(*Buffer).ReadByte",
|
|
|
|
|
"(*Buffer).Reset",
|
|
|
|
|
"(*Buffer).String",
|
|
|
|
|
"(*Buffer).UnreadByte",
|
|
|
|
|
"(*Buffer).tryGrowByReslice",
|
|
|
|
|
},
|
2017-09-13 21:03:20 +02:00
|
|
|
"unicode/utf8": {
|
|
|
|
|
"FullRune",
|
|
|
|
|
"FullRuneInString",
|
|
|
|
|
"RuneLen",
|
|
|
|
|
"ValidRune",
|
|
|
|
|
},
|
2017-09-28 20:44:21 +01:00
|
|
|
"reflect": {
|
|
|
|
|
"Value.CanAddr",
|
|
|
|
|
"Value.CanSet",
|
|
|
|
|
"Value.IsValid",
|
|
|
|
|
"add",
|
|
|
|
|
"align",
|
|
|
|
|
"flag.kind",
|
|
|
|
|
"flag.ro",
|
|
|
|
|
|
|
|
|
|
// TODO: these use panic, need mid-stack
|
|
|
|
|
// inlining
|
|
|
|
|
// "Value.CanInterface",
|
|
|
|
|
// "Value.pointer",
|
|
|
|
|
// "flag.mustBe",
|
|
|
|
|
// "flag.mustBeAssignable",
|
|
|
|
|
// "flag.mustBeExported",
|
|
|
|
|
},
|
2017-09-22 15:15:23 -05:00
|
|
|
"regexp": {
|
|
|
|
|
"(*bitState).push",
|
|
|
|
|
},
|
2017-09-13 15:04:16 +02:00
|
|
|
}
|
|
|
|
|
|
2017-10-20 10:53:48 -04:00
|
|
|
if runtime.GOARCH != "386" && runtime.GOARCH != "mips64" && runtime.GOARCH != "mips64le" {
|
2017-09-20 13:09:08 -05:00
|
|
|
// nextFreeFast calls sys.Ctz64, which on 386 is implemented in asm and is not inlinable.
|
|
|
|
|
// We currently don't have midstack inlining so nextFreeFast is also not inlinable on 386.
|
2017-10-20 10:53:48 -04:00
|
|
|
// On MIPS64x, Ctz64 is not intrinsified and causes nextFreeFast too expensive to inline
|
|
|
|
|
// (Issue 22239).
|
2017-09-20 13:09:08 -05:00
|
|
|
want["runtime"] = append(want["runtime"], "nextFreeFast")
|
2017-10-20 10:53:48 -04:00
|
|
|
}
|
|
|
|
|
if runtime.GOARCH != "386" {
|
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
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 12:21:36 +01:00
|
|
|
// 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")
|
2017-09-20 13:09:08 -05:00
|
|
|
}
|
|
|
|
|
|
2017-09-14 15:51:18 +01:00
|
|
|
notInlinedReason := make(map[string]string)
|
2017-09-13 21:03:20 +02:00
|
|
|
pkgs := make([]string, 0, len(want))
|
|
|
|
|
for pname, fnames := range want {
|
|
|
|
|
pkgs = append(pkgs, pname)
|
|
|
|
|
for _, fname := range fnames {
|
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
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-09-22 12:21:36 +01:00
|
|
|
fullName := pname + "." + fname
|
|
|
|
|
if _, ok := notInlinedReason[fullName]; ok {
|
|
|
|
|
t.Errorf("duplicate func: %s", fullName)
|
|
|
|
|
}
|
|
|
|
|
notInlinedReason[fullName] = "unknown reason"
|
2017-09-13 21:03:20 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-08 10:58:58 -05:00
|
|
|
args := append([]string{"build", "-a", "-gcflags=all=-m -m"}, pkgs...)
|
2017-09-13 21:03:20 +02:00
|
|
|
cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), args...))
|
2017-09-14 15:51:18 +01:00
|
|
|
pr, pw := io.Pipe()
|
|
|
|
|
cmd.Stdout = pw
|
|
|
|
|
cmd.Stderr = pw
|
|
|
|
|
cmdErr := make(chan error, 1)
|
|
|
|
|
go func() {
|
|
|
|
|
cmdErr <- cmd.Run()
|
|
|
|
|
pw.Close()
|
|
|
|
|
}()
|
|
|
|
|
scanner := bufio.NewScanner(pr)
|
2017-09-13 21:03:20 +02:00
|
|
|
curPkg := ""
|
2017-09-14 15:51:18 +01:00
|
|
|
canInline := regexp.MustCompile(`: can inline ([^ ]*)`)
|
|
|
|
|
cannotInline := regexp.MustCompile(`: cannot inline ([^ ]*): (.*)`)
|
|
|
|
|
for scanner.Scan() {
|
|
|
|
|
line := scanner.Text()
|
|
|
|
|
if strings.HasPrefix(line, "# ") {
|
|
|
|
|
curPkg = line[2:]
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if m := canInline.FindStringSubmatch(line); m != nil {
|
|
|
|
|
fname := m[1]
|
|
|
|
|
delete(notInlinedReason, curPkg+"."+fname)
|
|
|
|
|
continue
|
2017-09-13 21:03:20 +02:00
|
|
|
}
|
2017-09-14 15:51:18 +01:00
|
|
|
if m := cannotInline.FindStringSubmatch(line); m != nil {
|
|
|
|
|
fname, reason := m[1], m[2]
|
|
|
|
|
fullName := curPkg + "." + fname
|
|
|
|
|
if _, ok := notInlinedReason[fullName]; ok {
|
|
|
|
|
// cmd/compile gave us a reason why
|
|
|
|
|
notInlinedReason[fullName] = reason
|
|
|
|
|
}
|
2017-09-13 15:04:16 +02:00
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-14 15:51:18 +01:00
|
|
|
if err := <-cmdErr; err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
for fullName, reason := range notInlinedReason {
|
|
|
|
|
t.Errorf("%s was not inlined: %s", fullName, reason)
|
2017-09-13 15:04:16 +02:00
|
|
|
}
|
|
|
|
|
}
|