Patchwork : Fix IPA with profiling

login
register
mail settings
Submitter Uros Bizjak
Date July 4, 2012, 1:22 p.m.
Message ID <CAFULd4ZbnqQ8woORekatH7qobg15SxcC2GLDVPX6=UqxE9jsYQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/168982/
State New
Headers show

Comments

Uros Bizjak - July 4, 2012, 1:22 p.m.
Hello!

Attached patch partially reverts r187375 [1]. Apparently, the patch
added some new functionality to symtab_remove_unreachable_nodes,
although the ChangeLog said:

Log:
	...
	(symtab_remove_unreachable_nodes): Cleanup.

It looks to me that since we changed something, we also have to update
something, at least when profiling, before calling
cgraph_propagate_frequency.

2012-07-04  Uros Bizjak  <ubizjak@gmail.com>

	* ipa.c (symtab_remove_unreachable_nodes): Partially revert r187375
	to not call cgraph_propagate_frequency if something was changed.

testsuite/ChangLog:

2012-07-04  Uros Bizjak  <ubizjak@gmail.com>

	* g++.dg/torture/pr53321.C: New test.

Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
also with profiled LTO bootstrap.

OK for mainline?

[1] http://gcc.gnu.org/ml/gcc-cvs/2012-05/msg00371.html

Uros.
Richard Guenther - July 4, 2012, 1:36 p.m.
On Wed, 4 Jul 2012, Uros Bizjak wrote:

> Hello!
> 
> Attached patch partially reverts r187375 [1]. Apparently, the patch
> added some new functionality to symtab_remove_unreachable_nodes,
> although the ChangeLog said:
> 
> Log:
> 	...
> 	(symtab_remove_unreachable_nodes): Cleanup.
> 
> It looks to me that since we changed something, we also have to update
> something, at least when profiling, before calling
> cgraph_propagate_frequency.
> 
> 2012-07-04  Uros Bizjak  <ubizjak@gmail.com>
> 
> 	* ipa.c (symtab_remove_unreachable_nodes): Partially revert r187375
> 	to not call cgraph_propagate_frequency if something was changed.
> 
> testsuite/ChangLog:
> 
> 2012-07-04  Uros Bizjak  <ubizjak@gmail.com>
> 
> 	* g++.dg/torture/pr53321.C: New test.
> 
> Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
> also with profiled LTO bootstrap.
> 
> OK for mainline?

Ok.

Thanks,
Richard.

> [1] http://gcc.gnu.org/ml/gcc-cvs/2012-05/msg00371.html
> 
> Uros.
H.J. Lu - July 6, 2012, 2:15 p.m.
On Wed, Jul 4, 2012 at 6:22 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
> Attached patch partially reverts r187375 [1]. Apparently, the patch
> added some new functionality to symtab_remove_unreachable_nodes,
> although the ChangeLog said:
>
> Log:
>         ...
>         (symtab_remove_unreachable_nodes): Cleanup.
>
> It looks to me that since we changed something, we also have to update
> something, at least when profiling, before calling
> cgraph_propagate_frequency.
>
> 2012-07-04  Uros Bizjak  <ubizjak@gmail.com>
>
>         * ipa.c (symtab_remove_unreachable_nodes): Partially revert r187375
>         to not call cgraph_propagate_frequency if something was changed.
>

This caused:

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

Patch

Index: ipa.c
===================================================================
--- ipa.c	(revision 189217)
+++ ipa.c	(working copy)
@@ -449,11 +449,6 @@  symtab_remove_unreachable_nodes (bool before_inlin
   verify_symtab ();
 #endif
 
-  /* If we removed something, perhaps profile could be improved.  */
-  if (changed && optimize && inline_edge_summary_vec)
-    FOR_EACH_DEFINED_FUNCTION (node)
-      cgraph_propagate_frequency (node);
-
   return changed;
 }
 
Index: testsuite/g++.dg/torture/pr53321.C
===================================================================
--- testsuite/g++.dg/torture/pr53321.C	(revision 0)
+++ testsuite/g++.dg/torture/pr53321.C	(working copy)
@@ -0,0 +1,36 @@ 
+// { dg-do compile }
+// { dg-require-profiling "-fprofile-generate" }
+// { dg-options "-fprofile-generate" }
+
+typedef long unsigned int size_t;
+
+extern "C"
+{
+  extern void *memcpy (void *__dest, __const void *__src, size_t __n);
+}
+
+extern char *src, *sources;
+extern int n_sources;
+
+static void
+find_source (const char *file_name)
+{
+  memcpy (src, sources, n_sources * sizeof (*sources));
+}
+
+extern const char *gcov_read_string (void);
+
+static void read_graph_file (void)
+{
+  find_source (gcov_read_string ());
+}
+
+static void process_file (void)
+{
+  read_graph_file ();
+}
+
+int main ()
+{
+  process_file ();
+}