devirt-13.C: Update template.
authorJan Hubicka <hubicka@ucw.cz>
Tue, 17 Dec 2013 10:26:59 +0000 (11:26 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 17 Dec 2013 10:26:59 +0000 (10:26 +0000)
* g++.dg/ipa/devirt-13.C: Update template.
* ipa-utils.h (possible_polymorphic_call_targets): Determine context of
the call.
* gimple-fold.c (gimple_fold_call): Use ipa-devirt to devirtualize.

From-SVN: r206042

gcc/ChangeLog
gcc/gimple-fold.c
gcc/ipa-utils.h
gcc/testsuite/ChangeLog

index 639ec9b..7da6fc4 100644 (file)
@@ -1,3 +1,9 @@
+2013-12-17  Jan Hubicka  <hubicka@ucw.cz>
+
+       * ipa-utils.h (possible_polymorphic_call_targets): Determine context of
+       the call.
+       * gimple-fold.c (gimple_fold_call): Use ipa-devirt to devirtualize.
+
 2013-12-17  Jakub Jelinek  <jakub@redhat.com>
 
        * expr.c (convert_modes): For SUBREG_PROMOTED_VAR_P use SUBREG_REG (x)
index 1705394..767c869 100644 (file)
@@ -1153,26 +1153,20 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
          gimple_call_set_fn (stmt, OBJ_TYPE_REF_EXPR (callee));
          changed = true;
        }
-      else if (virtual_method_call_p (callee))
+      else if (flag_devirtualize && virtual_method_call_p (callee))
        {
-         tree obj = OBJ_TYPE_REF_OBJECT (callee);
-         tree binfo = gimple_extract_devirt_binfo_from_cst
-                (obj, obj_type_ref_class (callee));
-         if (binfo)
+         bool final;
+         vec <cgraph_node *>targets
+           = possible_polymorphic_call_targets (callee, &final);
+         if (final && targets.length () <= 1)
            {
-             HOST_WIDE_INT token
-               = TREE_INT_CST_LOW (OBJ_TYPE_REF_TOKEN (callee));
-             tree fndecl = gimple_get_virt_method_for_binfo (token, binfo);
-             if (fndecl)
-               {
-#ifdef ENABLE_CHECKING
-                 gcc_assert (possible_polymorphic_call_target_p
-                                (callee, cgraph_get_node (fndecl)));
-
-#endif
-                 gimple_call_set_fndecl (stmt, fndecl);
-                 changed = true;
-               }
+             tree fndecl;
+             if (targets.length () == 1)
+               fndecl = targets[0]->decl;
+             else
+               fndecl = builtin_decl_implicit (BUILT_IN_UNREACHABLE);
+             gimple_call_set_fndecl (stmt, fndecl);
+             changed = true;
            }
        }
     }
index b527425..480b752 100644 (file)
@@ -121,10 +121,17 @@ possible_polymorphic_call_targets (tree call,
                                   bool *final = NULL,
                                   void **cache_token = NULL)
 {
+  tree otr_type;
+  HOST_WIDE_INT otr_token;
+  ipa_polymorphic_call_context context;
+
+  get_polymorphic_call_info (current_function_decl,
+                            call,
+                            &otr_type, &otr_token, &context);
   return possible_polymorphic_call_targets (obj_type_ref_class (call),
                                            tree_to_uhwi
                                              (OBJ_TYPE_REF_TOKEN (call)),
-                                           ipa_dummy_polymorphic_call_context,
+                                           context,
                                            final, cache_token);
 }
 
index 671a8b5..ec35aea 100644 (file)
@@ -1,3 +1,7 @@
+2013-12-17  Jan Hubicka  <hubicka@ucw.cz>
+
+       * g++.dg/ipa/devirt-13.C: Update template.
+
 2013-12-16  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/54949