ipa-cp: Avoid ICEs when looking at expanded thunks and unoptimized functions
authorMartin Jambor <mjambor@suse.cz>
Fri, 29 Nov 2019 13:29:35 +0000 (14:29 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Fri, 29 Nov 2019 13:29:35 +0000 (14:29 +0100)
2019-11-29  Martin Jambor  <mjambor@suse.cz>

PR ipa/92476
* ipa-cp.c (set_single_call_flag): Set node_calling_single_call in
the summary only if the summary exists.
(find_more_scalar_values_for_callers_subset): Check node_dead in
the summary only if the summary exists.
(ipcp_store_bits_results): Ignore nodes without lattices.
(ipcp_store_vr_results): Likewise.
* cgraphclones.c: Include ipa-fnsummary.h and ipa-prop.h and the
header files required by them.
(cgraph_node::expand_all_artificial_thunks): Analyze expanded thunks.

From-SVN: r278841

gcc/ChangeLog
gcc/cgraphclones.c
gcc/ipa-cp.c

index c2d27921ca834be65caa328a35e445610f51fa1c..c06d450c0743e1e70570a7e8c7e3eab5228c8c13 100644 (file)
@@ -1,3 +1,16 @@
+2019-11-29  Martin Jambor  <mjambor@suse.cz>
+
+       PR ipa/92476
+       * ipa-cp.c (set_single_call_flag): Set node_calling_single_call in
+       the summary only if the summary exists.
+       (find_more_scalar_values_for_callers_subset): Check node_dead in
+       the summary only if the summary exists.
+       (ipcp_store_bits_results): Ignore nodes without lattices.
+       (ipcp_store_vr_results): Likewise.
+       * cgraphclones.c: Include ipa-fnsummary.h and ipa-prop.h and the
+       header files required by them.
+       (cgraph_node::expand_all_artificial_thunks): Analyze expanded thunks.
+
 2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR tree-optimization/92710
index a79491e0b88b96f75d2167997ef6230fb3195d5c..9aacb0b196cc03473b4ef3d0915b55620426cc19 100644 (file)
@@ -80,6 +80,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-inline.h"
 #include "dumpfile.h"
 #include "gimple-pretty-print.h"
+#include "alloc-pool.h"
+#include "symbol-summary.h"
+#include "tree-vrp.h"
+#include "ipa-prop.h"
+#include "ipa-fnsummary.h"
 
 /* Create clone of edge in the node N represented by CALL_EXPR
    the callgraph.  */
@@ -268,6 +273,8 @@ cgraph_node::expand_all_artificial_thunks ()
          {
            thunk->thunk.thunk_p = false;
            thunk->analyze ();
+           ipa_analyze_node (thunk);
+           inline_analyze_function (thunk);
          }
        thunk->expand_all_artificial_thunks ();
       }
index b13322827b685dc41b64ce58b8349d22f0ea7481..d0c6e91edd4c177b2455edd6d2945ef5569e3c8b 100644 (file)
@@ -1165,7 +1165,7 @@ set_single_call_flag (cgraph_node *node, void *)
   /* Local thunks can be handled transparently, skip them.  */
   while (cs && cs->caller->thunk.thunk_p && cs->caller->local)
     cs = cs->next_caller;
-  if (cs)
+  if (cs && IPA_NODE_REF (cs->caller))
     {
       IPA_NODE_REF (cs->caller)->node_calling_single_call = true;
       return true;
@@ -4417,7 +4417,7 @@ find_more_scalar_values_for_callers_subset (struct cgraph_node *node,
          struct ipa_jump_func *jump_func;
          tree t;
 
-         if (IPA_NODE_REF (cs->caller)->node_dead)
+         if (IPA_NODE_REF (cs->caller) && IPA_NODE_REF (cs->caller)->node_dead)
            continue;
 
          if (!IPA_EDGE_REF (cs)
@@ -5422,6 +5422,9 @@ ipcp_store_bits_results (void)
 
       if (info->ipcp_orig_node)
        info = IPA_NODE_REF (info->ipcp_orig_node);
+      if (!info->lattices)
+       /* Newly expanded artificial thunks do not have lattices.  */
+       continue;
 
       unsigned count = ipa_get_param_count (info);
       for (unsigned i = 0; i < count; i++)
@@ -5495,6 +5498,9 @@ ipcp_store_vr_results (void)
 
       if (info->ipcp_orig_node)
        info = IPA_NODE_REF (info->ipcp_orig_node);
+      if (!info->lattices)
+       /* Newly expanded artificial thunks do not have lattices.  */
+       continue;
 
       unsigned count = ipa_get_param_count (info);
       for (unsigned i = 0; i < count; i++)