aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@gcc.gnu.org>2004-06-22 17:26:04 -0700
committerRichard Henderson <rth@gcc.gnu.org>2004-06-22 17:26:04 -0700
commit0f59171d711aaa9623e2ebc708324299662e55bd (patch)
tree0be6b0f8e11f86590d8a53628df5d2776497a29c /gcc/tree-ssa-ccp.c
parent2f60699380c4bc929efc444b2413d830bad3e9b5 (diff)
downloadgcc-0f59171d711aaa9623e2ebc708324299662e55bd.zip
gcc-0f59171d711aaa9623e2ebc708324299662e55bd.tar.gz
gcc-0f59171d711aaa9623e2ebc708324299662e55bd.tar.bz2
tree.def (VTABLE_REF): Remove.
* tree.def (VTABLE_REF): Remove. (OBJ_TYPE_REF): New. (TRY_CATCH_EXPR, TRY_FINALLY_EXPR): Set type 's'. * expr.c (expand_expr_real_1): Replace VTABLE_REF with OBJ_TYPE_REF. * fold-const.c (non_lvalue): Likewise. * gimplify.c (gimplify_expr): Likewise. (gimplify_call_expr): Use is_gimple_call_addr. * langhooks-def.h (LANG_HOOKS_FOLD_OBJ_TYPE_REF): New. * langhooks.h (fold_obj_type_ref): New. * tree-gimple.c (is_gimple_call_addr): New. * tree-gimple.h (is_gimple_call_addr): Declare. * tree-inline.c (inlinable_function_p): Fix merge error. (estimate_num_insns_1): Replace VTABLE_REF with OBJ_TYPE_REF. * tree-pretty-print.c (dump_generic_node): Likewise. (print_call_name): Handle OBJ_TYPE_REF. * tree-ssa-ccp.c (fold_stmt): Fold OBJ_TYPE_REF. * tree-ssa-operands.c (get_expr_operands): Handle OBJ_TYPE_REF. * tree.h (OBJ_TYPE_REF_EXPR): New. (OBJ_TYPE_REF_OBJECT, OBJ_TYPE_REF_TOKEN): New. * doc/c-tree.texi (VTABLE_REF): Remove. * objc/objc-act.c (build_objc_method_call): Build an OBJ_TYPE_REF. cp/ * class.c (build_vfn_ref): Take a pointer not object. Build an OBJ_TYPE_REF. (cp_fold_obj_type_ref): New. * call.c (build_over_call): Update build_vfn_ref call. * cp-lang.c (LANG_HOOKS_FOLD_OBJ_TYPE_REF): New. * cp-tree.h (cp_fold_obj_type_ref): Declare. testsuite/ * g++.dg/opt/devirt1.C: New. From-SVN: r83531
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 658a2cb..ef0c12b 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2037,13 +2037,41 @@ fold_stmt (tree *stmt_p)
return changed;
result = NULL_TREE;
- /* Check for builtins that CCP can handle using information not
- available in the generic fold routines. */
if (TREE_CODE (rhs) == CALL_EXPR)
{
- tree callee = get_callee_fndecl (rhs);
+ tree callee;
+
+ /* Check for builtins that CCP can handle using information not
+ available in the generic fold routines. */
+ callee = get_callee_fndecl (rhs);
if (callee && DECL_BUILT_IN (callee))
result = ccp_fold_builtin (stmt, rhs);
+ else
+ {
+ /* Check for resolvable OBJ_TYPE_REF. The only sorts we can resolve
+ here are when we've propagated the address of a decl into the
+ object slot. */
+ /* ??? Should perhaps do this in fold proper. However, doing it
+ there requires that we create a new CALL_EXPR, and that requires
+ copying EH region info to the new node. Easier to just do it
+ here where we can just smash the call operand. */
+ callee = TREE_OPERAND (rhs, 0);
+ if (TREE_CODE (callee) == OBJ_TYPE_REF
+ && lang_hooks.fold_obj_type_ref
+ && TREE_CODE (OBJ_TYPE_REF_OBJECT (callee)) == ADDR_EXPR
+ && DECL_P (TREE_OPERAND (OBJ_TYPE_REF_OBJECT (callee), 0)))
+ {
+ tree t;
+
+ t = TREE_TYPE (TREE_OPERAND (OBJ_TYPE_REF_OBJECT (callee), 0));
+ t = lang_hooks.fold_obj_type_ref (callee, t);
+ if (t)
+ {
+ TREE_OPERAND (rhs, 0) = t;
+ changed = true;
+ }
+ }
+ }
}
/* If we couldn't fold the RHS, hand over to the generic fold routines. */