i = gsi_start (lowered_body);
lower_gimple_bind (&i, &data);
- /* Once the old body has been lowered, replace it with the new
- lowered sequence. */
- gimple_set_body (current_function_decl, lowered_body);
-
i = gsi_last (lowered_body);
/* If the function falls off the end, we need a null return statement.
and insert. */
disp_var = create_tmp_var (ptr_type_node, "setjmpvar");
arg = build_addr (disp_label, current_function_decl);
- t = implicit_built_in_decls[BUILT_IN_SETJMP_DISPATCHER];
+ t = builtin_decl_implicit (BUILT_IN_SETJMP_DISPATCHER);
x = gimple_build_call (t, 1, arg);
gimple_call_set_lhs (x, disp_var);
gsi_insert_after (&i, x, GSI_CONTINUE_LINKING);
}
+ /* Once the old body has been lowered, replace it with the new
+ lowered sequence. */
+ gimple_set_body (current_function_decl, lowered_body);
+
gcc_assert (data.block == DECL_INITIAL (current_function_decl));
BLOCK_SUBBLOCKS (data.block)
= blocks_nreverse (BLOCK_SUBBLOCKS (data.block));
PROP_gimple_lcf, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
- TODO_dump_func /* todo_flags_finish */
+ 0 /* todo_flags_finish */
}
};
+
/* 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);
if (fndecl)
parms = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
else
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
- || gimple_call_arg (stmt, i) == error_mark_node
- || !fold_convertible_p (DECL_ARG_TYPE (p),
- gimple_call_arg (stmt, i)))
+ || arg == error_mark_node
+ || (!types_compatible_p (DECL_ARG_TYPE (p), TREE_TYPE (arg))
+ && !fold_convertible_p (DECL_ARG_TYPE (p), arg)))
return false;
}
}
{
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
- || gimple_call_arg (stmt, i) == error_mark_node
+ || arg == error_mark_node
|| TREE_CODE (TREE_VALUE (p)) == VOID_TYPE
- || !fold_convertible_p (TREE_VALUE (p),
- gimple_call_arg (stmt, i)))
+ || (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg))
+ && !fold_convertible_p (TREE_VALUE (p), arg)))
return false;
}
}
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
do it explicitly. DATA is passed through the recursion. */
static void
-lower_sequence (gimple_seq seq, struct lower_data *data)
+lower_sequence (gimple_seq *seq, struct lower_data *data)
{
gimple_stmt_iterator gsi;
- for (gsi = gsi_start (seq); !gsi_end_p (gsi); )
+ for (gsi = gsi_start (*seq); !gsi_end_p (gsi); )
lower_stmt (&gsi, data);
}
stmt = gsi_stmt (*gsi);
- lower_sequence (gimple_omp_body (stmt), data);
- gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
- gsi_insert_seq_before (gsi, gimple_omp_body (stmt), GSI_SAME_STMT);
+ lower_sequence (gimple_omp_body_ptr (stmt), data);
+ gsi_insert_seq_after (gsi, gimple_omp_body (stmt), GSI_CONTINUE_LINKING);
gimple_omp_set_body (stmt, NULL);
- gsi_remove (gsi, false);
+ gsi_next (gsi);
}
case GIMPLE_TRY:
{
bool try_cannot_fallthru;
- lower_sequence (gimple_try_eval (stmt), data);
+ lower_sequence (gimple_try_eval_ptr (stmt), data);
try_cannot_fallthru = data->cannot_fallthru;
data->cannot_fallthru = false;
- lower_sequence (gimple_try_cleanup (stmt), data);
+ lower_sequence (gimple_try_cleanup_ptr (stmt), data);
/* See gimple_stmt_may_fallthru for the rationale. */
if (gimple_try_kind (stmt) == GIMPLE_TRY_FINALLY)
{
case GIMPLE_CATCH:
data->cannot_fallthru = false;
- lower_sequence (gimple_catch_handler (stmt), data);
+ lower_sequence (gimple_catch_handler_ptr (stmt), data);
break;
case GIMPLE_EH_FILTER:
data->cannot_fallthru = false;
- lower_sequence (gimple_eh_filter_failure (stmt), data);
+ lower_sequence (gimple_eh_filter_failure_ptr (stmt), data);
+ break;
+
+ case GIMPLE_EH_ELSE:
+ lower_sequence (gimple_eh_else_n_body_ptr (stmt), data);
+ lower_sequence (gimple_eh_else_e_body_ptr (stmt), data);
break;
case GIMPLE_NOP:
data->cannot_fallthru = false;
return;
+ case GIMPLE_TRANSACTION:
+ lower_sequence (gimple_transaction_body_ptr (stmt), data);
+ break;
+
default:
gcc_unreachable ();
}
}
record_vars (gimple_bind_vars (stmt));
- lower_sequence (gimple_bind_body (stmt), data);
+ lower_sequence (gimple_bind_body_ptr (stmt), data);
if (new_block)
{
if (gimple_seq_may_fallthru (gimple_try_eval (stmt)))
return true;
- i = gsi_start (gimple_try_cleanup (stmt));
+ i = gsi_start (*gimple_try_cleanup_ptr (stmt));
switch (gimple_code (gsi_stmt (i)))
{
case GIMPLE_CATCH:
return (gimple_seq_may_fallthru (gimple_try_eval (stmt))
&& gimple_seq_may_fallthru (gimple_try_cleanup (stmt)));
+ case GIMPLE_EH_ELSE:
+ return (gimple_seq_may_fallthru (gimple_eh_else_n_body (stmt))
+ || gimple_seq_may_fallthru (gimple_eh_else_e_body (stmt)));
+
case GIMPLE_CALL:
/* Functions that do not return do not fall through. */
return (gimple_call_flags (stmt) & ECF_NORETURN) == 0;
/* Build '__builtin_setjmp_setup (BUF, NEXT_LABEL)' and insert. */
arg = build_addr (next_label, current_function_decl);
- t = implicit_built_in_decls[BUILT_IN_SETJMP_SETUP];
+ t = builtin_decl_implicit (BUILT_IN_SETJMP_SETUP);
g = gimple_build_call (t, 2, gimple_call_arg (stmt, 0), arg);
gimple_set_location (g, loc);
gimple_set_block (g, gimple_block (stmt));
/* Build '__builtin_setjmp_receiver (NEXT_LABEL)' and insert. */
arg = build_addr (next_label, current_function_decl);
- t = implicit_built_in_decls[BUILT_IN_SETJMP_RECEIVER];
+ t = builtin_decl_implicit (BUILT_IN_SETJMP_RECEIVER);
g = gimple_build_call (t, 1, arg);
gimple_set_location (g, loc);
gimple_set_block (g, gimple_block (stmt));