re PR objc/45878 (Can't compile even a trivial ObjC program with -fexceptions -O2)
authorRichard Guenther <rguenther@suse.de>
Wed, 13 Oct 2010 18:25:08 +0000 (18:25 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 13 Oct 2010 18:25:08 +0000 (18:25 +0000)
2010-10-13  Richard Guenther  <rguenther@suse.de>

PR objc/45878
* tree-ssa-ccpc (ccp_fold_stmt): Use gimple_fold_obj_type_ref.

From-SVN: r165430

gcc/ChangeLog
gcc/tree-ssa-ccp.c

index 7a434ace8524cb9ed59f7f7bb0a19cbb5717ce69..531b889ab2ad16a822d85b9e379d9d6d0715e949 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-13  Richard Guenther  <rguenther@suse.de>
+
+       PR objc/45878
+       * tree-ssa-ccpc (ccp_fold_stmt): Use gimple_fold_obj_type_ref.
+
 2010-10-13  Eric Botcazou  <ebotcazou@adacore.com>
 
        * cse.c (cse_insn): Fix thinko in the canonicalization of USE insns.
index 2fa4726e1ea560fc10819a04c3fddd22d56ecd3b..650494144cdac8ea35c5f43caaf12f0f434cd3a7 100644 (file)
@@ -2267,6 +2267,7 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi)
        tree lhs = gimple_call_lhs (stmt);
        tree val;
        tree argt;
+       tree callee;
        bool changed = false;
        unsigned i;
 
@@ -2306,16 +2307,24 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi)
                changed = true;
              }
          }
-       if (TREE_CODE (gimple_call_fn (stmt)) == OBJ_TYPE_REF)
+
+       callee = gimple_call_fn (stmt);
+       if (TREE_CODE (callee) == OBJ_TYPE_REF
+           && TREE_CODE (OBJ_TYPE_REF_EXPR (callee)) == SSA_NAME)
          {
-           tree expr = OBJ_TYPE_REF_EXPR (gimple_call_fn (stmt));
-           expr = valueize_op (expr);
-           if (TREE_CODE (expr) == ADDR_EXPR
-               && TREE_CODE (TREE_OPERAND (expr, 0)) == FUNCTION_DECL)
-            {
-              gimple_call_set_fn (stmt, expr);
-              changed = true;
-            }
+           tree expr = OBJ_TYPE_REF_EXPR (callee);
+           OBJ_TYPE_REF_EXPR (callee) = valueize_op (expr);
+           if (TREE_CODE (OBJ_TYPE_REF_EXPR (callee)) == ADDR_EXPR)
+             {
+               tree t;
+               t = gimple_fold_obj_type_ref (callee, NULL_TREE);
+               if (t)
+                 {
+                   gimple_call_set_fn (stmt, t);
+                   changed = true;
+                 }
+             }
+           OBJ_TYPE_REF_EXPR (callee) = expr;
          }
 
        return changed;