Patchwork Add -fmem-report-wpa

login
register
mail settings
Submitter Andi Kleen
Date Sept. 7, 2012, 5:01 a.m.
Message ID <1346994060-30211-1-git-send-email-andi@firstfloor.org>
Download mbox | patch
Permalink /patch/182315/
State New
Headers show

Comments

Andi Kleen - Sept. 7, 2012, 5:01 a.m.
From: Andi Kleen <ak@linux.intel.com>

For parallel LTO builds setting -fmem-report does not work very well
because all the LTRANS phases dump it in parallel and typically interleave
it to unreadability.

Since usually the memory bottleneck is WPA add a flag to only dump
the memory report for that.

Passed bootstrap and testsuite on x86_64.

2012-09-06  Andi Kleen  <ak@my.domain.org>

	* gcc/common.opt (-fmem-report-wpa): Add
	* gcc/doc/invoke.texi (-fmem-report-wpa): Document.
	* gcc/lto/lto.c (do_whole_program_analysis): Run mem_report
	when mem_report_wpa is set.
---
 gcc/common.opt      |    4 ++++
 gcc/doc/invoke.texi |    7 ++++++-
 gcc/lto/lto.c       |    2 ++
 3 files changed, 12 insertions(+), 1 deletions(-)
Richard Guenther - Sept. 7, 2012, 9:18 a.m.
On Fri, Sep 7, 2012 at 7:01 AM, Andi Kleen <andi@firstfloor.org> wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> For parallel LTO builds setting -fmem-report does not work very well
> because all the LTRANS phases dump it in parallel and typically interleave
> it to unreadability.
>
> Since usually the memory bottleneck is WPA add a flag to only dump
> the memory report for that.
>
> Passed bootstrap and testsuite on x86_64.

Ok.

Thanks,
Richard.

> 2012-09-06  Andi Kleen  <ak@my.domain.org>
>
>         * gcc/common.opt (-fmem-report-wpa): Add
>         * gcc/doc/invoke.texi (-fmem-report-wpa): Document.
>         * gcc/lto/lto.c (do_whole_program_analysis): Run mem_report
>         when mem_report_wpa is set.
> ---
>  gcc/common.opt      |    4 ++++
>  gcc/doc/invoke.texi |    7 ++++++-
>  gcc/lto/lto.c       |    2 ++
>  3 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 87e28b5..73eebf4 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -1470,6 +1470,10 @@ fmem-report
>  Common Report Var(mem_report)
>  Report on permanent memory allocation
>
> +fmem-report-wpa
> +Common Report Var(mem_report_wpa)
> +Report on permanent memory allocation in WPA only
> +
>  ; This will attempt to merge constant section constants, if 1 only
>  ; string constants and constants from constant pool, if 2 also constant
>  ; variables.
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 6cf7cec..5a5f9d2 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -328,7 +328,7 @@ Objective-C and Objective-C++ Dialects}.
>  -feliminate-unused-debug-symbols -femit-class-debug-always @gol
>  -fenable-@var{kind}-@var{pass} @gol
>  -fenable-@var{kind}-@var{pass}=@var{range-list} @gol
> --fdebug-types-section @gol
> +-fdebug-types-section -fmem-report-wpa @gol
>  -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report -fprofile-arcs @gol
>  -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
>  -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
> @@ -5132,6 +5132,11 @@ pass when it finishes.
>  Makes the compiler print some statistics about permanent memory
>  allocation when it finishes.
>
> +@item -fmem-report-wpa
> +@opindex fmem-report-wpa
> +Makes the compiler print some statistics about permanent memory
> +allocation for the WPA phase only.
> +
>  @item -fpre-ipa-mem-report
>  @opindex fpre-ipa-mem-report
>  @item -fpost-ipa-mem-report
> diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
> index 5da5412..3c59299 100644
> --- a/gcc/lto/lto.c
> +++ b/gcc/lto/lto.c
> @@ -2016,6 +2016,8 @@ do_whole_program_analysis (void)
>    /* Show the LTO report before launching LTRANS.  */
>    if (flag_lto_report)
>      print_lto_report ();
> +  if (mem_report_wpa)
> +    dump_mem_report ();
>  }
>
>
> --
> 1.7.7
>
Hans-Peter Nilsson - Sept. 8, 2012, 6:37 p.m.
On Thu, 6 Sep 2012, Andi Kleen wrote:

> From: Andi Kleen <ak@linux.intel.com>

> Passed bootstrap and testsuite on x86_64.

> +++ b/gcc/lto/lto.c
> @@ -2016,6 +2016,8 @@ do_whole_program_analysis (void)
>    /* Show the LTO report before launching LTRANS.  */
>    if (flag_lto_report)
>      print_lto_report ();
> +  if (mem_report_wpa)
> +    dump_mem_report ();
>  }

Broke build for cris-elf:
g++ -c   -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE
-fno-exceptions -fno-rtti -W -Wall -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long
-Wno-variadic-macros -Wno-overlength-strings -fno-common
-DHAVE_CONFIG_H -I. -Ilto -I/tmp/hpautotest-gcc0/gcc/gcc
-I/tmp/hpautotest-gcc0/gcc/gcc/lto
-I/tmp/hpautotest-gcc0/gcc/gcc/../include -I/tmp/hpautotest-gcc0/gcc/gcc/../libcpp/include
-I/tmp/hpautotest-gcc0/cris-elf/gccobj/./gmp
-I/tmp/hpautotest-gcc0/gcc/gmp -I/tmp/hpautotest-gcc0/cris-elf/gccobj/./mpfr
-I/tmp/hpautotest-gcc0/gcc/mpfr -I/tmp/hpautotest-gcc0/gcc/mpc/src  -I/tmp/hpautotest-gcc0/gcc/gcc/../libdecnumber
-I/tmp/hpautotest-gcc0/gcc/gcc/../libdecnumber/dpd
-I../libdecnumber    /tmp/hpautotest-gcc0/gcc/gcc/lto/lto.c -o lto/lto.o
/tmp/hpautotest-gcc0/gcc/gcc/lto/lto.c: In function 'void do_whole_program_analysis()':
/tmp/hpautotest-gcc0/gcc/gcc/lto/lto.c:2020: error: 'dump_mem_report' was not declared in this scope
make[2]: *** [lto/lto.o] Error 1

brgds, H-P
Andi Kleen - Sept. 8, 2012, 7:09 p.m.
On Sat, Sep 08, 2012 at 02:37:18PM -0400, Hans-Peter Nilsson wrote:
> On Thu, 6 Sep 2012, Andi Kleen wrote:
> 
> > From: Andi Kleen <ak@linux.intel.com>
> 
> > Passed bootstrap and testsuite on x86_64.
> 
> > +++ b/gcc/lto/lto.c
> > @@ -2016,6 +2016,8 @@ do_whole_program_analysis (void)
> >    /* Show the LTO report before launching LTRANS.  */
> >    if (flag_lto_report)
> >      print_lto_report ();
> > +  if (mem_report_wpa)
> > +    dump_mem_report ();
> >  }
> 
> Broke build for cris-elf:

Fixed now. Sorry for the complications.
-Andi

Patch

diff --git a/gcc/common.opt b/gcc/common.opt
index 87e28b5..73eebf4 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1470,6 +1470,10 @@  fmem-report
 Common Report Var(mem_report)
 Report on permanent memory allocation
 
+fmem-report-wpa
+Common Report Var(mem_report_wpa)
+Report on permanent memory allocation in WPA only
+
 ; This will attempt to merge constant section constants, if 1 only
 ; string constants and constants from constant pool, if 2 also constant
 ; variables.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 6cf7cec..5a5f9d2 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -328,7 +328,7 @@  Objective-C and Objective-C++ Dialects}.
 -feliminate-unused-debug-symbols -femit-class-debug-always @gol
 -fenable-@var{kind}-@var{pass} @gol
 -fenable-@var{kind}-@var{pass}=@var{range-list} @gol
--fdebug-types-section @gol
+-fdebug-types-section -fmem-report-wpa @gol
 -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report -fprofile-arcs @gol
 -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
 -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
@@ -5132,6 +5132,11 @@  pass when it finishes.
 Makes the compiler print some statistics about permanent memory
 allocation when it finishes.
 
+@item -fmem-report-wpa
+@opindex fmem-report-wpa
+Makes the compiler print some statistics about permanent memory
+allocation for the WPA phase only.
+
 @item -fpre-ipa-mem-report
 @opindex fpre-ipa-mem-report
 @item -fpost-ipa-mem-report
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 5da5412..3c59299 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -2016,6 +2016,8 @@  do_whole_program_analysis (void)
   /* Show the LTO report before launching LTRANS.  */
   if (flag_lto_report)
     print_lto_report ();
+  if (mem_report_wpa)
+    dump_mem_report ();
 }