-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: copy causes escape #15730
Comments
Assigning to 1.8 since this seems inefficient but not broken. Please reassign if you disagree. |
Any progress? I'm try to fix this issue by this tricky code. |
cc @cherrymui |
The loop version doesn't escape because the assignment is on byte, a non-pointer type. The copy version is modeled with data flow of type "dereference-of-string", which was (conservatively) also string, which contains pointer, which causes escape. |
Change https://golang.org/cl/107597 mentions this issue: |
go version
)?go version devel +0a9595f Tue May 17 18:46:03 2016 -0400 linux/amd64
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/austin/r/go"
GORACE=""
GOROOT="/home/austin/go.dev"
GOTOOLDIR="/home/austin/go.dev/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build366275436=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
I expected "abc" in
main
to not escape and the conversion tointerface{}
to not allocate.If I use
copy
intest
, escape analysis determines that arg's content escapes, which causes the args slice to escape, which causes theconvT2E
inmain
to allocate. However, if I do the copy "manually" by looping over the string, args does not escape, and theconvT2E
happens on the stack./cc @dr2chase @randall77
The text was updated successfully, but these errors were encountered: