aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2013-10-18 19:35:40 +0000
committerAndrew Macleod <amacleod@gcc.gnu.org>2013-10-18 19:35:40 +0000
commit4484a35a86b8b80034c5b17b690c839103ed73b2 (patch)
treedae3f2a566777542e71127cd497bac3fc05fbf29 /gcc/cgraph.c
parentbfaa17c183b35b1a21537b9cd7880dcba2be8540 (diff)
downloadgcc-4484a35a86b8b80034c5b17b690c839103ed73b2.zip
gcc-4484a35a86b8b80034c5b17b690c839103ed73b2.tar.gz
gcc-4484a35a86b8b80034c5b17b690c839103ed73b2.tar.bz2
tree-ssa.h: Don't include gimple-low.h...
* tree-ssa.h: Don't include gimple-low.h, tree-ssa-address.h, sbitmap.h, tree-ssa-threadedge.h, tree-ssa-dom.h, and tree-cfgcleanup.h. * 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. Don't include basic-block.h. * gimplify.c: Add gimple-low to include list. * omp-low.c: Add gimple-low and tree-cfgcleanup.h to include list. * tree-eh.c: Add gimple-low to include list. * tree-nested.c: Likewise. * cfgexpand.c: Add tree-ssa-address.h to include list. * expr.c: Likewise. * gimple-fold.c: Likewise. * gimple-ssa-strength-reduction.c: Likewise. * trans-mem.c: Likewise. * tree-mudflap.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-dom.c: Include tree-ssa-threadedge.h and tree-ssa-dom.h. (degenerate_phi_result): Move to tree-phinodes.c. * tree-ssa-loop-ch.c: Include tree-ssa-threadedge.h. * tree-ssa-threadedge.c: Likewise. * tree-vrp.c: Likewise. * tree-phinodes.c (degenerate_phi_result): Relocate here. * tree-ssa-dom.h (degenerate_phi_result): Remove Prototype. * tree-phinodes.h (degenerate_phi_result): Add prototype. * tree-ssa-copy.c: Include tree-ssa-dom.h. * tree-ssa-forwprop.c: Likewise. * tree-cfgcleanup.c (execute_cleanup_cfg_post_optimizing, pass_data_cleanup_cfg_post_optimizing, make_pass_cleanup_cfg_post_optimizing): Relocate from tree-optimize.c. * tree-optimize.c: Delete File. * graphite.c: Include tree-cfgcleanup.h. * passes.c: Likewise. * tree-cfg.c: Likewise. * tree-profile.c: Likewise. * tree-ssa-dse.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-switch-conversion.c: Don't include tree-ssa-operands.h. * tree-outof-ssa.c: Include sbitmap.h. * tree-ssa-live.c: Likewise. * tree-ssa-propagate.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-stdarg.c: Likewise. * Makefile.in (OBJS): Delete tree-optimize.o. * basic-block.h (gcov_type, gcov_type_unsigned): Move to coretypes.h. * coretypes.h (gcov_type, gcov_type_unsigned): Relocate here. * varasm.c: Include basic-block.h. * cfgloop.h: Include function.h instead of basic-block.h (bb_loop_depth): Move to cfgloop.c. * cfgloop.c (bb_loop_depth): Relocate from cfgloop.h. From-SVN: r203833
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 124ee0a..6ebd0c7 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -2998,4 +2998,99 @@ cgraph_get_body (struct cgraph_node *node)
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"