These two patches fix multiple ICE that occurred due to DFE being
recently enabled after AutoFDO LIPO linking.

Passes regression and internal testing. Ok for Google/4_8?

Teresa

2014-06-12  Teresa Johnson  <tejohn...@google.com>
            Dehao Chen  <de...@google.com>

        Google ref b/15521327.

        * cgraphclones.c (cgraph_clone_edge): Use resolved node.
        * l-ipo.c (resolve_cgraph_node): Resolve to non-removable node.

Index: cgraphclones.c
===================================================================
--- cgraphclones.c      (revision 211386)
+++ cgraphclones.c      (working copy)
@@ -94,6 +94,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-utils.h"
 #include "lto-streamer.h"
 #include "except.h"
+#include "l-ipo.h"

 /* Create clone of E in the node N represented by CALL_EXPR the callgraph.  */
 struct cgraph_edge *
@@ -118,7 +119,11 @@ cgraph_clone_edge (struct cgraph_edge *e, struct c

       if (call_stmt && (decl = gimple_call_fndecl (call_stmt)))
        {
-         struct cgraph_node *callee = cgraph_get_node (decl);
+          struct cgraph_node *callee;
+          if (L_IPO_COMP_MODE && cgraph_pre_profiling_inlining_done)
+            callee = cgraph_lipo_get_resolved_node (decl);
+          else
+            callee = cgraph_get_node (decl);
          gcc_checking_assert (callee);
          new_edge = cgraph_create_edge (n, callee, call_stmt, count, freq);
        }
Index: l-ipo.c
===================================================================
--- l-ipo.c     (revision 211386)
+++ l-ipo.c     (working copy)
@@ -1542,6 +1542,18 @@ resolve_cgraph_node (struct cgraph_sym **slot, str
       gcc_assert (decl1_defined);
       add_define_module (*slot, decl2);

+      /* Pick the node that cannot be removed, to avoid a situation
+         where we remove the resolved node and later try to access
+         it for the remaining non-removable copy.  E.g. one may be
+         extern and the other weak, only the extern copy can be removed.  */
+      if (cgraph_can_remove_if_no_direct_calls_and_refs_p ((*slot)->rep_node)
+          && !cgraph_can_remove_if_no_direct_calls_and_refs_p (node))
+        {
+          (*slot)->rep_node = node;
+          (*slot)->rep_decl = decl2;
+          return;
+        }
+
       has_prof1 = has_profile_info (decl1);
       bool is_aux1 = cgraph_is_auxiliary (decl1);
       bool is_aux2 = cgraph_is_auxiliary (decl2);


-- 
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413

Reply via email to