On Mon, 7 Jan 2013, Jakub Jelinek wrote: > On Mon, Jan 07, 2013 at 02:55:48PM +0100, Richard Biener wrote: > > *** gcc/testsuite/gcc.dg/torture/pr55890-1.c (revision 0) > > --- gcc/testsuite/gcc.dg/torture/pr55890-1.c (working copy) > > *************** > > *** 0 **** > > --- 1,6 ---- > > + /* { dg-do compile } */ > > + > > + extern void *memmove(void *, void *, long unsigned int); > > Please use __SIZE_TYPE__ as the last argument here.
Done. Also fixed up tree-ssa-strlen.c now as pr55890-2.c also ICEs therein. Re-bootstrapping/testing now. Richard. 2013-01-07 Richard Biener <rguent...@suse.de> PR middle-end/55890 * gimple.h (gimple_call_builtin_p): New overload. * gimple.c (validate_call): New function. (gimple_call_builtin_p): Likewise. * tree-ssa-structalias.c (find_func_aliases_for_builtin_call): Use gimple_call_builtin_p. (find_func_clobbers): Likewise. * tree-ssa-strlen.c (adjust_last_stmt): Likewise. (strlen_optimize_stmt): Likewise. * gcc.dg/torture/pr55890-1.c: New testcase. * gcc.dg/torture/pr55890-2.c: Likewise. Index: gcc/gimple.c =================================================================== *** gcc/gimple.c (revision 194970) --- gcc/gimple.c (working copy) *************** is_gimple_builtin_call (gimple stmt) *** 4137,4152 **** return false; } ! /* Return true when STMT is builtins call to CODE. */ bool gimple_call_builtin_p (gimple stmt, enum built_in_function code) { tree fndecl; ! return (is_gimple_call (stmt) ! && (fndecl = gimple_call_fndecl (stmt)) != NULL ! && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL ! && DECL_FUNCTION_CODE (fndecl) == code); } /* Return true if STMT clobbers memory. STMT is required to be a --- 4137,4196 ---- return false; } ! /* Return true when STMTs arguments match those of FNDECL. */ ! ! static bool ! validate_call (gimple stmt, tree fndecl) ! { ! tree targs = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); ! unsigned nargs = gimple_call_num_args (stmt); ! for (unsigned i = 0; i < nargs; ++i) ! { ! /* Variadic args follow. */ ! if (!targs) ! return true; ! tree arg = gimple_call_arg (stmt, i); ! if (INTEGRAL_TYPE_P (TREE_TYPE (arg)) ! && INTEGRAL_TYPE_P (TREE_VALUE (targs))) ! ; ! else if (POINTER_TYPE_P (TREE_TYPE (arg)) ! && POINTER_TYPE_P (TREE_VALUE (targs))) ! ; ! else if (TREE_CODE (TREE_TYPE (arg)) ! != TREE_CODE (TREE_VALUE (targs))) ! return false; ! targs = TREE_CHAIN (targs); ! } ! if (targs && !VOID_TYPE_P (TREE_VALUE (targs))) ! return false; ! return true; ! } ! ! /* Return true when STMT is builtins call to CLASS. */ ! ! bool ! gimple_call_builtin_p (gimple stmt, enum built_in_class klass) ! { ! tree fndecl; ! if (is_gimple_call (stmt) ! && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE ! && DECL_BUILT_IN_CLASS (fndecl) == klass) ! return validate_call (stmt, fndecl); ! return false; ! } ! ! /* Return true when STMT is builtins call to CODE of CLASS. */ bool gimple_call_builtin_p (gimple stmt, enum built_in_function code) { tree fndecl; ! if (is_gimple_call (stmt) ! && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE ! && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL ! && DECL_FUNCTION_CODE (fndecl) == code) ! return validate_call (stmt, fndecl); ! return false; } /* Return true if STMT clobbers memory. STMT is required to be a Index: gcc/gimple.h =================================================================== *** gcc/gimple.h (revision 194970) --- gcc/gimple.h (working copy) *************** extern bool walk_stmt_load_store_ops (gi *** 893,898 **** --- 893,899 ---- bool (*)(gimple, tree, void *), bool (*)(gimple, tree, void *)); extern bool gimple_ior_addresses_taken (bitmap, gimple); + extern bool gimple_call_builtin_p (gimple, enum built_in_class); extern bool gimple_call_builtin_p (gimple, enum built_in_function); extern bool gimple_asm_clobbers_memory_p (const_gimple); Index: gcc/tree-ssa-structalias.c =================================================================== *** gcc/tree-ssa-structalias.c (revision 194970) --- gcc/tree-ssa-structalias.c (working copy) *************** find_func_aliases_for_builtin_call (gimp *** 4014,4021 **** vec<ce_s> rhsc = vNULL; varinfo_t fi; ! if (fndecl != NULL_TREE ! && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) /* ??? All builtins that are handled here need to be handled in the alias-oracle query functions explicitly! */ switch (DECL_FUNCTION_CODE (fndecl)) --- 4014,4020 ---- vec<ce_s> rhsc = vNULL; varinfo_t fi; ! if (gimple_call_builtin_p (t, BUILT_IN_NORMAL)) /* ??? All builtins that are handled here need to be handled in the alias-oracle query functions explicitly! */ switch (DECL_FUNCTION_CODE (fndecl)) *************** find_func_clobbers (gimple origt) *** 4768,4775 **** /* For builtins we do not have separate function info. For those we do not generate escapes for we have to generate clobbers/uses. */ ! if (decl ! && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL) switch (DECL_FUNCTION_CODE (decl)) { /* The following functions use and clobber memory pointed to --- 4767,4773 ---- /* For builtins we do not have separate function info. For those we do not generate escapes for we have to generate clobbers/uses. */ ! if (gimple_call_builtin_p (t, BUILT_IN_NORMAL)) switch (DECL_FUNCTION_CODE (decl)) { /* The following functions use and clobber memory pointed to Index: gcc/tree-ssa-strlen.c =================================================================== *** gcc/tree-ssa-strlen.c (revision 194970) --- gcc/tree-ssa-strlen.c (working copy) *************** adjust_last_stmt (strinfo si, gimple stm *** 809,818 **** if (!is_gimple_call (last.stmt)) return; ! callee = gimple_call_fndecl (last.stmt); ! if (callee == NULL_TREE || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL) return; switch (DECL_FUNCTION_CODE (callee)) { case BUILT_IN_MEMCPY: --- 809,818 ---- if (!is_gimple_call (last.stmt)) return; ! if (!gimple_call_builtin_p (last.stmt, BUILT_IN_NORMAL)) return; + callee = gimple_call_fndecl (last.stmt); switch (DECL_FUNCTION_CODE (callee)) { case BUILT_IN_MEMCPY: *************** strlen_optimize_stmt (gimple_stmt_iterat *** 1750,1756 **** if (is_gimple_call (stmt)) { tree callee = gimple_call_fndecl (stmt); ! if (callee && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL) switch (DECL_FUNCTION_CODE (callee)) { case BUILT_IN_STRLEN: --- 1750,1756 ---- if (is_gimple_call (stmt)) { tree callee = gimple_call_fndecl (stmt); ! if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)) switch (DECL_FUNCTION_CODE (callee)) { case BUILT_IN_STRLEN: Index: gcc/testsuite/gcc.dg/torture/pr55890-1.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr55890-1.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr55890-1.c (working copy) *************** *** 0 **** --- 1,6 ---- + /* { dg-do compile } */ + + extern void *memmove(void *, void *, __SIZE_TYPE__); + typedef int (*_TEST_fun_) (); + static _TEST_fun_ i = (_TEST_fun_) memmove; + main() { i(); } Index: gcc/testsuite/gcc.dg/torture/pr55890-2.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr55890-2.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr55890-2.c (working copy) *************** *** 0 **** --- 1,4 ---- + /* { dg-do compile } */ + + extern void *memcpy(); + main() { memcpy(); }