summaryrefslogtreecommitdiff
path: root/gcc/gimple-low.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2011-05-11 11:13:27 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2011-05-11 11:13:27 +0000
commitc41143fb1d63596ff2a0f6da741b4bae73b8be16 (patch)
treed70c0763693cfef7bc877f21e079986944261a5f /gcc/gimple-low.c
parenteb0badc13724022c8828a55e516d0eecdc487cc3 (diff)
downloadgcc-c41143fb1d63596ff2a0f6da741b4bae73b8be16.tar.gz
2011-05-11 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 173647 using svnmerge git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@173652 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-low.c')
-rw-r--r--gcc/gimple-low.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 67087a0aadc..3afa0b2582d 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -208,25 +208,28 @@ 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;
+ /* 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. */
- fndecl = gimple_call_fndecl (stmt);
- parms = NULL_TREE;
if (fndecl)
parms = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
- else if (POINTER_TYPE_P (TREE_TYPE (gimple_call_fn (stmt))))
- parms = TYPE_ARG_TYPES (TREE_TYPE (TREE_TYPE (gimple_call_fn (stmt))));
+ 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,
@@ -273,6 +276,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
@@ -758,6 +780,9 @@ lower_gimple_return (gimple_stmt_iterator *gsi, struct lower_data *data)
/* Generate a goto statement and remove the return statement. */
found:
+ /* When not optimizing, make sure user returns are preserved. */
+ if (!optimize && gimple_has_location (stmt))
+ DECL_ARTIFICIAL (tmp_rs.label) = 0;
t = gimple_build_goto (tmp_rs.label);
gimple_set_location (t, gimple_location (stmt));
gimple_set_block (t, gimple_block (stmt));