re PR middle-end/49495 (-O3 causes error message "edge points to wrong declaration:")
authorMartin Jambor <mjambor@suse.cz>
Thu, 7 Jul 2011 18:08:00 +0000 (20:08 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Thu, 7 Jul 2011 18:08:00 +0000 (20:08 +0200)
2011-07-07  Martin Jambor  <mjambor@suse.cz>

PR middle-end/49495
* cgraphunit.c (verify_edge_corresponds_to_fndecl): New function.
(verify_cgraph_node): Some functinality moved to
verify_edge_corresponds_to_fndecl, call it.

From-SVN: r175998

gcc/ChangeLog
gcc/cgraphunit.c

index d9670d5c0de63999848f1d89826f40e1d576cc8a..dbeb8e68cd6a55a9b409a8afd4f8006623d78e6a 100644 (file)
@@ -1,3 +1,10 @@
+2011-07-07  Martin Jambor  <mjambor@suse.cz>
+
+       PR middle-end/49495
+       * cgraphunit.c (verify_edge_corresponds_to_fndecl): New function.
+       (verify_cgraph_node): Some functinality moved to
+       verify_edge_corresponds_to_fndecl, call it.
+
 2011-07-07  Joseph Myers  <joseph@codesourcery.com>
 
        * config.gcc (*local*): Remove.
index e470d85acc61eec02f3846c4cfbb9f736b4b57df..2414d86695f3a1d7e160d45a243b73ba2384b448 100644 (file)
@@ -450,6 +450,28 @@ cgraph_debug_gimple_stmt (struct function *this_cfun, gimple stmt)
   debug_gimple_stmt (stmt);
 }
 
+/* Verify that call graph edge E corresponds to DECL from the associated
+   statement.  Return true if the verification should fail.  */
+
+static bool
+verify_edge_corresponds_to_fndecl (struct cgraph_edge *e, tree decl)
+{
+  if (!e->callee->global.inlined_to
+      && decl
+      && cgraph_get_node (decl)
+      && (e->callee->former_clone_of
+         != cgraph_function_or_thunk_node (cgraph_get_node (decl), NULL)->decl)
+      /* IPA-CP sometimes redirect edge to clone and then back to the former
+        function.  This ping-pong has to go, eventaully.  */
+      && (cgraph_function_or_thunk_node (cgraph_get_node (decl), NULL)
+         != cgraph_function_or_thunk_node (e->callee, NULL))
+      && !clone_of_p (cgraph_get_node (decl),
+                     e->callee))
+    return true;
+  else
+    return false;
+}
+
 /* Verify cgraph nodes of given cgraph node.  */
 DEBUG_FUNCTION void
 verify_cgraph_node (struct cgraph_node *node)
@@ -702,17 +724,7 @@ verify_cgraph_node (struct cgraph_node *node)
                          }
                        if (!e->indirect_unknown_callee)
                          {
-                           if (!e->callee->global.inlined_to
-                               && decl
-                               && cgraph_get_node (decl)
-                               && (e->callee->former_clone_of
-                                   != cgraph_get_node (decl)->decl)
-                               /* IPA-CP sometimes redirect edge to clone and then back to the former
-                                  function.  This ping-pong has to go, eventaully.  */
-                               && (cgraph_function_or_thunk_node (cgraph_get_node (decl), NULL)
-                                   != cgraph_function_or_thunk_node (e->callee, NULL))
-                               && !clone_of_p (cgraph_get_node (decl),
-                                               e->callee))
+                           if (verify_edge_corresponds_to_fndecl (e, decl))
                              {
                                error ("edge points to wrong declaration:");
                                debug_tree (e->callee->decl);