OSDN Git Service

* cgraph.c (cgraph_mark_address_taken_node): No longer imply needed flag.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 13 May 2010 06:13:46 +0000 (06:13 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 05:07:24 +0000 (14:07 +0900)
* cgraph.h (cgraph_only_called_directly_p,
cgraph_can_remove_if_no_direct_calls_p): test address_taken flag.
(cgraph_can_remove_if_no_direct_calls_and_refs_p): New function.
* cgraphunit.c (cgraph_mark_functions_to_output): Test address_taken.
(assemble
* ipa.c (cgraph_remove_unreachable_nodes): Use
cgraph_can_remove_if_no_direct_calls_and_refs_p; clear address_taken flags.
* tree-inline.c (copy_bb): Check address_taken flag.
* tree-profile.c (tree_gen_ic_func_profiler): Check address_taken and
externally_visible flag.

* tree-ssa/unreachable.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159354 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h
gcc/cgraphunit.c
gcc/ipa.c
gcc/testsuite/ChangeLog
gcc/tree-inline.c

index 0decfd8..f6b1554 100644 (file)
@@ -1,3 +1,17 @@
+2010-05-12  Jan Hubicka  <jh@suse.cz>
+
+       * cgraph.c (cgraph_mark_address_taken_node): No longer imply needed flag.
+       * cgraph.h (cgraph_only_called_directly_p,
+       cgraph_can_remove_if_no_direct_calls_p): test address_taken flag.
+       (cgraph_can_remove_if_no_direct_calls_and_refs_p): New function.
+       * cgraphunit.c (cgraph_mark_functions_to_output): Test address_taken.
+       (assemble
+       * ipa.c (cgraph_remove_unreachable_nodes): Use
+       cgraph_can_remove_if_no_direct_calls_and_refs_p; clear address_taken flags.
+       * tree-inline.c (copy_bb): Check address_taken flag.
+       * tree-profile.c (tree_gen_ic_func_profiler): Check address_taken and
+       externally_visible flag.
+
 2010-05-12  Jason Merrill  <jason@redhat.com>
 
        PR bootstrap/44048
 2010-05-12  Jason Merrill  <jason@redhat.com>
 
        PR bootstrap/44048
index b16a10d..82ce0e8 100644 (file)
@@ -1686,8 +1686,8 @@ cgraph_mark_needed_node (struct cgraph_node *node)
 void
 cgraph_mark_address_taken_node (struct cgraph_node *node)
 {
 void
 cgraph_mark_address_taken_node (struct cgraph_node *node)
 {
+  cgraph_mark_reachable_node (node);
   node->address_taken = 1;
   node->address_taken = 1;
-  cgraph_mark_needed_node (node);
 }
 
 /* Return local info for the compiled function.  */
 }
 
 /* Return local info for the compiled function.  */
index dbfc89f..1ccae09 100644 (file)
@@ -856,19 +856,28 @@ varpool_node_set_nonempty_p (varpool_node_set set)
 static inline bool
 cgraph_only_called_directly_p (struct cgraph_node *node)
 {
 static inline bool
 cgraph_only_called_directly_p (struct cgraph_node *node)
 {
-  return !node->needed && !node->local.externally_visible;
+  return !node->needed && !node->address_taken && !node->local.externally_visible;
 }
 
 /* Return true when function NODE can be removed from callgraph
    if all direct calls are eliminated.  */
 
 static inline bool
 }
 
 /* Return true when function NODE can be removed from callgraph
    if all direct calls are eliminated.  */
 
 static inline bool
-cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
+cgraph_can_remove_if_no_direct_calls_and_refs_p (struct cgraph_node *node)
 {
   return (!node->needed && !node->reachable_from_other_partition
          && (DECL_COMDAT (node->decl) || !node->local.externally_visible));
 }
 
 {
   return (!node->needed && !node->reachable_from_other_partition
          && (DECL_COMDAT (node->decl) || !node->local.externally_visible));
 }
 
+/* Return true when function NODE can be removed from callgraph
+   if all direct calls are eliminated.  */
+
+static inline bool
+cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
+{
+  return !node->address_taken && cgraph_can_remove_if_no_direct_calls_and_refs_p (node);
+}
+
 /* Constant pool accessor function.  */
 htab_t constant_pool_htab (void);
 
 /* Constant pool accessor function.  */
 htab_t constant_pool_htab (void);
 
index cacb90c..b97a33e 100644 (file)
@@ -1201,6 +1201,7 @@ cgraph_mark_functions_to_output (void)
       if (node->analyzed
          && !node->global.inlined_to
          && (node->needed || node->reachable_from_other_partition
       if (node->analyzed
          && !node->global.inlined_to
          && (node->needed || node->reachable_from_other_partition
+             || node->address_taken
              || (e && node->reachable))
          && !TREE_ASM_WRITTEN (decl)
          && !DECL_EXTERNAL (decl))
              || (e && node->reachable))
          && !TREE_ASM_WRITTEN (decl)
          && !DECL_EXTERNAL (decl))
index 1fc3fdd..2512177 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -207,7 +207,7 @@ cgraph_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
 #endif
   varpool_reset_queue ();
   for (node = cgraph_nodes; node; node = node->next)
 #endif
   varpool_reset_queue ();
   for (node = cgraph_nodes; node; node = node->next)
-    if (!cgraph_can_remove_if_no_direct_calls_p (node)
+    if (!cgraph_can_remove_if_no_direct_calls_and_refs_p (node)
        && ((!DECL_EXTERNAL (node->decl))
             || before_inlining_p))
       {
        && ((!DECL_EXTERNAL (node->decl))
             || before_inlining_p))
       {
@@ -405,6 +405,25 @@ cgraph_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
           varpool_remove_node (vnode);
        }
     }
           varpool_remove_node (vnode);
        }
     }
+  if (file)
+    fprintf (file, "\nClearing address taken flags:");
+  for (node = cgraph_nodes; node; node = node->next)
+    if (node->address_taken
+       && !node->reachable_from_other_partition)
+      {
+       int i;
+        struct ipa_ref *ref;
+       bool found = false;
+        for (i = 0; ipa_ref_list_refering_iterate (&node->ref_list, i, ref)
+                   && !found; i++)
+         found = true;
+       if (!found)
+         {
+           if (file)
+             fprintf (file, " %s", cgraph_node_name (node));
+           node->address_taken = false;
+         }
+      }
 
 #ifdef ENABLE_CHECKING
   verify_cgraph ();
 
 #ifdef ENABLE_CHECKING
   verify_cgraph ();
index e62336b..8f18143 100644 (file)
@@ -1,3 +1,7 @@
+2010-05-12  Jan Hubicka  <jh@suse.cz>
+
+       * tree-ssa/unreachable.c: New test.
+
 2010-05-12  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/sfinae1.C: New.
 2010-05-12  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/sfinae1.C: New.
index 302d36b..03b013c 100644 (file)
@@ -1711,6 +1711,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
                     other cases we hit a bug (incorrect node sharing is the
                     most common reason for missing edges).  */
                  gcc_assert (dest->needed || !dest->analyzed
                     other cases we hit a bug (incorrect node sharing is the
                     most common reason for missing edges).  */
                  gcc_assert (dest->needed || !dest->analyzed
+                             || dest->address_taken
                              || !id->src_node->analyzed);
                  if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES)
                    cgraph_create_edge_including_clones
                              || !id->src_node->analyzed);
                  if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES)
                    cgraph_create_edge_including_clones