aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-03-17 18:46:23 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2009-03-17 18:46:23 +0100
commit6b2b88712792698e1348e585ab91fa8518a250f0 (patch)
tree1561d673290eb404bb41c2a5161a6ff3f15f7b15
parent16e60c1706a8abf971d1ae216a33cc7e2f29e3c5 (diff)
downloadgcc-6b2b88712792698e1348e585ab91fa8518a250f0.zip
gcc-6b2b88712792698e1348e585ab91fa8518a250f0.tar.gz
gcc-6b2b88712792698e1348e585ab91fa8518a250f0.tar.bz2
re PR middle-end/39443 (Builtin redirection no longer working for memcmp)
PR middle-end/39443 * optabs.c (set_user_assembler_libfunc): New function. * expr.h (set_user_assembler_libfunc): New prototype. * c-common.c: Include libfuncs.h. (set_builtin_user_assembler_name): Call set_user_assembler_libfunc for memcmp, memset, memcpy, memmove and abort. * Makefile.in (c-common.o): Depend on libfuncs.h. * gcc.dg/pr39443.c: New test. From-SVN: r144910
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/Makefile.in2
-rw-r--r--gcc/c-common.c27
-rw-r--r--gcc/expr.h3
-rw-r--r--gcc/optabs.c18
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/pr39443.c18
7 files changed, 73 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 18264af..7af0db0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
2009-03-17 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/39443
+ * optabs.c (set_user_assembler_libfunc): New function.
+ * expr.h (set_user_assembler_libfunc): New prototype.
+ * c-common.c: Include libfuncs.h.
+ (set_builtin_user_assembler_name): Call set_user_assembler_libfunc
+ for memcmp, memset, memcpy, memmove and abort.
+ * Makefile.in (c-common.o): Depend on libfuncs.h.
+
PR debug/39412
* dwarf2out.c (gen_inlined_enumeration_type_die,
gen_inlined_structure_type_die, gen_inlined_union_type_die,
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index be5634f..d4d6683 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1890,7 +1890,7 @@ c-common.o : c-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(TARGET_H) $(C_TREE_H) tree-iterator.h langhooks.h tree-mudflap.h \
intl.h opts.h $(REAL_H) $(CPPLIB_H) $(TREE_INLINE_H) $(HASHTAB_H) \
$(BUILTINS_DEF) $(CGRAPH_H) $(BASIC_BLOCK_H) $(TARGET_DEF_H) \
- $(GIMPLE_H)
+ $(GIMPLE_H) libfuncs.h
c-pretty-print.o : c-pretty-print.c $(C_PRETTY_PRINT_H) \
$(C_TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(REAL_H) \
diff --git a/gcc/c-common.c b/gcc/c-common.c
index a84113f..cc00511 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. If not see
#include "target-def.h"
#include "gimple.h"
#include "fixed-value.h"
+#include "libfuncs.h"
cpp_reader *parse_in; /* Declared in c-pragma.h. */
@@ -4401,10 +4402,28 @@ set_builtin_user_assembler_name (tree decl, const char *asmspec)
builtin = built_in_decls [DECL_FUNCTION_CODE (decl)];
set_user_assembler_name (builtin, asmspec);
- if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY)
- init_block_move_fn (asmspec);
- else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET)
- init_block_clear_fn (asmspec);
+ switch (DECL_FUNCTION_CODE (decl))
+ {
+ case BUILT_IN_MEMCPY:
+ init_block_move_fn (asmspec);
+ memcpy_libfunc = set_user_assembler_libfunc ("memcpy", asmspec);
+ break;
+ case BUILT_IN_MEMSET:
+ init_block_clear_fn (asmspec);
+ memset_libfunc = set_user_assembler_libfunc ("memset", asmspec);
+ break;
+ case BUILT_IN_MEMMOVE:
+ memmove_libfunc = set_user_assembler_libfunc ("memmove", asmspec);
+ break;
+ case BUILT_IN_MEMCMP:
+ memcmp_libfunc = set_user_assembler_libfunc ("memcmp", asmspec);
+ break;
+ case BUILT_IN_ABORT:
+ abort_libfunc = set_user_assembler_libfunc ("abort", asmspec);
+ break;
+ default:
+ break;
+ }
}
/* The number of named compound-literals generated thus far. */
diff --git a/gcc/expr.h b/gcc/expr.h
index 730f805..216de87 100644
--- a/gcc/expr.h
+++ b/gcc/expr.h
@@ -1,6 +1,6 @@
/* Definitions for code generation pass of GNU compiler.
Copyright (C) 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GCC.
@@ -786,6 +786,7 @@ extern void init_all_optabs (void);
/* Call this to initialize an optab function entry. */
extern rtx init_one_libfunc (const char *);
+extern rtx set_user_assembler_libfunc (const char *, const char *);
extern int vector_mode_valid_p (enum machine_mode);
diff --git a/gcc/optabs.c b/gcc/optabs.c
index ed59f5e..f7e44db 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -6072,6 +6072,24 @@ init_one_libfunc (const char *name)
return XEXP (DECL_RTL (decl), 0);
}
+/* Adjust the assembler name of libfunc NAME to ASMSPEC. */
+
+rtx
+set_user_assembler_libfunc (const char *name, const char *asmspec)
+{
+ tree id, decl;
+ void **slot;
+ hashval_t hash;
+
+ id = get_identifier (name);
+ hash = htab_hash_string (name);
+ slot = htab_find_slot_with_hash (libfunc_decls, id, hash, NO_INSERT);
+ gcc_assert (slot);
+ decl = (tree) *slot;
+ set_user_assembler_name (decl, asmspec);
+ return XEXP (DECL_RTL (decl), 0);
+}
+
/* Call this to reset the function entry for one optab (OPTABLE) in mode
MODE to NAME, which should be either 0 or a string constant. */
void
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d93660e..ae361a5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2009-03-17 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/39443
+ * gcc.dg/pr39443.c: New test.
+
PR debug/39412
* gcc.dg/debug/pr39412.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr39443.c b/gcc/testsuite/gcc.dg/pr39443.c
new file mode 100644
index 0000000..1baa63a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr39443.c
@@ -0,0 +1,18 @@
+/* PR middle-end/39443 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not "memcmp" } } */
+
+typedef __SIZE_TYPE__ size_t;
+
+extern int memcmp (const void *s1, const void *s2, size_t n)
+ __attribute__ ((__nothrow__, __pure__));
+extern __typeof (memcmp) memcmp __asm__ ("memory_compare");
+
+int
+test (char *s, char *t, int cnt)
+{
+ if (__builtin_expect (cnt, 0))
+ return memcmp (s, t, cnt);
+ return 0;
+}