compiler: use builtin memcmp directly
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 24 Jun 2019 16:54:22 +0000 (16:54 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 24 Jun 2019 16:54:22 +0000 (16:54 +0000)
    Instead of going through a C function __go_memcmp, we can just
    use __builtin_memcmp directly. This allows more optimizations in
    the compiler backend.

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

From-SVN: r272620

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc
gcc/go/gofrontend/runtime.def
libgo/Makefile.am
libgo/Makefile.in
libgo/runtime/go-memcmp.c [deleted file]

index 92d863e79cb371b0bcaa625d0d0db53ab5eaebe8..89d401b6a3edd17ff00d97cf3b54bd590c608d54 100644 (file)
@@ -1,4 +1,4 @@
-1232eef628227ef855c5fa6d94b31778b2e74a85
+338e4baf88a4ae676205dff601dbef2d31b19d2d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index c9d8ea2a8292272f6944ce2d00dc459c7406dc5f..050da32c02f44be7099922588c6b5b6057cd64d7 100644 (file)
@@ -6199,7 +6199,8 @@ Binary_expression::lower_compare_to_memcmp(Gogo*, Statement_inserter* inserter)
                                               TYPE_INFO_SIZE);
 
   Expression* call = Runtime::make_call(Runtime::MEMCMP, loc, 3, a1, a2, len);
-  Expression* zero = Expression::make_integer_ul(0, NULL, loc);
+  Type* int32_type = Type::lookup_integer_type("int32");
+  Expression* zero = Expression::make_integer_ul(0, int32_type, loc);
   return Expression::make_binary(this->op_, call, zero, loc);
 }
 
index 27d5e472f6f2fa1e9c3fb43bfbd192b64992b443..7b66b166b77035e823900b29b04f0d02b16e095f 100644 (file)
@@ -29,7 +29,7 @@
 // result types.
 
 // The standard C memcmp function, used for struct comparisons.
-DEF_GO_RUNTIME(MEMCMP, "__go_memcmp", P3(POINTER, POINTER, UINTPTR), R1(INT))
+DEF_GO_RUNTIME(MEMCMP, "__builtin_memcmp", P3(POINTER, POINTER, UINTPTR), R1(INT32))
 
 // Decode a non-ASCII rune from a string.
 DEF_GO_RUNTIME(DECODERUNE, "runtime.decoderune", P2(STRING, INT),
index 4bfed3facf75d792c8962fdd0a60ee8fdaa2823d..88f885b6675127614a67df8312d79619d803dde0 100644 (file)
@@ -459,7 +459,6 @@ runtime_files = \
        runtime/go-fieldtrack.c \
        runtime/go-matherr.c \
        runtime/go-memclr.c \
-       runtime/go-memcmp.c \
        runtime/go-memequal.c \
        runtime/go-nanotime.c \
        runtime/go-now.c \
index 837e1e8a621f25e66ec4cdb799acaef37862eee5..f53ca3f4b12810cf1aa46eefc1f24d8e802067e0 100644 (file)
@@ -244,8 +244,8 @@ am__objects_3 = runtime/aeshash.lo runtime/go-assert.lo \
        runtime/go-cgo.lo runtime/go-construct-map.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-nanotime.lo runtime/go-now.lo runtime/go-nosys.lo \
+       runtime/go-memequal.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-unsafe-pointer.lo runtime/go-unsetenv.lo \
@@ -892,7 +892,6 @@ runtime_files = \
        runtime/go-fieldtrack.c \
        runtime/go-matherr.c \
        runtime/go-memclr.c \
-       runtime/go-memcmp.c \
        runtime/go-memequal.c \
        runtime/go-nanotime.c \
        runtime/go-now.c \
@@ -1343,8 +1342,6 @@ runtime/go-matherr.lo: runtime/$(am__dirstamp) \
        runtime/$(DEPDIR)/$(am__dirstamp)
 runtime/go-memclr.lo: runtime/$(am__dirstamp) \
        runtime/$(DEPDIR)/$(am__dirstamp)
-runtime/go-memcmp.lo: runtime/$(am__dirstamp) \
-       runtime/$(DEPDIR)/$(am__dirstamp)
 runtime/go-memequal.lo: runtime/$(am__dirstamp) \
        runtime/$(DEPDIR)/$(am__dirstamp)
 runtime/go-nanotime.lo: runtime/$(am__dirstamp) \
@@ -1436,7 +1433,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-fieldtrack.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-matherr.Plo@am__quote@
 @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-nanotime.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@runtime/$(DEPDIR)/go-nosys.Plo@am__quote@
diff --git a/libgo/runtime/go-memcmp.c b/libgo/runtime/go-memcmp.c
deleted file mode 100644 (file)
index 78a356b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* go-memcmp.c -- the go memory comparison function.
-
-   Copyright 2012 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"
-
-intgo
-__go_memcmp (const void *p1, const void *p2, uintptr len)
-{
-  return __builtin_memcmp (p1, p2, len);
-}