gimple_check_call_matching_types() was being called from 3 or 4 different files,and seemed more appropriate as a cgraph routine (which called it 3 times). So I moved that and its helper to cgraph.c.
After that, I only needed to update 4 .c files to directly include gimple-low.h
bootstraps on x86_64-unknown-linux-gnu with no new regressions. OK? Andrew
* tree-ssa.h: Remove gimple-low.h from include list. * gimple-low.c (gimple_check_call_arg, gimple_check_call_matching_types): Move to cgraph.c. * gimple-low.h: Remove prototype. * cgraph.c: (gimple_check_call_arg, gimple_check_call_matching_types): Relocate from gimple-low.c. * cgraph.h: Add prototype, * gimplify.c: Add gimple-low to include list. * omp-low.c: Add gimple-low to include list. * tree-eh.c: Add gimple-low to include list. * tree-nested.c: Add gimple-low to include list. *** T2/tree-ssa.h 2013-10-17 09:36:38.577417384 -0400 --- tree-ssa.h 2013-10-17 09:37:07.962843834 -0400 *************** along with GCC; see the file COPYING3. *** 36,42 **** #include "tree-ssa-address.h" #include "tree-ssa-loop.h" #include "tree-into-ssa.h" - #include "gimple-low.h" #include "tree-dfa.h" /* Mapping for redirected edges. */ --- 36,41 ---- *** T2/gimple-low.c 2013-10-17 09:36:38.544418194 -0400 --- gimple-low.c 2013-10-17 10:43:00.860672918 -0400 *************** along with GCC; see the file COPYING3. *** 32,37 **** --- 32,38 ---- #include "diagnostic-core.h" #include "tree-pass.h" #include "langhooks.h" + #include "gimple-low.h" /* The differences between High GIMPLE and Low GIMPLE are the following: *************** make_pass_lower_cf (gcc::context *ctxt) *** 215,317 **** return new pass_lower_cf (ctxt); } - - - /* Verify if the type of the argument matches that of the function - declaration. If we cannot verify this or there is a mismatch, - return false. */ - - static bool - gimple_check_call_args (gimple stmt, tree fndecl, bool args_count_match) - { - tree parms, p; - unsigned int i, nargs; - - /* Calls to internal functions always match their signature. */ - if (gimple_call_internal_p (stmt)) - return true; - - nargs = gimple_call_num_args (stmt); - - /* Get argument types for verification. */ - if (fndecl) - parms = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); - else - parms = TYPE_ARG_TYPES (gimple_call_fntype (stmt)); - - /* Verify if the type of the argument matches that of the function - declaration. If we cannot verify this or there is a mismatch, - return false. */ - if (fndecl && DECL_ARGUMENTS (fndecl)) - { - for (i = 0, p = DECL_ARGUMENTS (fndecl); - i < nargs; - i++, p = DECL_CHAIN (p)) - { - tree arg; - /* We cannot distinguish a varargs function from the case - of excess parameters, still deferring the inlining decision - to the callee is possible. */ - if (!p) - break; - arg = gimple_call_arg (stmt, i); - if (p == error_mark_node - || arg == error_mark_node - || (!types_compatible_p (DECL_ARG_TYPE (p), TREE_TYPE (arg)) - && !fold_convertible_p (DECL_ARG_TYPE (p), arg))) - return false; - } - if (args_count_match && p) - return false; - } - else if (parms) - { - for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p)) - { - tree arg; - /* If this is a varargs function defer inlining decision - to callee. */ - if (!p) - break; - arg = gimple_call_arg (stmt, i); - if (TREE_VALUE (p) == error_mark_node - || arg == error_mark_node - || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE - || (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg)) - && !fold_convertible_p (TREE_VALUE (p), arg))) - return false; - } - } - else - { - if (nargs != 0) - return false; - } - return true; - } - - /* Verify if the type of the argument and lhs of CALL_STMT matches - that of the function declaration CALLEE. If ARGS_COUNT_MATCH is - true, the arg count needs to be the same. - If we cannot verify this or there is a mismatch, return false. */ - - bool - gimple_check_call_matching_types (gimple call_stmt, tree callee, - bool args_count_match) - { - tree lhs; - - if ((DECL_RESULT (callee) - && !DECL_BY_REFERENCE (DECL_RESULT (callee)) - && (lhs = gimple_call_lhs (call_stmt)) != NULL_TREE - && !useless_type_conversion_p (TREE_TYPE (DECL_RESULT (callee)), - TREE_TYPE (lhs)) - && !fold_convertible_p (TREE_TYPE (DECL_RESULT (callee)), lhs)) - || !gimple_check_call_args (call_stmt, callee, args_count_match)) - return false; - return true; - } - /* Lower sequence SEQ. Unlike gimplification the statements are not relowered when they are changed -- if this has to be done, the lowering routine must do it explicitly. DATA is passed through the recursion. */ --- 216,221 ---- *** T2/gimple-low.h 2013-10-17 09:36:38.544418194 -0400 --- gimple-low.h 2013-10-17 10:38:16.459642108 -0400 *************** along with GCC; see the file COPYING3. *** 20,26 **** #ifndef GCC_GIMPLE_LOW_H #define GCC_GIMPLE_LOW_H - extern bool gimple_check_call_matching_types (gimple, tree, bool); extern bool gimple_stmt_may_fallthru (gimple); extern bool gimple_seq_may_fallthru (gimple_seq); extern void record_vars_into (tree, tree); --- 20,25 ---- *** T2/cgraph.c 2013-10-17 09:36:38.526418635 -0400 --- cgraph.c 2013-10-17 10:36:35.668609863 -0400 *************** cgraph_get_body (struct cgraph_node *nod *** 2998,3001 **** --- 2998,3096 ---- return true; } + /* Verify if the type of the argument matches that of the function + declaration. If we cannot verify this or there is a mismatch, + return false. */ + + static bool + gimple_check_call_args (gimple stmt, tree fndecl, bool args_count_match) + { + tree parms, p; + unsigned int i, nargs; + + /* Calls to internal functions always match their signature. */ + if (gimple_call_internal_p (stmt)) + return true; + + nargs = gimple_call_num_args (stmt); + + /* Get argument types for verification. */ + if (fndecl) + parms = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); + else + parms = TYPE_ARG_TYPES (gimple_call_fntype (stmt)); + + /* Verify if the type of the argument matches that of the function + declaration. If we cannot verify this or there is a mismatch, + return false. */ + if (fndecl && DECL_ARGUMENTS (fndecl)) + { + for (i = 0, p = DECL_ARGUMENTS (fndecl); + i < nargs; + i++, p = DECL_CHAIN (p)) + { + tree arg; + /* We cannot distinguish a varargs function from the case + of excess parameters, still deferring the inlining decision + to the callee is possible. */ + if (!p) + break; + arg = gimple_call_arg (stmt, i); + if (p == error_mark_node + || arg == error_mark_node + || (!types_compatible_p (DECL_ARG_TYPE (p), TREE_TYPE (arg)) + && !fold_convertible_p (DECL_ARG_TYPE (p), arg))) + return false; + } + if (args_count_match && p) + return false; + } + else if (parms) + { + for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p)) + { + tree arg; + /* If this is a varargs function defer inlining decision + to callee. */ + if (!p) + break; + arg = gimple_call_arg (stmt, i); + if (TREE_VALUE (p) == error_mark_node + || arg == error_mark_node + || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE + || (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg)) + && !fold_convertible_p (TREE_VALUE (p), arg))) + return false; + } + } + else + { + if (nargs != 0) + return false; + } + return true; + } + + /* Verify if the type of the argument and lhs of CALL_STMT matches + that of the function declaration CALLEE. If ARGS_COUNT_MATCH is + true, the arg count needs to be the same. + If we cannot verify this or there is a mismatch, return false. */ + + bool + gimple_check_call_matching_types (gimple call_stmt, tree callee, + bool args_count_match) + { + tree lhs; + + if ((DECL_RESULT (callee) + && !DECL_BY_REFERENCE (DECL_RESULT (callee)) + && (lhs = gimple_call_lhs (call_stmt)) != NULL_TREE + && !useless_type_conversion_p (TREE_TYPE (DECL_RESULT (callee)), + TREE_TYPE (lhs)) + && !fold_convertible_p (TREE_TYPE (DECL_RESULT (callee)), lhs)) + || !gimple_check_call_args (call_stmt, callee, args_count_match)) + return false; + return true; + } + #include "gt-cgraph.h" *** T2/cgraph.h 2013-10-17 09:36:38.526418635 -0400 --- cgraph.h 2013-10-17 10:38:14.827641692 -0400 *************** void cgraph_speculative_call_info (struc *** 742,747 **** --- 742,748 ---- struct cgraph_edge *&, struct cgraph_edge *&, struct ipa_ref *&); + extern bool gimple_check_call_matching_types (gimple, tree, bool); /* In cgraphunit.c */ struct asm_node *add_asm_node (tree); *** T2/gimplify.c 2013-10-17 09:36:38.545418169 -0400 --- gimplify.c 2013-10-17 10:43:24.707672416 -0400 *************** along with GCC; see the file COPYING3. *** 43,48 **** --- 43,49 ---- #include "splay-tree.h" #include "vec.h" #include "omp-low.h" + #include "gimple-low.h" #include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name */ #include "tree-pass.h" /* FIXME: only for PROP_gimple_any */ *** T2/omp-low.c 2013-10-17 09:36:38.557417875 -0400 --- omp-low.c 2013-10-17 10:43:17.390672611 -0400 *************** along with GCC; see the file COPYING3. *** 44,49 **** --- 44,50 ---- #include "cfgloop.h" #include "target.h" #include "omp-low.h" + #include "gimple-low.h" /* Lowering of OpenMP parallel and workshare constructs proceeds in two *** T2/tree-eh.c 2013-10-17 09:36:38.572417507 -0400 --- tree-eh.c 2013-10-17 10:43:12.669672718 -0400 *************** along with GCC; see the file COPYING3. *** 36,41 **** --- 36,42 ---- #include "gimple.h" #include "target.h" #include "cfgloop.h" + #include "gimple-low.h" /* In some instances a tree and a gimple need to be stored in a same table, i.e. in hash tables. This is a structure to do this. */ *** T2/tree-nested.c 2013-10-17 09:36:38.574417458 -0400 --- tree-nested.c 2013-10-17 10:43:07.892672811 -0400 *************** *** 33,38 **** --- 33,39 ---- #include "expr.h" /* FIXME: For STACK_SAVEAREA_MODE and SAVE_NONLOCAL. */ #include "langhooks.h" #include "pointer-set.h" + #include "gimple-low.h" /* The object of this pass is to lower the representation of a set of nested