[Bug ipa/60911] [4.9/4.10 Regression] wrong code with -O2 -flto -fipa-pta

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 23 12:15:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60911

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Ah, and tree-ssa-structalias.c does

  /* Build the constraints.  */
  FOR_EACH_DEFINED_FUNCTION (node)
    {
      varinfo_t vi;
      /* Nodes without a body are not interesting.  Especially do not
         visit clones at this point for now - we get duplicate decls
         there for inline clones at least.  */
      if (!cgraph_function_with_gimple_body_p (node) || node->clone_of)
        continue;
      cgraph_get_body (node);

but doesn't apply IPA transforms.  I think the kludge in the pass manager
should do that instead.  I wonder how the above doesn't trigger the
in_lto_p assert in cgraph_get_body though ... (maybe the odd DECL_RESULT
check makes sure we don't trigger that path).

Ick.  That code path triggers also with

2171          do_per_function (clear_last_verified, NULL);

doing the push/pop_cfun game on each fn just to clear last_verified ...
in WPA stage ... same for

2179      do_per_function (update_properties_after_pass, pass);

and more.  Trying to make

Index: gcc/passes.c
===================================================================
--- gcc/passes.c        (revision 209677)
+++ gcc/passes.c        (working copy)
@@ -1506,9 +1506,11 @@ do_per_function (void (*callback) (void
     {
       struct cgraph_node *node;
       FOR_EACH_DEFINED_FUNCTION (node)
-       if (node->analyzed && gimple_has_body_p (node->decl)
+       if (node->analyzed
+           && cgraph_function_with_gimple_body_p (node)
            && (!node->clone_of || node->decl != node->clone_of->decl))
          {
+           cgraph_get_body (node);
            push_cfun (DECL_STRUCT_FUNCTION (node->decl));
            callback (data);
            if (!flag_wpa)

not ICE ...

Index: gcc/passes.c
===================================================================
--- gcc/passes.c        (revision 209677)
+++ gcc/passes.c        (working copy)
@@ -1506,18 +1506,24 @@ do_per_function (void (*callback) (void
     {
       struct cgraph_node *node;
       FOR_EACH_DEFINED_FUNCTION (node)
-       if (node->analyzed && gimple_has_body_p (node->decl)
+       if (node->analyzed
+           && cgraph_function_with_gimple_body_p (node)
            && (!node->clone_of || node->decl != node->clone_of->decl))
          {
-           push_cfun (DECL_STRUCT_FUNCTION (node->decl));
-           callback (data);
            if (!flag_wpa)
+             cgraph_get_body (node);
+           if (gimple_has_body_p (node->decl))
              {
-               free_dominance_info (CDI_DOMINATORS);
-               free_dominance_info (CDI_POST_DOMINATORS);
+               push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+               callback (data);
+               if (!flag_wpa)
+                 {
+                   free_dominance_info (CDI_DOMINATORS);
+                   free_dominance_info (CDI_POST_DOMINATORS);
+                 }
+               pop_cfun ();
+               ggc_collect ();
              }
-           pop_cfun ();
-           ggc_collect ();
          }
     }
 }

works though.



More information about the Gcc-bugs mailing list