mirror of
https://github.com/golang/go
synced 2024-10-02 22:25:08 +00:00
cmd/compile/internal/walk: reuse runtime.scase
Shaves ~1.5kB off cmd/go binary. Change-Id: I8ad85aa4a24bc197b009c8e1ea9201957222152a Reviewed-on: https://go-review.googlesource.com/c/go/+/521677 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
This commit is contained in:
parent
e7240ed886
commit
fecf51717f
|
@ -9,6 +9,7 @@ import (
|
|||
"cmd/compile/internal/ir"
|
||||
"cmd/compile/internal/typecheck"
|
||||
"cmd/compile/internal/types"
|
||||
"cmd/internal/src"
|
||||
)
|
||||
|
||||
func walkSelect(sel *ir.SelectStmt) {
|
||||
|
@ -287,11 +288,15 @@ var scase *types.Type
|
|||
// Keep in sync with src/runtime/select.go.
|
||||
func scasetype() *types.Type {
|
||||
if scase == nil {
|
||||
scase = types.NewStruct([]*types.Field{
|
||||
n := ir.NewDeclNameAt(src.NoXPos, ir.OTYPE, ir.Pkgs.Runtime.Lookup("scase"))
|
||||
scase = types.NewNamed(n)
|
||||
n.SetType(scase)
|
||||
n.SetTypecheck(1)
|
||||
|
||||
scase.SetUnderlying(types.NewStruct([]*types.Field{
|
||||
types.NewField(base.Pos, typecheck.Lookup("c"), types.Types[types.TUNSAFEPTR]),
|
||||
types.NewField(base.Pos, typecheck.Lookup("elem"), types.Types[types.TUNSAFEPTR]),
|
||||
})
|
||||
scase.SetNoalg(true)
|
||||
}))
|
||||
}
|
||||
return scase
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ var b bool
|
|||
|
||||
// this used to have a spurious "live at entry to f11a: ~r0"
|
||||
func f11a() *int {
|
||||
select { // ERROR "stack object .autotmp_[0-9]+ \[2\]struct"
|
||||
select { // ERROR "stack object .autotmp_[0-9]+ \[2\]runtime.scase$"
|
||||
case <-c:
|
||||
return nil
|
||||
case <-c:
|
||||
|
@ -182,7 +182,7 @@ func f11b() *int {
|
|||
// get to the bottom of the function.
|
||||
// This used to have a spurious "live at call to printint: p".
|
||||
printint(1) // nothing live here!
|
||||
select { // ERROR "stack object .autotmp_[0-9]+ \[2\]struct"
|
||||
select { // ERROR "stack object .autotmp_[0-9]+ \[2\]runtime.scase$"
|
||||
case <-c:
|
||||
return nil
|
||||
case <-c:
|
||||
|
@ -202,7 +202,7 @@ func f11c() *int {
|
|||
// Unlike previous, the cases in this select fall through,
|
||||
// so we can get to the println, so p is not dead.
|
||||
printint(1) // ERROR "live at call to printint: p$"
|
||||
select { // ERROR "live at call to selectgo: p$" "stack object .autotmp_[0-9]+ \[2\]struct"
|
||||
select { // ERROR "live at call to selectgo: p$" "stack object .autotmp_[0-9]+ \[2\]runtime.scase$"
|
||||
case <-c:
|
||||
case <-c:
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ func f38(b bool) {
|
|||
// we care that the println lines have no live variables
|
||||
// and therefore no output.
|
||||
if b {
|
||||
select { // ERROR "live at call to selectgo:( .autotmp_[0-9]+)+$" "stack object .autotmp_[0-9]+ \[4\]struct \{"
|
||||
select { // ERROR "live at call to selectgo:( .autotmp_[0-9]+)+$" "stack object .autotmp_[0-9]+ \[4\]runtime.scase$"
|
||||
case <-fc38():
|
||||
printnl()
|
||||
case fc38() <- *fi38(1): // ERROR "live at call to fc38:( .autotmp_[0-9]+)+$" "live at call to fi38:( .autotmp_[0-9]+)+$" "stack object .autotmp_[0-9]+ string$"
|
||||
|
|
|
@ -164,7 +164,7 @@ var b bool
|
|||
|
||||
// this used to have a spurious "live at entry to f11a: ~r0"
|
||||
func f11a() *int {
|
||||
select { // ERROR "stack object .autotmp_[0-9]+ \[2\]struct"
|
||||
select { // ERROR "stack object .autotmp_[0-9]+ \[2\]runtime.scase$"
|
||||
case <-c:
|
||||
return nil
|
||||
case <-c:
|
||||
|
@ -179,7 +179,7 @@ func f11b() *int {
|
|||
// get to the bottom of the function.
|
||||
// This used to have a spurious "live at call to printint: p".
|
||||
printint(1) // nothing live here!
|
||||
select { // ERROR "stack object .autotmp_[0-9]+ \[2\]struct"
|
||||
select { // ERROR "stack object .autotmp_[0-9]+ \[2\]runtime.scase$"
|
||||
case <-c:
|
||||
return nil
|
||||
case <-c:
|
||||
|
@ -199,7 +199,7 @@ func f11c() *int {
|
|||
// Unlike previous, the cases in this select fall through,
|
||||
// so we can get to the println, so p is not dead.
|
||||
printint(1) // ERROR "live at call to printint: p$"
|
||||
select { // ERROR "live at call to selectgo: p$" "stack object .autotmp_[0-9]+ \[2\]struct"
|
||||
select { // ERROR "live at call to selectgo: p$" "stack object .autotmp_[0-9]+ \[2\]runtime.scase$"
|
||||
case <-c:
|
||||
case <-c:
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ func f38(b bool) {
|
|||
// we care that the println lines have no live variables
|
||||
// and therefore no output.
|
||||
if b {
|
||||
select { // ERROR "live at call to selectgo:( .autotmp_[0-9]+)+$" "stack object .autotmp_[0-9]+ \[4\]struct \{"
|
||||
select { // ERROR "live at call to selectgo:( .autotmp_[0-9]+)+$" "stack object .autotmp_[0-9]+ \[4\]runtime.scase$"
|
||||
case <-fc38():
|
||||
printnl()
|
||||
case fc38() <- *fi38(1): // ERROR "live at call to fc38:( .autotmp_[0-9]+)+$" "live at call to fi38:( .autotmp_[0-9]+)+$" "stack object .autotmp_[0-9]+ string$"
|
||||
|
|
Loading…
Reference in a new issue