mirror of
https://github.com/golang/go
synced 2024-11-24 19:30:42 -07:00
gc: fix arm build
Escape analysis was incorrectly assuming that functions without bodies don't leak their parameters. This meant that sync/atomic's TestAddInt64 was allocating x on its stack, and then x was not properly aligned for use with the atomic 64-bit instructions. Obviously we should figure out the alignment story on 5g too, but this fix is correct and should restore the build to 'ok'. TBR=lvd CC=golang-dev https://golang.org/cl/4964047
This commit is contained in:
parent
a3bc7681b5
commit
77f0bdce07
@ -505,7 +505,7 @@ esccall(Node *n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fn && fn->op == ONAME && fn->class == PFUNC && fn->ntype) {
|
if(fn && fn->op == ONAME && fn->class == PFUNC && fn->defn && fn->defn->nbody && fn->ntype) {
|
||||||
// Local function. Incorporate into flow graph.
|
// Local function. Incorporate into flow graph.
|
||||||
|
|
||||||
// Receiver.
|
// Receiver.
|
||||||
@ -697,6 +697,10 @@ esctag(Node *func)
|
|||||||
Node *savefn;
|
Node *savefn;
|
||||||
NodeList *ll;
|
NodeList *ll;
|
||||||
|
|
||||||
|
// External functions must be assumed unsafe.
|
||||||
|
if(func->nbody == nil)
|
||||||
|
return;
|
||||||
|
|
||||||
savefn = curfn;
|
savefn = curfn;
|
||||||
curfn = func;
|
curfn = func;
|
||||||
|
|
||||||
|
@ -774,3 +774,9 @@ func foo118(unknown func(*int)) { // ERROR "unknown does not escape"
|
|||||||
x := 1 // ERROR "moved to heap: NAME-x"
|
x := 1 // ERROR "moved to heap: NAME-x"
|
||||||
unknown(&x) // ERROR "&x escapes to heap"
|
unknown(&x) // ERROR "&x escapes to heap"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func external(*int)
|
||||||
|
|
||||||
|
func foo119(x *int) { // ERROR "leaking param: NAME-x"
|
||||||
|
external(x)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user