+2011-04-08 Richard Guenther <rguenther@suse.de>
+
+ * gimple.h (gimple_call_fntype): New function.
+ (gimple_call_return_type): Use it.
+ * expr.c (expand_expr_real_1): Use gimple_call_fntype.
+ * gimple-low.c (gimple_check_call_args): Likewise.
+ * gimple.c (gimple_call_flags): Likewise.
+ (gimple_call_arg_flags): Likewise.
+ (gimple_call_return_flags): Likewise.
+ * tree-cfg.c (verify_gimple_call): Likewise.
+ (do_warn_unused_result): Likewise.
+ * tree-ssa-ccp.c (ccp_fold_stmt): Likewise.
+ * value-prof.c (gimple_ic_transform): Fix fndecl check.
+
2011-04-08 Dmitry Melnik <dm@ispras.ru>
PR rtl-optimization/48235
&& (g = SSA_NAME_DEF_STMT (ssa_name))
&& gimple_code (g) == GIMPLE_CALL)
pmode = promote_function_mode (type, mode, &unsignedp,
- TREE_TYPE
- (TREE_TYPE (gimple_call_fn (g))),
+ gimple_call_fntype (g),
2);
else
pmode = promote_decl_mode (exp, &unsignedp);
/* 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,
{
int flags;
tree decl = gimple_call_fndecl (stmt);
- tree t;
if (decl)
flags = flags_from_decl_or_type (decl);
else
{
- t = TREE_TYPE (gimple_call_fn (stmt));
- if (t && TREE_CODE (t) == POINTER_TYPE)
- flags = flags_from_decl_or_type (TREE_TYPE (t));
+ tree t = TREE_TYPE (gimple_call_fn (stmt));
+ /* ??? We can end up being called from gimple_set_modified from
+ gsi_remove in which case the function being called can
+ be a released SSA name. Give up in that case. */
+ if (t)
+ flags = flags_from_decl_or_type (gimple_call_fntype (stmt));
else
flags = 0;
}
int
gimple_call_arg_flags (const_gimple stmt, unsigned arg)
{
- tree type = TREE_TYPE (TREE_TYPE (gimple_call_fn (stmt)));
+ tree type = gimple_call_fntype (stmt);
tree attr = lookup_attribute ("fn spec", TYPE_ATTRIBUTES (type));
if (!attr)
return 0;
if (gimple_call_flags (stmt) & ECF_MALLOC)
return ERF_NOALIAS;
- type = TREE_TYPE (TREE_TYPE (gimple_call_fn (stmt)));
+ type = gimple_call_fntype (stmt);
attr = lookup_attribute ("fn spec", TYPE_ATTRIBUTES (type));
if (!attr)
return 0;
return gimple_op (gs, 1);
}
+/* Return the function type of the function called by GS. */
+
+static inline tree
+gimple_call_fntype (const_gimple gs)
+{
+ return TREE_TYPE (TREE_TYPE (gimple_call_fn (gs)));
+}
/* Return a pointer to the tree node representing the function called by call
statement GS. */
static inline tree
gimple_call_return_type (const_gimple gs)
{
- tree fn = gimple_call_fn (gs);
- tree type = TREE_TYPE (fn);
-
- /* See through the pointer. */
- type = TREE_TYPE (type);
+ tree type = gimple_call_fntype (gs);
- /* The type returned by a FUNCTION_DECL is the type of its
+ /* The type returned by a function is the type of its
function type. */
return TREE_TYPE (type);
}
return true;
}
- fntype = TREE_TYPE (TREE_TYPE (fn));
+ fntype = gimple_call_fntype (stmt);
if (gimple_call_lhs (stmt)
&& !useless_type_conversion_p (TREE_TYPE (gimple_call_lhs (stmt)),
TREE_TYPE (fntype))
LHS. All calls whose value is ignored should be
represented like this. Look for the attribute. */
fdecl = gimple_call_fndecl (g);
- ftype = TREE_TYPE (TREE_TYPE (gimple_call_fn (g)));
+ ftype = gimple_call_fntype (g);
if (lookup_attribute ("warn_unused_result", TYPE_ATTRIBUTES (ftype)))
{
this can use the argument slot types for type verification
instead of the current argument type. We also can safely
drop qualifiers here as we are dealing with constants anyway. */
- argt = TYPE_ARG_TYPES (TREE_TYPE (TREE_TYPE (gimple_call_fn (stmt))));
+ argt = TYPE_ARG_TYPES (gimple_call_fntype (stmt));
for (i = 0; i < gimple_call_num_args (stmt) && argt;
++i, argt = TREE_CHAIN (argt))
{
histogram_value histogram;
gcov_type val, count, all, bb_all;
gcov_type prob;
- tree callee;
gimple modify;
struct cgraph_node *direct_call;
if (gimple_code (stmt) != GIMPLE_CALL)
return false;
- callee = gimple_call_fn (stmt);
-
- if (TREE_CODE (callee) == FUNCTION_DECL)
+ if (gimple_call_fndecl (stmt) != NULL_TREE)
return false;
histogram = gimple_histogram_value_of_type (cfun, stmt, HIST_TYPE_INDIR_CALL);