From 26e0228f565f3d57769d18fa362a300ff51ba1e7 Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Mon, 11 Apr 2011 20:37:57 +0000 Subject: sanity check ic target From-SVN: r172276 --- gcc/gimple-low.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'gcc/gimple-low.c') diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c index 9968493..01aeb49 100644 --- a/gcc/gimple-low.c +++ b/gcc/gimple-low.c @@ -208,20 +208,20 @@ struct gimple_opt_pass pass_lower_cf = }; + /* 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. */ -bool -gimple_check_call_args (gimple stmt) +static bool +gimple_check_call_args (gimple stmt, tree fndecl) { - tree fndecl, parms, p; + tree parms, p; unsigned int i, nargs; nargs = gimple_call_num_args (stmt); /* Get argument types for verification. */ - fndecl = gimple_call_fndecl (stmt); if (fndecl) parms = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); else @@ -272,6 +272,25 @@ gimple_check_call_args (gimple stmt) return true; } +/* Verify if the type of the argument and lhs of CALL_STMT matches + that of the function declaration CALLEE. + If we cannot verify this or there is a mismatch, return false. */ + +bool +gimple_check_call_matching_types (gimple call_stmt, tree callee) +{ + 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)) + 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 -- cgit v1.1