runtime: use builtin memmove directly
authorCherry Zhang <cherryyz@google.com>
Wed, 8 May 2019 17:40:45 +0000 (17:40 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 8 May 2019 17:40:45 +0000 (17:40 +0000)
    We can use the intrinsic memmove directly, without going through
    C.

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

* go-gcc.cc (Gcc_backend::Gcc_backend): Define memmove builtin.

From-SVN: r271016

gcc/go/ChangeLog
gcc/go/go-gcc.cc
gcc/go/gofrontend/MERGE
libgo/Makefile.am
libgo/Makefile.in
libgo/go/runtime/stubs.go
libgo/runtime/go-memmove.c [deleted file]

index a73072f2546e5892e9f476292ca84cd151b59744..10c2b6959f6ddf8ccc186d81ce66186a79049fa6 100644 (file)
@@ -1,3 +1,7 @@
+2019-05-08  Cherry Zhang  <cherryyz@google.com>
+
+       * go-gcc.cc (Gcc_backend::Gcc_backend): Define memmove builtin.
+
 2019-05-07  Cherry Zhang  <cherryyz@google.com>
 
        * lang.opt (-fgo-debug-optimization): New option.
index 1a52d9b22c1385c8a57b9127ade81a600d615a1f..e0e4333602c12224a5c818038f0c4205f2edc7c9 100644 (file)
@@ -604,6 +604,15 @@ Gcc_backend::Gcc_backend()
                                                NULL_TREE),
                       false, false);
 
+  // We use __builtin_memmove for copying data.
+  this->define_builtin(BUILT_IN_MEMMOVE, "__builtin_memmove", "memmove",
+                      build_function_type_list(void_type_node,
+                                               ptr_type_node,
+                                               const_ptr_type_node,
+                                               size_type_node,
+                                               NULL_TREE),
+                      false, false);
+
   // Used by runtime/internal/sys.
   this->define_builtin(BUILT_IN_CTZ, "__builtin_ctz", "ctz",
                       build_function_type_list(integer_type_node,
index 9a80682f169cf5494d8ebac5e8a025a979db0c2b..c7caf1eb4a995545b1011974aa8fd170e2ce028e 100644 (file)
@@ -1,4 +1,4 @@
-0b4cf8ded107ccbfbd4af7f4e056f23f941d0f86
+3a9bccfbf4af1c756978c40967838d9f6a4e7a62
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 1201cf59633a172e203d684def7af64ec03539e1..ebbdee81b228fe6f39c4bbc0976ea6a12fa4f907 100644 (file)
@@ -461,7 +461,6 @@ runtime_files = \
        runtime/go-memclr.c \
        runtime/go-memcmp.c \
        runtime/go-memequal.c \
-       runtime/go-memmove.c \
        runtime/go-nanotime.c \
        runtime/go-now.c \
        runtime/go-nosys.c \
index 346683b52379588406a22dc67c7a20a72eb0fb30..737b01e90d8c013b4aeb44aa6f3462bfaf169083 100644 (file)
@@ -245,16 +245,15 @@ am__objects_3 = runtime/aeshash.lo runtime/go-assert.lo \
        runtime/go-ffi.lo runtime/go-fieldtrack.lo \
        runtime/go-matherr.lo runtime/go-memclr.lo \
        runtime/go-memcmp.lo runtime/go-memequal.lo \
-       runtime/go-memmove.lo runtime/go-nanotime.lo runtime/go-now.lo \
-       runtime/go-nosys.lo runtime/go-reflect-call.lo \
-       runtime/go-runtime-error.lo runtime/go-setenv.lo \
-       runtime/go-signal.lo runtime/go-strslice.lo \
-       runtime/go-typedesc-equal.lo runtime/go-unsafe-pointer.lo \
-       runtime/go-unsetenv.lo runtime/go-unwind.lo \
-       runtime/go-varargs.lo runtime/env_posix.lo runtime/panic.lo \
-       runtime/print.lo runtime/proc.lo runtime/runtime_c.lo \
-       runtime/stack.lo runtime/yield.lo $(am__objects_1) \
-       $(am__objects_2)
+       runtime/go-nanotime.lo runtime/go-now.lo runtime/go-nosys.lo \
+       runtime/go-reflect-call.lo runtime/go-runtime-error.lo \
+       runtime/go-setenv.lo runtime/go-signal.lo \
+       runtime/go-strslice.lo runtime/go-typedesc-equal.lo \
+       runtime/go-unsafe-pointer.lo runtime/go-unsetenv.lo \
+       runtime/go-unwind.lo runtime/go-varargs.lo \
+       runtime/env_posix.lo runtime/panic.lo runtime/print.lo \
+       runtime/proc.lo runtime/runtime_c.lo runtime/stack.lo \
+       runtime/yield.lo $(am__objects_1) $(am__objects_2)
 am_libgo_llgo_la_OBJECTS = $(am__objects_3)
 libgo_llgo_la_OBJECTS = $(am_libgo_llgo_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -882,7 +881,6 @@ runtime_files = \
        runtime/go-memclr.c \
        runtime/go-memcmp.c \
        runtime/go-memequal.c \
-       runtime/go-memmove.c \
        runtime/go-nanotime.c \
        runtime/go-now.c \
        runtime/go-nosys.c \
@@ -1337,8 +1335,6 @@ runtime/go-memcmp.lo: runtime/$(am__dirstamp) \
        runtime/$(DEPDIR)/$(am__dirstamp)
 runtime/go-memequal.lo: runtime/$(am__dirstamp) \
        runtime/$(DEPDIR)/$(am__dirstamp)
-runtime/go-memmove.lo: runtime/$(am__dirstamp) \
-       runtime/$(DEPDIR)/$(am__dirstamp)
 runtime/go-nanotime.lo: runtime/$(am__dirstamp) \
        runtime/$(DEPDIR)/$(am__dirstamp)
 runtime/go-now.lo: runtime/$(am__dirstamp) \
@@ -1431,7 +1427,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-memclr.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-memcmp.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-memequal.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-memmove.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-nanotime.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-nosys.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-now.Plo@am__quote@
index dfdb38e8010620d9ed47bb40c6b3ea6708f7d53d..435cdf7ce9249d372cb2bf68459cc612d887269d 100644 (file)
@@ -100,6 +100,7 @@ func reflect_memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) {
 
 // memmove copies n bytes from "from" to "to".
 //go:noescape
+//extern __builtin_memmove
 func memmove(to, from unsafe.Pointer, n uintptr)
 
 //go:linkname reflect_memmove reflect.memmove
diff --git a/libgo/runtime/go-memmove.c b/libgo/runtime/go-memmove.c
deleted file mode 100644 (file)
index a6fda08..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/* go-memmove.c -- move one memory buffer to another
-
-   Copyright 2016 The Go Authors. All rights reserved.
-   Use of this source code is governed by a BSD-style
-   license that can be found in the LICENSE file.  */
-
-#include "runtime.h"
-
-void move(void *, void *, uintptr)
-  __asm__ (GOSYM_PREFIX "runtime.memmove");
-
-void
-move (void *p1, void *p2, uintptr len)
-{
-  __builtin_memmove (p1, p2, len);
-}