compiler: recognize and optimize map range clear

Programming / Compilers / GCC - ian [138bc75d-0d04-0410-961f-82ee72b054a4] - 1 May 2019 21:37 EDT

Recognize

for k := range m { delete(m, k) }

for map m, and rewrite it to runtime.mapclear, as the gc compiler does.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/169397

b52ffd74a93 compiler: recognize and optimize map range clear
gcc/go/gofrontend/MERGE | 2 +-
gcc/go/gofrontend/runtime.def | 3 ++
gcc/go/gofrontend/statements.cc | 96 +++++++++++++++++++++++++++++++++++++++++
gcc/go/gofrontend/statements.h | 4 ++
libgo/go/runtime/map.go | 1 +
5 files changed, 105 insertions(+), 1 deletion(-)

Upstream: gcc.gnu.org


  • Share