summaryrefslogtreecommitdiff
path: root/libgo/Makefile.in
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-05-31 21:18:39 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-05-31 21:18:39 +0000
commit6303331c3330222fef94eff8d8d35c99ca1d3e88 (patch)
tree99ef20c56f1bba3d53736e534b7e49f270169863 /libgo/Makefile.in
parent2b5360d7477277e7e0f32a5bd5479afac819b5e1 (diff)
compiler: optimize append of make
The gc compiler recognizes append(s, make([]T, n)...), and generates code to directly zero the tail instead of allocating a new slice and copying. This CL lets the Go frontend do basically the same. The difficulty is that at the point we handle append, there may already be temporaries introduced (e.g. in order_evaluations), which makes it hard to find the append-of-make pattern. The compiler could "see through" the value of a temporary, but it is only safe to do if the temporary is not assigned multiple times. For this, we add tracking of assignments and uses for temporaries. This also helps in optimizing non-escape slice make. We already optimize non-escape slice make with constant len/cap to stack allocation. But it failed to handle things like f(make([]T, n)) (where the slice doesn't escape and n is constant), because of the temporary. With tracking of temporary assignments and uses, it can handle this now as well. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179597 From-SVN: r271822
Diffstat (limited to 'libgo/Makefile.in')
0 files changed, 0 insertions, 0 deletions