]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cgraphunit.c (verify_edge_count_and_frequency): New function.
authorMartin Jambor <mjambor@suse.cz>
Thu, 22 Jul 2010 09:33:11 +0000 (11:33 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Thu, 22 Jul 2010 09:33:11 +0000 (11:33 +0200)
2010-07-22  Martin Jambor  <mjambor@suse.cz>

* cgraphunit.c (verify_edge_count_and_frequency): New function.
(verify_cgraph_node): Verify frequencies of indirect edges.
* tree-inline.c (tree_function_versioning): Update frequencies of
indirect edges.

From-SVN: r162406

gcc/ChangeLog
gcc/cgraphunit.c
gcc/tree-inline.c

index 2cb8a104e94a1c9f8c6e01e189a03d95b894988e..80744a1c8d5c61502fd4fda9b2feb86d4f66bb42 100644 (file)
@@ -1,3 +1,10 @@
+2010-07-22  Martin Jambor  <mjambor@suse.cz>
+
+       * cgraphunit.c (verify_edge_count_and_frequency): New function.
+       (verify_cgraph_node): Verify frequencies of indirect edges.
+       * tree-inline.c (tree_function_versioning): Update frequencies of
+       indirect edges.
+
 2010-07-22  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
 
        PR target/43698
index 7dce8e96799a547947e3330d51bb94fc1896e47f..0f3a6e23d00586e0c36ed76e7147cbacb2621447 100644 (file)
@@ -570,6 +570,42 @@ clone_of_p (struct cgraph_node *node, struct cgraph_node *node2)
 }
 #endif
 
+/* Verify edge E count and frequency.  */
+
+static bool
+verify_edge_count_and_frequency (struct cgraph_edge *e)
+{
+  bool error_found = false;
+  if (e->count < 0)
+    {
+      error ("caller edge count is negative");
+      error_found = true;
+    }
+  if (e->frequency < 0)
+    {
+      error ("caller edge frequency is negative");
+      error_found = true;
+    }
+  if (e->frequency > CGRAPH_FREQ_MAX)
+    {
+      error ("caller edge frequency is too large");
+      error_found = true;
+    }
+  if (gimple_has_body_p (e->caller->decl)
+      && !e->caller->global.inlined_to
+      && (e->frequency
+         != compute_call_stmt_bb_frequency (e->caller->decl,
+                                            gimple_bb (e->call_stmt))))
+    {
+      error ("caller edge frequency %i does not match BB freqency %i",
+            e->frequency,
+            compute_call_stmt_bb_frequency (e->caller->decl,
+                                            gimple_bb (e->call_stmt)));
+      error_found = true;
+    }
+  return error_found;
+}
+
 /* Verify cgraph nodes of given cgraph node.  */
 DEBUG_FUNCTION void
 verify_cgraph_node (struct cgraph_node *node)
@@ -635,33 +671,8 @@ verify_cgraph_node (struct cgraph_node *node)
     }
   for (e = node->callers; e; e = e->next_caller)
     {
-      if (e->count < 0)
-       {
-         error ("caller edge count is negative");
-         error_found = true;
-       }
-      if (e->frequency < 0)
-       {
-         error ("caller edge frequency is negative");
-         error_found = true;
-       }
-      if (e->frequency > CGRAPH_FREQ_MAX)
-       {
-         error ("caller edge frequency is too large");
-         error_found = true;
-       }
-      if (gimple_has_body_p (e->caller->decl)
-          && !e->caller->global.inlined_to
-          && (e->frequency
-             != compute_call_stmt_bb_frequency (e->caller->decl,
-                                                gimple_bb (e->call_stmt))))
-       {
-         error ("caller edge frequency %i does not match BB freqency %i",
-                e->frequency,
-                compute_call_stmt_bb_frequency (e->caller->decl,
-                                                gimple_bb (e->call_stmt)));
-         error_found = true;
-       }
+      if (verify_edge_count_and_frequency (e))
+       error_found = true;
       if (!e->inline_failed)
        {
          if (node->global.inlined_to
@@ -684,6 +695,9 @@ verify_cgraph_node (struct cgraph_node *node)
            error_found = true;
          }
     }
+  for (e = node->indirect_calls; e; e = e->next_callee)
+    if (verify_edge_count_and_frequency (e))
+      error_found = true;
   if (!node->callers && node->global.inlined_to)
     {
       error ("inlined_to pointer is set but no predecessors found");
index 5b429eb5485f85428a7f2b4d8cc56e9834611d33..dc09c29b6ea20000fcfd303eb767542d2b7f0ce4 100644 (file)
@@ -5184,7 +5184,15 @@ tree_function_versioning (tree old_decl, tree new_decl,
       for (e = new_version_node->callees; e; e = e->next_callee)
        {
          basic_block bb = gimple_bb (e->call_stmt);
-         e->frequency = compute_call_stmt_bb_frequency (current_function_decl, bb);
+         e->frequency = compute_call_stmt_bb_frequency (current_function_decl,
+                                                        bb);
+         e->count = bb->count;
+       }
+      for (e = new_version_node->indirect_calls; e; e = e->next_callee)
+       {
+         basic_block bb = gimple_bb (e->call_stmt);
+         e->frequency = compute_call_stmt_bb_frequency (current_function_decl,
+                                                        bb);
          e->count = bb->count;
        }
     }