Commit 9bfc434b by Richard Guenther Committed by Richard Biener

gimple.h (gimple_call_fntype): New function.

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.

From-SVN: r172178
parent 7c1f0b40
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> 2011-04-08 Dmitry Melnik <dm@ispras.ru>
PR rtl-optimization/48235 PR rtl-optimization/48235
......
...@@ -8533,8 +8533,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, ...@@ -8533,8 +8533,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
&& (g = SSA_NAME_DEF_STMT (ssa_name)) && (g = SSA_NAME_DEF_STMT (ssa_name))
&& gimple_code (g) == GIMPLE_CALL) && gimple_code (g) == GIMPLE_CALL)
pmode = promote_function_mode (type, mode, &unsignedp, pmode = promote_function_mode (type, mode, &unsignedp,
TREE_TYPE gimple_call_fntype (g),
(TREE_TYPE (gimple_call_fn (g))),
2); 2);
else else
pmode = promote_decl_mode (exp, &unsignedp); pmode = promote_decl_mode (exp, &unsignedp);
......
...@@ -222,11 +222,10 @@ gimple_check_call_args (gimple stmt) ...@@ -222,11 +222,10 @@ gimple_check_call_args (gimple stmt)
/* Get argument types for verification. */ /* Get argument types for verification. */
fndecl = gimple_call_fndecl (stmt); fndecl = gimple_call_fndecl (stmt);
parms = NULL_TREE;
if (fndecl) if (fndecl)
parms = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); parms = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
else if (POINTER_TYPE_P (TREE_TYPE (gimple_call_fn (stmt)))) else
parms = TYPE_ARG_TYPES (TREE_TYPE (TREE_TYPE (gimple_call_fn (stmt)))); parms = TYPE_ARG_TYPES (gimple_call_fntype (stmt));
/* Verify if the type of the argument matches that of the function /* Verify if the type of the argument matches that of the function
declaration. If we cannot verify this or there is a mismatch, declaration. If we cannot verify this or there is a mismatch,
......
...@@ -1780,15 +1780,17 @@ gimple_call_flags (const_gimple stmt) ...@@ -1780,15 +1780,17 @@ gimple_call_flags (const_gimple stmt)
{ {
int flags; int flags;
tree decl = gimple_call_fndecl (stmt); tree decl = gimple_call_fndecl (stmt);
tree t;
if (decl) if (decl)
flags = flags_from_decl_or_type (decl); flags = flags_from_decl_or_type (decl);
else else
{ {
t = TREE_TYPE (gimple_call_fn (stmt)); tree t = TREE_TYPE (gimple_call_fn (stmt));
if (t && TREE_CODE (t) == POINTER_TYPE) /* ??? We can end up being called from gimple_set_modified from
flags = flags_from_decl_or_type (TREE_TYPE (t)); 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 else
flags = 0; flags = 0;
} }
...@@ -1804,7 +1806,7 @@ gimple_call_flags (const_gimple stmt) ...@@ -1804,7 +1806,7 @@ gimple_call_flags (const_gimple stmt)
int int
gimple_call_arg_flags (const_gimple stmt, unsigned arg) 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)); tree attr = lookup_attribute ("fn spec", TYPE_ATTRIBUTES (type));
if (!attr) if (!attr)
return 0; return 0;
...@@ -1848,7 +1850,7 @@ gimple_call_return_flags (const_gimple stmt) ...@@ -1848,7 +1850,7 @@ gimple_call_return_flags (const_gimple stmt)
if (gimple_call_flags (stmt) & ECF_MALLOC) if (gimple_call_flags (stmt) & ECF_MALLOC)
return ERF_NOALIAS; 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)); attr = lookup_attribute ("fn spec", TYPE_ATTRIBUTES (type));
if (!attr) if (!attr)
return 0; return 0;
......
...@@ -2011,6 +2011,13 @@ gimple_call_fn (const_gimple gs) ...@@ -2011,6 +2011,13 @@ gimple_call_fn (const_gimple gs)
return gimple_op (gs, 1); 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 /* Return a pointer to the tree node representing the function called by call
statement GS. */ statement GS. */
...@@ -2073,13 +2080,9 @@ gimple_call_fndecl (const_gimple gs) ...@@ -2073,13 +2080,9 @@ gimple_call_fndecl (const_gimple gs)
static inline tree static inline tree
gimple_call_return_type (const_gimple gs) gimple_call_return_type (const_gimple gs)
{ {
tree fn = gimple_call_fn (gs); tree type = gimple_call_fntype (gs);
tree type = TREE_TYPE (fn);
/* See through the pointer. */
type = TREE_TYPE (type);
/* 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. */ function type. */
return TREE_TYPE (type); return TREE_TYPE (type);
} }
......
...@@ -3086,7 +3086,7 @@ verify_gimple_call (gimple stmt) ...@@ -3086,7 +3086,7 @@ verify_gimple_call (gimple stmt)
return true; return true;
} }
fntype = TREE_TYPE (TREE_TYPE (fn)); fntype = gimple_call_fntype (stmt);
if (gimple_call_lhs (stmt) if (gimple_call_lhs (stmt)
&& !useless_type_conversion_p (TREE_TYPE (gimple_call_lhs (stmt)), && !useless_type_conversion_p (TREE_TYPE (gimple_call_lhs (stmt)),
TREE_TYPE (fntype)) TREE_TYPE (fntype))
...@@ -7441,7 +7441,7 @@ do_warn_unused_result (gimple_seq seq) ...@@ -7441,7 +7441,7 @@ do_warn_unused_result (gimple_seq seq)
LHS. All calls whose value is ignored should be LHS. All calls whose value is ignored should be
represented like this. Look for the attribute. */ represented like this. Look for the attribute. */
fdecl = gimple_call_fndecl (g); 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))) if (lookup_attribute ("warn_unused_result", TYPE_ATTRIBUTES (ftype)))
{ {
......
...@@ -1727,7 +1727,7 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi) ...@@ -1727,7 +1727,7 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi)
this can use the argument slot types for type verification this can use the argument slot types for type verification
instead of the current argument type. We also can safely instead of the current argument type. We also can safely
drop qualifiers here as we are dealing with constants anyway. */ 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; for (i = 0; i < gimple_call_num_args (stmt) && argt;
++i, argt = TREE_CHAIN (argt)) ++i, argt = TREE_CHAIN (argt))
{ {
......
...@@ -1230,16 +1230,13 @@ gimple_ic_transform (gimple stmt) ...@@ -1230,16 +1230,13 @@ gimple_ic_transform (gimple stmt)
histogram_value histogram; histogram_value histogram;
gcov_type val, count, all, bb_all; gcov_type val, count, all, bb_all;
gcov_type prob; gcov_type prob;
tree callee;
gimple modify; gimple modify;
struct cgraph_node *direct_call; struct cgraph_node *direct_call;
if (gimple_code (stmt) != GIMPLE_CALL) if (gimple_code (stmt) != GIMPLE_CALL)
return false; return false;
callee = gimple_call_fn (stmt); if (gimple_call_fndecl (stmt) != NULL_TREE)
if (TREE_CODE (callee) == FUNCTION_DECL)
return false; return false;
histogram = gimple_histogram_value_of_type (cfun, stmt, HIST_TYPE_INDIR_CALL); histogram = gimple_histogram_value_of_type (cfun, stmt, HIST_TYPE_INDIR_CALL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment