-
Notifications
You must be signed in to change notification settings - Fork 19k
cmd/compile: copy causes escape #15730
Copy link
Copy link
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Performanceearly-in-cycleA change that should be done early in the 3 month dev cycle.A change that should be done early in the 3 month dev cycle.
Milestone
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Performanceearly-in-cycleA change that should be done early in the 3 month dev cycle.A change that should be done early in the 3 month dev cycle.
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
mainto not escape and the conversion tointerface{}to not allocate.If I use
copyintest, escape analysis determines that arg's content escapes, which causes the args slice to escape, which causes theconvT2Einmainto allocate. However, if I do the copy "manually" by looping over the string, args does not escape, and theconvT2Ehappens on the stack./cc @dr2chase @randall77