[PATCH] RIP lang_hooks.tree_inlining.convert_parm_for_inlining
Richard Guenther
rguenther@suse.de
Fri Jun 22 17:22:00 GMT 2007
Not as nice as possible, but this get's rid of the
convert_parm_for_inlining langhook and it's associated problems of
late (wrong) warnings. It also get's me further on the removal
of the types_compatible langhook from the middle-end.
Bootstrapped and tested on x86_64-unknown-linux-gnu for C and C++
(other langs don't use the hook).
Does this look ok?
Thanks,
Richard.
2007-06-22 Richard Guenther <rguenther@suse.de>
* 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 TREE_STATIC flag.
* ipa-inline.c (cgraph_mark_inline): Honor TREE_STATIC 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.
* testsuite/gcc.dg/pr29254.c: The warning is bogus.
Index: gcc/testsuite/gcc.dg/pr29254.c
===================================================================
*** gcc.orig/testsuite/gcc.dg/pr29254.c 2007-06-22 16:32:25.000000000 +0200
--- gcc/testsuite/gcc.dg/pr29254.c 2007-06-22 16:33:08.000000000 +0200
***************
*** 1,6 ****
/* { dg-do compile } */
/* { dg-options "-O3 -Werror" } */
- /* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */
list_compare (int * list1)
{
--- 1,5 ----
*************** value_compare (int * a)
*** 18,22 ****
func2 (const int * fb)
{
! func1 ((int *) fb); /* { dg-error "discards qualifiers" } */
}
--- 17,21 ----
func2 (const int * fb)
{
! func1 ((int *) fb); /* { dg-bogus "discards qualifiers" } */
}
Index: gcc/tree-inline.c
===================================================================
*** gcc.orig/tree-inline.c 2007-06-22 16:32:25.000000000 +0200
--- gcc/tree-inline.c 2007-06-22 16:33:08.000000000 +0200
*************** initialize_inlined_parameters (copy_body
*** 1457,1463 ****
tree a;
tree p;
tree vars = NULL_TREE;
- int argnum = 0;
call_expr_arg_iterator iter;
tree static_chain = CALL_EXPR_STATIC_CHAIN (exp);
--- 1457,1462 ----
*************** initialize_inlined_parameters (copy_body
*** 1468,1484 ****
equivalent VAR_DECL, appropriately initialized. */
for (p = parms, a = first_call_expr_arg (exp, &iter); p;
a = next_call_expr_arg (&iter), p = TREE_CHAIN (p))
! {
! tree value;
!
! ++argnum;
!
! /* Find the initializer. */
! value = lang_hooks.tree_inlining.convert_parm_for_inlining
! (p, a, fn, argnum);
!
! setup_one_parameter (id, p, value, fn, bb, &vars);
! }
/* Initialize the static chain. */
p = DECL_STRUCT_FUNCTION (fn)->static_chain_decl;
--- 1467,1473 ----
equivalent VAR_DECL, appropriately initialized. */
for (p = parms, a = first_call_expr_arg (exp, &iter); p;
a = next_call_expr_arg (&iter), p = TREE_CHAIN (p))
! setup_one_parameter (id, p, a, fn, bb, &vars);
/* Initialize the static chain. */
p = DECL_STRUCT_FUNCTION (fn)->static_chain_decl;
Index: gcc/cgraphbuild.c
===================================================================
*** gcc.orig/cgraphbuild.c 2007-06-22 16:32:25.000000000 +0200
--- gcc/cgraphbuild.c 2007-06-22 16:33:08.000000000 +0200
*************** initialize_inline_failed (struct cgraph_
*** 99,104 ****
--- 99,106 ----
"considered for inlining");
else if (!node->local.inlinable)
e->inline_failed = N_("function not inlinable");
+ else if (TREE_STATIC (e->call_stmt))
+ e->inline_failed = N_("mismatched arguments");
else
e->inline_failed = N_("function not considered for inlining");
}
Index: gcc/gimplify.c
===================================================================
*** gcc.orig/gimplify.c 2007-06-22 16:32:25.000000000 +0200
--- gcc/gimplify.c 2007-06-22 17:54:50.000000000 +0200
*************** gimplify_arg (tree *expr_p, tree *pre_p)
*** 2047,2053 ****
static enum gimplify_status
gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
{
! tree decl;
enum gimplify_status ret;
int i, nargs;
--- 2047,2053 ----
static enum gimplify_status
gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
{
! tree decl, parms, p;
enum gimplify_status ret;
int i, nargs;
*************** gimplify_call_expr (tree *expr_p, tree *
*** 2113,2118 ****
--- 2113,2145 ----
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
+ || 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)))
+ {
+ TREE_STATIC (*expr_p) = 1;
+ break;
+ }
+ }
+ else
+ TREE_STATIC (*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++)
Index: gcc/ipa-inline.c
===================================================================
*** gcc.orig/ipa-inline.c 2007-06-22 16:32:25.000000000 +0200
--- gcc/ipa-inline.c 2007-06-22 16:33:08.000000000 +0200
*************** cgraph_mark_inline (struct cgraph_edge *
*** 295,301 ****
for (e = what->callers; e; e = next)
{
next = e->next_caller;
! if (e->caller == to && e->inline_failed)
{
cgraph_mark_inline_edge (e, true);
if (e == edge)
--- 295,301 ----
for (e = what->callers; e; e = next)
{
next = e->next_caller;
! if (e->caller == to && e->inline_failed && !TREE_STATIC (e->call_stmt))
{
cgraph_mark_inline_edge (e, true);
if (e == edge)
*************** cgraph_mark_inline (struct cgraph_edge *
*** 303,309 ****
times++;
}
}
! gcc_assert (times);
return edge;
}
--- 303,309 ----
times++;
}
}
! /*gcc_assert (times);*/
return edge;
}
*************** cgraph_decide_inlining_of_small_function
*** 885,891 ****
}
gcc_assert (edge->aux);
edge->aux = NULL;
! if (!edge->inline_failed)
continue;
/* When not having profile info ready we don't weight by any way the
--- 885,891 ----
}
gcc_assert (edge->aux);
edge->aux = NULL;
! if (!edge->inline_failed || TREE_STATIC (edge->call_stmt))
continue;
/* When not having profile info ready we don't weight by any way the
*************** cgraph_decide_inlining (void)
*** 1076,1082 ****
for (e = node->callers; e; e = next)
{
next = e->next_caller;
! if (!e->inline_failed)
continue;
if (cgraph_recursive_inlining_p (e->caller, e->callee,
&e->inline_failed))
--- 1076,1082 ----
for (e = node->callers; e; e = next)
{
next = e->next_caller;
! if (!e->inline_failed || TREE_STATIC (e->call_stmt))
continue;
if (cgraph_recursive_inlining_p (e->caller, e->callee,
&e->inline_failed))
Index: gcc/c-objc-common.h
===================================================================
*** gcc.orig/c-objc-common.h 2007-06-13 12:12:32.000000000 +0200
--- gcc/c-objc-common.h 2007-06-22 16:42:08.000000000 +0200
*************** extern void c_initialize_diagnostics (di
*** 89,97 ****
#undef LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS
#define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS \
c_disregard_inline_limits
- #undef LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING
- #define LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \
- c_convert_parm_for_inlining
#undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
#define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN c_dump_tree
--- 89,94 ----
Index: gcc/c-tree.h
===================================================================
*** gcc.orig/c-tree.h 2007-06-13 12:12:32.000000000 +0200
--- gcc/c-tree.h 2007-06-22 16:42:26.000000000 +0200
*************** extern tree c_start_case (tree);
*** 577,583 ****
extern void c_finish_case (tree);
extern tree build_asm_expr (tree, tree, tree, tree, bool);
extern tree build_asm_stmt (tree, tree);
- extern tree c_convert_parm_for_inlining (tree, tree, tree, int);
extern int c_types_compatible_p (tree, tree);
extern tree c_begin_compound_stmt (bool);
extern tree c_end_compound_stmt (tree, bool);
--- 577,582 ----
Index: gcc/c-typeck.c
===================================================================
*** gcc.orig/c-typeck.c 2007-06-19 18:00:51.000000000 +0200
--- gcc/c-typeck.c 2007-06-22 16:43:07.000000000 +0200
*************** convert_for_assignment (tree type, tree
*** 4247,4283 ****
return error_mark_node;
}
-
- /* Convert VALUE for assignment into inlined parameter PARM. ARGNUM
- is used for error and warning reporting and indicates which argument
- is being processed. */
-
- tree
- c_convert_parm_for_inlining (tree parm, tree value, tree fn, int argnum)
- {
- tree ret, type;
-
- /* If FN was prototyped at the call site, the value has been converted
- already in convert_arguments.
- However, we might see a prototype now that was not in place when
- the function call was seen, so check that the VALUE actually matches
- PARM before taking an early exit. */
- if (!value
- || (TYPE_ARG_TYPES (TREE_TYPE (fn))
- && (TYPE_MAIN_VARIANT (TREE_TYPE (parm))
- == TYPE_MAIN_VARIANT (TREE_TYPE (value)))))
- return value;
-
- type = TREE_TYPE (parm);
- ret = convert_for_assignment (type, value,
- ic_argpass_nonproto, fn,
- fn, argnum);
- if (targetm.calls.promote_prototypes (TREE_TYPE (fn))
- && INTEGRAL_TYPE_P (type)
- && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
- ret = default_conversion (ret);
- return ret;
- }
/* If VALUE is a compound expr all of whose expressions are constant, then
return its value. Otherwise, return error_mark_node.
--- 4247,4252 ----
Index: gcc/langhooks-def.h
===================================================================
*** gcc.orig/langhooks-def.h 2007-06-13 12:12:39.000000000 +0200
--- gcc/langhooks-def.h 2007-06-22 16:41:49.000000000 +0200
*************** extern tree lhd_tree_inlining_walk_subtr
*** 73,79 ****
extern int lhd_tree_inlining_cannot_inline_tree_fn (tree *);
extern int lhd_tree_inlining_disregard_inline_limits (tree);
extern int lhd_tree_inlining_auto_var_in_fn_p (tree, tree);
- extern tree lhd_tree_inlining_convert_parm_for_inlining (tree, tree, tree, int);
extern void lhd_initialize_diagnostics (struct diagnostic_context *);
extern tree lhd_callgraph_analyze_expr (tree *, int *, tree);
--- 73,78 ----
*************** extern void lhd_omp_firstprivatize_type_
*** 145,152 ****
lhd_tree_inlining_auto_var_in_fn_p
#define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P \
hook_bool_tree_tree_false
- #define LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \
- lhd_tree_inlining_convert_parm_for_inlining
#define LANG_HOOKS_TREE_INLINING_INITIALIZER { \
LANG_HOOKS_TREE_INLINING_WALK_SUBTREES, \
--- 144,149 ----
*************** extern void lhd_omp_firstprivatize_type_
*** 154,160 ****
LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS, \
LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P, \
LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P, \
- LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING \
}
#define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR lhd_callgraph_analyze_expr
--- 151,156 ----
Index: gcc/langhooks.c
===================================================================
*** gcc.orig/langhooks.c 2007-06-13 12:12:33.000000000 +0200
--- gcc/langhooks.c 2007-06-22 16:42:54.000000000 +0200
*************** lhd_tree_inlining_auto_var_in_fn_p (tree
*** 330,347 ****
|| TREE_CODE (var) == RESULT_DECL));
}
- /* lang_hooks.tree_inlining.convert_parm_for_inlining performs any
- language-specific conversion before assigning VALUE to PARM. */
-
- tree
- lhd_tree_inlining_convert_parm_for_inlining (tree parm ATTRIBUTE_UNUSED,
- tree value,
- tree fndecl ATTRIBUTE_UNUSED,
- int argnum ATTRIBUTE_UNUSED)
- {
- return value;
- }
-
/* lang_hooks.tree_dump.dump_tree: Dump language-specific parts of tree
nodes. Returns nonzero if it does not want the usual dumping of the
second argument. */
--- 330,335 ----
Index: gcc/langhooks.h
===================================================================
*** gcc.orig/langhooks.h 2007-06-13 12:12:33.000000000 +0200
--- gcc/langhooks.h 2007-06-22 16:41:55.000000000 +0200
*************** struct lang_hooks_for_tree_inlining
*** 42,48 ****
int (*disregard_inline_limits) (tree);
int (*auto_var_in_fn_p) (tree, tree);
bool (*var_mod_type_p) (tree, tree);
- tree (*convert_parm_for_inlining) (tree, tree, tree, int);
};
struct lang_hooks_for_callgraph
--- 42,47 ----
More information about the Gcc-patches
mailing list