summaryrefslogtreecommitdiff
path: root/gcc/gimple-low.c
diff options
context:
space:
mode:
authordavidxl <davidxl@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-11 20:37:57 +0000
committerdavidxl <davidxl@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-11 20:37:57 +0000
commit850ff64c7c083022e89a9f11d92e2bc9eab5a2f9 (patch)
tree8fba1831628ef1da28cb32bae8e55d3e3fe30a06 /gcc/gimple-low.c
parent6e9b96ec94f8d27211e76e965b97b7716199696f (diff)
downloadgcc-850ff64c7c083022e89a9f11d92e2bc9eab5a2f9.tar.gz
sanity check ic target
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@172276 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-low.c')
-rw-r--r--gcc/gimple-low.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 9968493cd2c..01aeb4940d3 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