lto-cgraph.c (input_cgraph_1): Don't break existing instrumentation clone references.
authorIlya Enkovich <ilya.enkovich@intel.com>
Tue, 9 Dec 2014 07:56:26 +0000 (07:56 +0000)
committerIlya Enkovich <ienkovich@gcc.gnu.org>
Tue, 9 Dec 2014 07:56:26 +0000 (07:56 +0000)
* lto-cgraph.c (input_cgraph_1): Don't break existing
instrumentation clone references.
* lto/lto-symtab.c (lto_cgraph_replace_node): Redirect
instrumented_version references appropriately.

From-SVN: r218507

gcc/ChangeLog
gcc/lto-cgraph.c
gcc/lto/lto-symtab.c

index dbd6272a0ed1a2466c81af84dbe7b6009378bd60..eba4f993e5f9033294ec2d177a4ba94cd17ff802 100644 (file)
@@ -1,3 +1,10 @@
+2014-12-09  Ilya Enkovich  <ilya.enkovich@intel.com>
+
+       * lto-cgraph.c (input_cgraph_1): Don't break existing
+       instrumentation clone references.
+       * lto/lto-symtab.c (lto_cgraph_replace_node): Redirect
+       instrumented_version references appropriately.
+
 2014-12-09  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        PR bootstrap/63995
index d424e145474f45b084831142768046fd147a70b9..b310b446808a3fc944e0a5eb2f5be5e914172091 100644 (file)
@@ -1562,7 +1562,18 @@ input_cgraph_1 (struct lto_file_decl_data *file_data,
 
              cnode->instrumented_version = cgraph_node::get (cnode->orig_decl);
              if (cnode->instrumented_version)
-               cnode->instrumented_version->instrumented_version = cnode;
+               {
+                 /* We may have multiple nodes for a single function which
+                    will be merged later.  To have a proper merge we need
+                    to keep instrumentation_version reference between nodes
+                    consistent: each instrumented_version reference should
+                    have proper reverse reference.  Thus don't break existing
+                    instrumented_version reference if it already exists.  */
+                 if (cnode->instrumented_version->instrumented_version)
+                   cnode->instrumented_version = NULL;
+                 else
+                   cnode->instrumented_version->instrumented_version = cnode;
+               }
 
              /* Restore decl names reference.  */
              if (IDENTIFIER_TRANSPARENT_ALIAS (DECL_ASSEMBLER_NAME (cnode->decl))
index 4c4e48af3341e711dc8a2a9b6f8701f30722f2a8..f5d82a74b082fdecea3b0b092d8a9733a0917b76 100644 (file)
@@ -99,6 +99,20 @@ lto_cgraph_replace_node (struct cgraph_node *node,
   /* Redirect incomming references.  */
   prevailing_node->clone_referring (node);
 
+  /* Fix instrumentation references.  */
+  if (node->instrumented_version)
+    {
+      gcc_assert (node->instrumentation_clone
+                 == prevailing_node->instrumentation_clone);
+      node->instrumented_version->instrumented_version = prevailing_node;
+      if (!prevailing_node->instrumented_version)
+       prevailing_node->instrumented_version = node->instrumented_version;
+      /* Need to reset node->instrumented_version to NULL,
+        otherwise node removal code would reset
+        node->instrumented_version->instrumented_version.  */
+      node->instrumented_version = NULL;
+    }
+
   ipa_merge_profiles (prevailing_node, node);
   lto_free_function_in_decl_state_for_node (node);