* ipa-inline.c (can_inline_edge_p) Use merged_comdat.
authorJan Hubicka <hubicka@ucw.cz>
Fri, 4 Dec 2015 18:02:26 +0000 (19:02 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 4 Dec 2015 18:02:26 +0000 (18:02 +0000)
* cgraphclones.c (cgraph_node::create_clone): Use merged_comdat.
* cgraph.c (cgraph_node::dump): Dump merged_comdat.
* ipa-icf.c (sem_function::merge): Drop merged_comdat when merging
comdat and non-comdat.
* cgraph.h (cgraph_node): Rename merged to merged_comdat.
* ipa-inline-analysis.c (simple_edge_hints): Check both merged_comdat
and icf_merged.

* lto-symtab.c (lto_cgraph_replace_node): Update code computing
merged_comdat.

From-SVN: r231291

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h
gcc/cgraphclones.c
gcc/ipa-icf.c
gcc/ipa-inline-analysis.c
gcc/ipa-inline.c
gcc/lto/ChangeLog
gcc/lto/lto-symtab.c

index b25e6430f9bd94bec8848bee7f219ad58691c10c..8b90447f1059a2c735351e47321f14505aa010f6 100644 (file)
@@ -1,3 +1,14 @@
+2015-12-04  Jan Hubicka  <hubicka@ucw.cz>
+
+       * ipa-inline.c (can_inline_edge_p) Use merged_comdat.
+       * cgraphclones.c (cgraph_node::create_clone): Use merged_comdat.
+       * cgraph.c (cgraph_node::dump): Dump merged_comdat.
+       * ipa-icf.c (sem_function::merge): Drop merged_comdat when merging
+       comdat and non-comdat.
+       * cgraph.h (cgraph_node): Rename merged to merged_comdat.
+       * ipa-inline-analysis.c (simple_edge_hints): Check both merged_comdat
+       and icf_merged.
+
 2015-12-04  Paolo Bonzini  <bonzini@gnu.org>
 
        * c-family/c-common.c (maybe_warn_shift_overflow): Warn on all
index 3ee1907c33569a89f606b8a29e99e7b3f9ed9afa..2a559785bf8355eb24fdda608fd7a4a8da088b71 100644 (file)
@@ -1994,6 +1994,8 @@ cgraph_node::dump (FILE *f)
     fprintf (f, " tm_clone");
   if (icf_merged)
     fprintf (f, " icf_merged");
+  if (merged_comdat)
+    fprintf (f, " merged_comdat");
   if (nonfreeing_fn)
     fprintf (f, " nonfreeing_fn");
   if (DECL_STATIC_CONSTRUCTOR (decl))
index 6cff4468cc0b09c71f79b8c862f9d218f06c9046..e689fcd09d1a41bf8d44c035f69f0873bb208905 100644 (file)
@@ -1333,7 +1333,7 @@ public:
      accesses trapping.  */
   unsigned nonfreeing_fn : 1;
   /* True if there was multiple COMDAT bodies merged by lto-symtab.  */
-  unsigned merged : 1;
+  unsigned merged_comdat : 1;
   /* True if function was created to be executed in parallel.  */
   unsigned parallelized_function : 1;
   /* True if function is part split out by ipa-split.  */
index 143ca33d93a10960e22b6fa90a852af8ca0619d0..f8a7d3763f8dc1cb3f6582246e7ad2ffcb203ab7 100644 (file)
@@ -433,7 +433,7 @@ cgraph_node::create_clone (tree new_decl, gcov_type gcov_count, int freq,
   new_node->tp_first_run = tp_first_run;
   new_node->tm_clone = tm_clone;
   new_node->icf_merged = icf_merged;
-  new_node->merged = merged;
+  new_node->merged_comdat = merged_comdat;
 
   new_node->clone.tree_map = NULL;
   new_node->clone.args_to_skip = args_to_skip;
index 0c76672a2c631fdd852e4b50215edc63bf2ddd6c..18039ef7afd9062972f73302e2ef5e18cd6cb228 100644 (file)
@@ -1352,10 +1352,15 @@ sem_function::merge (sem_item *alias_item)
   gcc_assert (alias->icf_merged || remove || redirect_callers);
   original->icf_merged = true;
 
-  /* Inform the inliner about cross-module merging.  */
-  if ((original->lto_file_data || alias->lto_file_data)
-      && original->lto_file_data != alias->lto_file_data)
-    local_original->merged = original->merged = true;
+  /* We use merged flag to track cases where COMDAT function is known to be
+     compatible its callers.  If we merged in non-COMDAT, we need to give up
+     on this optimization.  */
+  if (original->merged_comdat && !alias->merged_comdat)
+    {
+      if (dump_file)
+       fprintf (dump_file, "Dropping merged_comdat flag.\n\n");
+      local_original->merged_comdat = original->merged_comdat = false;
+    }
 
   if (remove)
     {
index cf7766b7d1424d73682348d6716789857cea65ba..6392083d6befc68edebd7f3a79bdb16a13b338da 100644 (file)
@@ -3708,7 +3708,7 @@ simple_edge_hints (struct cgraph_edge *edge)
 
   if (callee->lto_file_data && edge->caller->lto_file_data
       && edge->caller->lto_file_data != callee->lto_file_data
-      && !callee->merged)
+      && !callee->merged_comdat && !callee->icf_merged)
     hints |= INLINE_HINT_cross_module;
 
   return hints;
index 01bfe0effda6eb6f3e36e8253378bf4f025a7fa2..f2fd84ba66b296b8b4102537db71a45ea95f77f9 100644 (file)
@@ -466,7 +466,7 @@ can_inline_edge_p (struct cgraph_edge *e, bool report,
          optimized with the optimization flags of module they are used in.
         Also do not care about mixing up size/speed optimization when
         DECL_DISREGARD_INLINE_LIMITS is set.  */
-      else if ((callee->merged
+      else if ((callee->merged_comdat
                && !lookup_attribute ("optimize",
                                      DECL_ATTRIBUTES (caller->decl)))
               || DECL_DISREGARD_INLINE_LIMITS (callee->decl))
index a508999e0f6558f3e374f0c9bf17852d2f2b5244..df2eaa9483e0617891347f4e3ca08efcf68bb94d 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-04  Jan Hubicka  <hubicka@ucw.cz>
+
+       * lto-symtab.c (lto_cgraph_replace_node): Update code computing
+       merged_comdat.
+
 2015-12-01  Jan Hubicka  <hubicka@ucw.cz>
 
        * lto.c (compare_tree_sccs_1): Do not compare TYPE_ALIAS_SET.
index 235df67e2ce34f5069f1c86fb3a7c7816d1aeaff..e5055b593a8403ff068404446a2a2e1782512e84 100644 (file)
@@ -63,8 +63,9 @@ lto_cgraph_replace_node (struct cgraph_node *node,
       gcc_assert (!prevailing_node->global.inlined_to);
       prevailing_node->mark_address_taken ();
     }
-  if (node->definition && prevailing_node->definition)
-    prevailing_node->merged = true;
+  if (node->definition && prevailing_node->definition
+      && DECL_COMDAT (node->decl) && DECL_COMDAT (prevailing_node->decl))
+    prevailing_node->merged_comdat = true;
 
   /* Redirect all incoming edges.  */
   compatible_p