From e36711f3cd476b24b011f18953aa3ed3e9a70a36 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Sat, 23 Jun 2007 18:17:57 +0000 Subject: re PR tree-optimization/16876 (ICE on testcase with -O3 in fold-const) 2007-06-23 Richard Guenther PR tree-optimization/16876 PR middle-end/29478 * tree.h (CALL_CANNOT_INLINE_P): New macro to access static_flag for CALL_EXPRs. * tree-inline.c (initialize_inlined_parameters): Do not call lang_hooks.tree_inlining.convert_parm_for_inlining. * cgraphbuild.c (initialize_inline_failed): Set inline failed reason for mismatched types. * gimplify.c (gimplify_call_expr): Verify the call expression arguments match the called function type signature. Otherwise mark the call expression to be not considered for inlining using CALL_CANNOT_INLINE_P flag. * ipa-inline.c (cgraph_mark_inline): Honor CALL_CANNOT_INLINE_P on the edges call expression. (cgraph_decide_inlining_of_small_function): Likewise. (cgraph_decide_inlining): Likewise. * c-objc-common.h (LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING): Remove define. * c-tree.h (c_convert_parm_for_inlining): Remove declaration. * c-typeck.c (c_convert_parm_for_inlining): Remove. * langhooks-def.h (lhd_tree_inlining_convert_parm_for_inlining): Remove declaration. (LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING): Remove define. * langhooks.c (lhd_tree_inlining_convert_parm_for_inlining): Remove. * langhooks.h (struct lang_hooks_for_tree_inlining): Remove convert_parm_for_inlining member. * gcc.dg/pr29254.c: The warning is bogus. * gcc.dg/warn-1.c: Likewise. * gcc.dg/assign-warn-3.c: Likewise. * gcc.dg/noncompile/pr16876.c: The testcase is bogus, remove. From-SVN: r125974 --- gcc/gimplify.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'gcc/gimplify.c') diff --git a/gcc/gimplify.c b/gcc/gimplify.c index e4d650b..7f5615e 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2058,7 +2058,7 @@ gimplify_arg (tree *expr_p, tree *pre_p) static enum gimplify_status gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value) { - tree decl; + tree decl, parms, p; enum gimplify_status ret; int i, nargs; @@ -2124,6 +2124,48 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value) nargs = call_expr_nargs (*expr_p); + /* Get argument types for verification. */ + decl = get_callee_fndecl (*expr_p); + parms = NULL_TREE; + if (decl) + parms = TYPE_ARG_TYPES (TREE_TYPE (decl)); + else if (POINTER_TYPE_P (TREE_TYPE (CALL_EXPR_FN (*expr_p)))) + parms = TYPE_ARG_TYPES (TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (*expr_p)))); + + /* Verify if the type of the argument matches that of the function + declaration. If we cannot verify this or there is a mismatch, + mark the call expression so it doesn't get inlined later. */ + if (parms) + { + for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p)) + if (!p + || TREE_VALUE (p) == error_mark_node + || CALL_EXPR_ARG (*expr_p, i) == error_mark_node + || !lang_hooks.types_compatible_p + (TREE_TYPE (CALL_EXPR_ARG (*expr_p, i)), TREE_VALUE (p))) + { + CALL_CANNOT_INLINE_P (*expr_p) = 1; + break; + } + } + else if (decl && DECL_ARGUMENTS (decl)) + { + for (i = 0, p = DECL_ARGUMENTS (decl); i < nargs; + i++, p = TREE_CHAIN (p)) + if (!p + || p == error_mark_node + || CALL_EXPR_ARG (*expr_p, i) == error_mark_node + || !lang_hooks.types_compatible_p + (TREE_TYPE (CALL_EXPR_ARG (*expr_p, i)), TREE_TYPE (p))) + { + CALL_CANNOT_INLINE_P (*expr_p) = 1; + break; + } + } + else if (nargs != 0) + CALL_CANNOT_INLINE_P (*expr_p) = 1; + + /* Finally, gimplify the function arguments. */ for (i = (PUSH_ARGS_REVERSED ? nargs - 1 : 0); PUSH_ARGS_REVERSED ? i >= 0 : i < nargs; PUSH_ARGS_REVERSED ? i-- : i++) -- cgit v1.1