mirror of
https://github.com/golang/go.git
synced 2024-09-21 10:28:27 +00:00
cmd/gc: fix escape analysis bug
Was not handling &x.y[0] and &x.y.z correctly where y is an array or struct-valued field (not a pointer). R=ken2 CC=golang-dev https://golang.org/cl/6551059
This commit is contained in:
parent
c7e0b8baa6
commit
54af752865
@ -926,9 +926,15 @@ escwalk(EscState *e, int level, Node *dst, Node *src)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ODOT:
|
||||||
|
escwalk(e, level, dst, src->left);
|
||||||
|
break;
|
||||||
|
|
||||||
case OINDEX:
|
case OINDEX:
|
||||||
if(isfixedarray(src->type))
|
if(isfixedarray(src->left->type)) {
|
||||||
|
escwalk(e, level, dst, src->left);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
// fall through
|
// fall through
|
||||||
case OSLICE:
|
case OSLICE:
|
||||||
case ODOTPTR:
|
case ODOTPTR:
|
||||||
|
@ -1211,3 +1211,21 @@ func foo137() {
|
|||||||
}()
|
}()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func foo138() *byte {
|
||||||
|
type T struct {
|
||||||
|
x [1]byte
|
||||||
|
}
|
||||||
|
t := new(T) // ERROR "new.T. escapes to heap"
|
||||||
|
return &t.x[0] // ERROR "&t.x.0. escapes to heap"
|
||||||
|
}
|
||||||
|
|
||||||
|
func foo139() *byte {
|
||||||
|
type T struct {
|
||||||
|
x struct {
|
||||||
|
y byte
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t := new(T) // ERROR "new.T. escapes to heap"
|
||||||
|
return &t.x.y // ERROR "&t.x.y escapes to heap"
|
||||||
|
}
|
||||||
|
@ -37,3 +37,21 @@ func f2() {} // ERROR "can inline f2"
|
|||||||
// No inline for panic, recover.
|
// No inline for panic, recover.
|
||||||
func f3() { panic(1) }
|
func f3() { panic(1) }
|
||||||
func f4() { recover() }
|
func f4() { recover() }
|
||||||
|
|
||||||
|
func f5() *byte {
|
||||||
|
type T struct {
|
||||||
|
x [1]byte
|
||||||
|
}
|
||||||
|
t := new(T) // ERROR "new.T. escapes to heap"
|
||||||
|
return &t.x[0] // ERROR "&t.x.0. escapes to heap"
|
||||||
|
}
|
||||||
|
|
||||||
|
func f6() *byte {
|
||||||
|
type T struct {
|
||||||
|
x struct {
|
||||||
|
y byte
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t := new(T) // ERROR "new.T. escapes to heap"
|
||||||
|
return &t.x.y // ERROR "&t.x.y escapes to heap"
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user