This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

-fprofile-generate/-fprofile-use options


Hi,
at the present, if you want to use profile feedback you need to specify
-fprofile-arcs -fprofile-values -fvpt when profiling and -fbranch-probabilities
-fvpt and several of optimizations that mostly win with profile feedback such
as -funroll-loops, -fpeel-loops, -ftracer.
This is somewhat absurd and definitly prevents users from trying this out.
The attached patch adds -fprofile-generate and -fprofile-use that is similar to
what other compiler have.

Bootstrapped/regtested i386
Honza

	* common.opt (fprofile-generate,fprofile-use): Add.
	* gcc.c (LINK_COMMAND_SPEC): Arrange -fprofile-generate to imply -lgcov
	* opts.c (profile_arc_flag_set, flag_profile_values_set,
	flag_unroll_loops_set, flag_tracer_set,
	flag_value_profile_transformations_set,
	flag_peel_loops_set): New static variables.
	(common_handle_option): Deal with -fprofile-generate/-fprofile-use
	* invoke.texi (-fprofile-generate, -fprofile-use): Describe.
Index: common.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/common.opt,v
retrieving revision 1.22
diff -c -3 -p -r1.22 common.opt
*** common.opt	1 Dec 2003 18:25:31 -0000	1.22
--- common.opt	3 Dec 2003 23:37:11 -0000
*************** fprofile-arcs
*** 513,518 ****
--- 513,526 ----
  Common
  Insert arc-based program profiling code
  
+ fprofile-generate
+ Common
+ Enable common options used for profiling application to be later used for profile feedback
+ 
+ fprofile-use
+ Common
+ Enable common options used for using profiled produce by -fprofile-generate
+ 
  fprofile-values
  Common
  Insert code to profile values of expressions
Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.396
diff -c -3 -p -r1.396 gcc.c
*** gcc.c	30 Nov 2003 08:23:23 -0000	1.396
--- gcc.c	3 Dec 2003 23:37:54 -0000
*************** proper position among the other output f
*** 676,682 ****
  %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
      %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
      %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
!     %{static:} %{L*} %(link_libgcc) %o %{fprofile-arcs:-lgcov}\
      %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}\
      %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"
  #endif
--- 676,682 ----
  %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
      %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
      %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
!     %{static:} %{L*} %(link_libgcc) %o %{fprofile-arcs|fprofile-generate:-lgcov}\
      %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}\
      %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"
  #endif
Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.47
diff -c -3 -p -r1.47 opts.c
*** opts.c	1 Dec 2003 18:25:32 -0000	1.47
--- opts.c	3 Dec 2003 23:38:05 -0000
*************** static unsigned int columns = 80;
*** 148,153 ****
--- 148,160 ----
  /* What to print when a switch has no documentation.  */
  static const char undocumented_msg[] = N_("This switch lacks documentation");
  
+ /* Used for bookkeeping on whether user set these flags so
+    -fprofile-use/-fprofile-generate does not use them.  */
+ static bool profile_arc_flag_set, flag_profile_values_set;
+ static bool flag_unroll_loops_set, flag_tracer_set;
+ static bool flag_value_profile_transformations_set;
+ static bool flag_peel_loops_set;
+ 
  /* Input file names.  */
  const char **in_fnames;
  unsigned num_in_fnames;
*************** common_handle_option (size_t scode, cons
*** 1135,1140 ****
--- 1142,1148 ----
        break;
  
      case OPT_fpeel_loops:
+       flag_peel_loops_set = true;
        flag_peel_loops = value;
        break;
  
*************** common_handle_option (size_t scode, cons
*** 1167,1180 ****
--- 1175,1215 ----
        break;
  
      case OPT_fprofile_arcs:
+       profile_arc_flag_set = true;
        profile_arc_flag = value;
        break;
  
+     case OPT_fprofile_use:
+       if (!profile_arc_flag_set)
+         profile_arc_flag = value;
+       if (!flag_profile_values_set)
+         flag_profile_values = value;
+       if (!flag_unroll_loops_set)
+         flag_unroll_loops = value;
+       if (!flag_peel_loops_set)
+         flag_peel_loops = value;
+       if (!flag_tracer_set)
+         flag_tracer = value;
+       if (!flag_value_profile_transformations_set)
+         flag_value_profile_transformations = value;
+       break;
+ 
+     case OPT_fprofile_generate:
+       if (!profile_arc_flag_set)
+         profile_arc_flag = value;
+       if (!flag_profile_values_set)
+         flag_profile_values = value;
+       if (!flag_value_profile_transformations_set)
+         flag_value_profile_transformations = value;
+       break;
+ 
      case OPT_fprofile_values:
+       flag_profile_values_set = true;
        flag_profile_values = value;
        break;
  
      case OPT_fvpt:
+       flag_value_profile_transformations_set = value;
        flag_value_profile_transformations = value;
        break;
  
*************** common_handle_option (size_t scode, cons
*** 1358,1363 ****
--- 1393,1399 ----
        break;
  
      case OPT_ftracer:
+       flag_tracer_set = true;
        flag_tracer = value;
        break;
  
*************** common_handle_option (size_t scode, cons
*** 1378,1383 ****
--- 1414,1420 ----
        break;
  
      case OPT_funroll_loops:
+       flag_unroll_loops_set = true;
        flag_unroll_loops = value;
        break;
  
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.365
diff -c -3 -p -r1.365 invoke.texi
*** doc/invoke.texi	1 Dec 2003 18:25:39 -0000	1.365
--- doc/invoke.texi	3 Dec 2003 23:39:05 -0000
*************** in the following sections.
*** 282,287 ****
--- 282,288 ----
  -fno-trapping-math  -fno-zero-initialized-in-bss @gol
  -fomit-frame-pointer  -foptimize-register-move @gol
  -foptimize-sibling-calls  -fprefetch-loop-arrays @gol
+ -fprofile-generate -fprofile-use @gol
  -freduce-all-givs  -fregmove  -frename-registers @gol
  -freorder-blocks  -freorder-functions @gol
  -frerun-cse-after-loop  -frerun-loop-opt @gol
*************** we perform a copy-propagation pass to tr
*** 4392,4397 ****
--- 4393,4413 ----
  and occasionally eliminate the copy.
  
  Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
+ 
+ @item -fprofile-generate
+ @opindex fprofile-generate
+ Enable options usually used for instrumenting application to produce profile usefull
+ for later recompilation profile feedback based optimization.
+ 
+ The following options are enabled: @code{-fprofile-arcs}, @code{-fprofile-values}, @code{-fvpt}
+ 
+ @item -fprofile-use
+ @opindex fprofile-use
+ Enable profile feedback based optimizations and optimizations generally profitable
+ only with profile feedback available.
+ 
+ The following options are enabled: @code{-fbranch-probabilities}, @code{-fvpt},
+ @code{-funroll-loops}, @code{-fpeel-loops}, @code{-ftracer}
  
  @end table
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]