diff options
author | Richard Guenther <rguenther@suse.de> | 2011-04-18 11:59:34 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-04-18 11:59:34 +0000 |
commit | 3b45a007ef93933c0c70c37cb87bf6097db68a32 (patch) | |
tree | ed06be32d0f633307c932b9633f8c7ecf01cec59 /gcc/gimple.h | |
parent | 870ef0cee00e152bbbf52891fd4e15a949fd474a (diff) | |
download | gcc-3b45a007ef93933c0c70c37cb87bf6097db68a32.zip gcc-3b45a007ef93933c0c70c37cb87bf6097db68a32.tar.gz gcc-3b45a007ef93933c0c70c37cb87bf6097db68a32.tar.bz2 |
gimple.h (gimple_call_addr_fndecl): New function.
2011-04-18 Richard Guenther <rguenther@suse.de>
* gimple.h (gimple_call_addr_fndecl): New function.
(gimple_call_fndecl): Use it.
* gimple-fold.c (gimple_fold_call): Fold away OBJ_TYPE_REFs
for direct calls.
* tree-ssa-ccp.c (ccp_fold_stmt): Remove OBJ_TYPE_REF folding.
* tree-ssa-pre.c (eliminate): Also simplify indirect OBJ_TYPE_REFs.
From-SVN: r172644
Diffstat (limited to 'gcc/gimple.h')
-rw-r--r-- | gcc/gimple.h | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/gcc/gimple.h b/gcc/gimple.h index 788ffe6..3146b70 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -2065,6 +2065,24 @@ gimple_call_set_fndecl (gimple gs, tree decl) gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl)); } +/* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL + associated with the callee if known. Otherwise return NULL_TREE. */ + +static inline tree +gimple_call_addr_fndecl (const_tree fn) +{ + if (TREE_CODE (fn) == ADDR_EXPR) + { + tree fndecl = TREE_OPERAND (fn, 0); + if (TREE_CODE (fndecl) == MEM_REF + && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR + && integer_zerop (TREE_OPERAND (fndecl, 1))) + fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0); + if (TREE_CODE (fndecl) == FUNCTION_DECL) + return fndecl; + } + return NULL_TREE; +} /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it. Otherwise return NULL. This function is analogous to @@ -2073,21 +2091,7 @@ gimple_call_set_fndecl (gimple gs, tree decl) static inline tree gimple_call_fndecl (const_gimple gs) { - tree addr = gimple_call_fn (gs); - if (TREE_CODE (addr) == ADDR_EXPR) - { - tree fndecl = TREE_OPERAND (addr, 0); - if (TREE_CODE (fndecl) == MEM_REF) - { - if (TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR - && integer_zerop (TREE_OPERAND (fndecl, 1))) - return TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0); - else - return NULL_TREE; - } - return TREE_OPERAND (addr, 0); - } - return NULL_TREE; + return gimple_call_addr_fndecl (gimple_call_fn (gs)); } |