summaryrefslogtreecommitdiff
path: root/gcc/gimple.h
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-08-09 17:28:39 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-08-09 17:28:39 +0000
commit7c9577becf922e261c901a1108ee0cb58aa73d58 (patch)
treee96c21c1520a969a3ed3dd84fdd1dadfb5821f86 /gcc/gimple.h
parent6cccc200142d9a9d1dbafa0d0a1d8ec2cb0b2c14 (diff)
downloadgcc-7c9577becf922e261c901a1108ee0cb58aa73d58.tar.gz
gimple.c (gimple_build_call_1): Deal with FUNCTION_DECL fn.
2008-08-09 Richard Guenther <rguenther@suse.de> * gimple.c (gimple_build_call_1): Deal with FUNCTION_DECL fn. * gimple.h (gimple_call_fn): Adjust comment. (gimple_call_set_fndecl): New function. (gimple_call_fndecl): Adjust for GIMPLE_CALL no longer having bare FUNCTION_DECL operand. (gimple_call_return_type): Likewise. * tree-cfg.c (verify_stmt): Verify function operand of a GIMPLE_CALL. * value-prof.c (gimple_divmod_fixed_value): Do not emit labels. (gimple_mod_pow2): Likewise. (gimple_mod_subtract): Likewise. (gimple_ic): Likewise. (gimple_stringop_fixed_value): Likewise. (gimple_indirect_call_to_profile): Fix for GIMPLE_CALL no longer having bare FUNCTION_DECL operand. * ipa-cp.c (ipcp_update_callgraph): Use gimple_call_set_fndecl. * omp-low.c (optimize_omp_library_calls): Likewise. * cgraphunit.c (update_call_expr): Likewise. * tree-ssa-math-opts.c (execute_cse_reciprocals): Likewise. (execute_convert_to_rsqrt): Likewise. * cfgexpand.c (gimple_to_tree): Simplify. (release_stmt_tree): Fix for GIMPLE_CALL no longer having bare FUNCTION_DECL operand. * tree-nested.c (init_tmp_var_with_call): Use gimple_call_return_type. (convert_gimple_call): Use gimple_call_fndecl. * c-common.c (c_warn_unused_result): Likewise. * gcc.dg/tree-ssa/inline-2.c: New testcase. From-SVN: r138907
Diffstat (limited to 'gcc/gimple.h')
-rw-r--r--gcc/gimple.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/gcc/gimple.h b/gcc/gimple.h
index f32600daf91..3799e062b37 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1905,7 +1905,7 @@ gimple_call_set_lhs (gimple gs, tree lhs)
/* Return the tree node representing the function called by call
- statement GS. This may or may not be a FUNCTION_DECL node. */
+ statement GS. */
static inline tree
gimple_call_fn (const_gimple gs)
@@ -1937,6 +1937,17 @@ gimple_call_set_fn (gimple gs, tree fn)
}
+/* Set FNDECL to be the function called by call statement GS. */
+
+static inline void
+gimple_call_set_fndecl (gimple gs, tree decl)
+{
+ GIMPLE_CHECK (gs, GIMPLE_CALL);
+ gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
+ gimple_set_op (gs, 1, build_fold_addr_expr (decl));
+}
+
+
/* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it.
Otherwise return NULL. This function is analogous to
get_callee_fndecl in tree land. */
@@ -1944,8 +1955,13 @@ gimple_call_set_fn (gimple gs, tree fn)
static inline tree
gimple_call_fndecl (const_gimple gs)
{
- tree decl = gimple_call_fn (gs);
- return (TREE_CODE (decl) == FUNCTION_DECL) ? decl : NULL_TREE;
+ tree addr = gimple_call_fn (gs);
+ if (TREE_CODE (addr) == ADDR_EXPR)
+ {
+ gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL);
+ return TREE_OPERAND (addr, 0);
+ }
+ return NULL_TREE;
}
@@ -1957,9 +1973,9 @@ gimple_call_return_type (const_gimple gs)
tree fn = gimple_call_fn (gs);
tree type = TREE_TYPE (fn);
- /* See through pointers. */
- if (POINTER_TYPE_P (type))
- type = TREE_TYPE (type);
+ /* See through the pointer. */
+ gcc_assert (POINTER_TYPE_P (type));
+ type = TREE_TYPE (type);
gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE);