OSDN Git Service

* doc/invoke.texi (-fipa-profile): Document.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Apr 2010 14:56:33 +0000 (14:56 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 05:36:24 +0000 (14:36 +0900)
* opts.c (decode_options): Enable ipa-profile at -O1.
* timevar.def (TV_IPA_PROFILE): Define.
* common.opt (fipa-profile): Add.
* cgraph.c (cgraph_clone_node): Set local flag and clear vtable method flag
for clones.
(cgraph_propagate_frequency): Handle only local ones.
* tree-pass.h (pass_ipa_profile): Declare.
* ipa-profile.c (gate_profile): Use flag_ipa_profile.
(pass_ipa_profile): Use TV_IPA_PROFILE.
* ipa.c (ipa_profile): New function.
(gate_ipa_profile): Likewise.
(pass_ipa_profile): New global variable.
* passes.c (pass_ipa_profile): New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158788 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cgraph.c
gcc/doc/invoke.texi
gcc/ipa.c
gcc/opts.c
gcc/passes.c
gcc/tree-pass.h

index c369a66..60ca105 100644 (file)
@@ -1,3 +1,20 @@
+2010-04-27  Jan Hubicka  <jh@suse.cz>
+
+       * doc/invoke.texi (-fipa-profile): Document.
+       * opts.c (decode_options): Enable ipa-profile at -O1.
+       * timevar.def (TV_IPA_PROFILE): Define.
+       * common.opt (fipa-profile): Add.
+       * cgraph.c (cgraph_clone_node): Set local flag and clear vtable method flag
+       for clones.
+       (cgraph_propagate_frequency): Handle only local ones.
+       * tree-pass.h (pass_ipa_profile): Declare.
+       * ipa-profile.c (gate_profile): Use flag_ipa_profile.
+       (pass_ipa_profile): Use TV_IPA_PROFILE.
+       * ipa.c (ipa_profile): New function.
+       (gate_ipa_profile): Likewise.
+       (pass_ipa_profile): New global variable.
+       * passes.c (pass_ipa_profile): New.
+
 2010-04-27  Nathan Froyd  <froydnj@codesourcery.com>
 
        * config/arm/arm.c (arm_expand_builtin): Remove redundant declaration.
index 95f4411..781d3b0 100644 (file)
@@ -1897,6 +1897,8 @@ cgraph_clone_node (struct cgraph_node *n, gcov_type count, int freq,
   new_node->analyzed = n->analyzed;
   new_node->local = n->local;
   new_node->local.externally_visible = false;
+  new_node->local.local = true;
+  new_node->local.vtable_method = false;
   new_node->global = n->global;
   new_node->rtl = n->rtl;
   new_node->count = count;
@@ -2314,7 +2316,7 @@ cgraph_propagate_frequency (struct cgraph_node *node)
 {
   bool maybe_unlikely_executed = true, maybe_executed_once = true;
   struct cgraph_edge *edge;
-  if (node->needed || node->local.externally_visible)
+  if (!node->local.local)
     return false;
   gcc_assert (node->analyzed);
   if (node->frequency == NODE_FREQUENCY_HOT)
index 107fabe..23f744b 100644 (file)
@@ -257,7 +257,6 @@ Objective-C and Objective-C++ Dialects}.
 -Wsign-compare  -Wsign-conversion  -Wstack-protector @gol
 -Wstrict-aliasing -Wstrict-aliasing=n @gol
 -Wstrict-overflow -Wstrict-overflow=@var{n} @gol
--Wsuggest-attribute=@r{[}const@r{|}pure@r{]} @gol
 -Wswitch  -Wswitch-default  -Wswitch-enum -Wsync-nand @gol
 -Wsystem-headers  -Wtrigraphs  -Wtype-limits  -Wundef  -Wuninitialized @gol
 -Wunknown-pragmas  -Wno-pragmas @gol
@@ -346,7 +345,7 @@ Objective-C and Objective-C++ Dialects}.
 -finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol
 -finline-small-functions -fipa-cp -fipa-cp-clone -fipa-matrix-reorg -fipa-pta @gol
 -fipa-profile -fipa-pure-const -fipa-reference -fipa-struct-reorg @gol
--fira-algorithm=@var{algorithm} @gol
+-fipa-type-escape -fira-algorithm=@var{algorithm} @gol
 -fira-region=@var{region} -fira-coalesce @gol
 -fira-loop-pressure -fno-ira-share-save-slots @gol
 -fno-ira-share-spill-slots -fira-verbose=@var{n} @gol
@@ -1172,9 +1171,9 @@ program and of the preprocessor and the compiler proper.
 
 @item -###
 @opindex ###
-Like @option{-v} except the commands are not executed and arguments
-are quoted unless they contain only alphanumeric characters or @code{./-_}.
-This is useful for shell scripts to capture the driver-generated command lines.
+Like @option{-v} except the commands are not executed and all command
+arguments are quoted.  This is useful for shell scripts to capture the
+driver-generated command lines.
 
 @item -pipe
 @opindex pipe
@@ -1929,15 +1928,6 @@ Disable built-in declarations of functions that are not mandated by
 ANSI/ISO C@.  These include @code{ffs}, @code{alloca}, @code{_exit},
 @code{index}, @code{bzero}, @code{conjf}, and other related functions.
 
-@item -fnothrow-opt
-@opindex fnothrow-opt
-Treat a @code{throw()} exception specification as though it were a
-@code{noexcept} specification to reduce or eliminate the text size
-overhead relative to a function with no exception specification.  The
-semantic effect is that an exception thrown out of a function with
-such an exception specification will result in a call to
-@code{terminate} rather than @code{unexpected}.
-
 @item -fno-operator-names
 @opindex fno-operator-names
 Do not treat the operator name keywords @code{and}, @code{bitand},
@@ -1991,15 +1981,6 @@ unambiguous base classes.
 Emit statistics about front-end processing at the end of the compilation.
 This information is generally only useful to the G++ development team.
 
-@item -fstrict-enums
-@opindex fstrict-enums
-Allow the compiler to optimize using the assumption that a value of
-enumeration type can only be one of the values of the enumeration (as
-defined in the C++ standard; basically, a value which can be
-represented in the minimum number of bits needed to represent all the
-enumerators).  This assumption may not be valid if the program uses a
-cast to convert an arbitrary integer value to the enumeration type.
-
 @item -ftemplate-depth=@var{n}
 @opindex ftemplate-depth
 Set the maximum instantiation depth for template classes to @var{n}.
@@ -2764,13 +2745,12 @@ Warn if feedback profiles do not match when using the
 If a source file was changed between @option{-fprofile-gen} and
 @option{-fprofile-use}, the files with the profile feedback can fail
 to match the source file and GCC can not use the profile feedback
-information.  By default, this warning is enabled and is treated as an
-error.  @option{-Wno-coverage-mismatch} can be used to disable the
-warning or @option{-Wno-error=coverage-mismatch} can be used to
-disable the error.  Disable the error for this warning can result in
-poorly optimized code, so disabling the error is useful only in the
-case of very minor changes such as bug fixes to an existing code-base.
-Completely disabling the warning is not recommended.
+information.  By default, GCC emits an error message in this case.
+The option @option{-Wcoverage-mismatch} emits a warning instead of an
+error.  GCC does not use appropriate feedback profiles, so using this
+option can result in poorly optimized code.  This option is useful
+only in the case of very minor changes such as bug fixes to an
+existing code-base.
 
 @end table
 
@@ -2910,8 +2890,8 @@ Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
 -Wc++0x-compat  @gol
 -Wchar-subscripts  @gol
 -Wenum-compare @r{(in C/Objc; this is on by default in C++)} @gol
--Wimplicit-int @r{(C and Objective-C only)} @gol
--Wimplicit-function-declaration @r{(C and Objective-C only)} @gol
+-Wimplicit-int  @gol
+-Wimplicit-function-declaration  @gol
 -Wcomment  @gol
 -Wformat   @gol
 -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}  @gol
@@ -3154,7 +3134,7 @@ enabled by default and it is made into an error by
 @option{-pedantic-errors}. This warning is also enabled by
 @option{-Wall}.
 
-@item -Wimplicit @r{(C and Objective-C only)}
+@item -Wimplicit
 @opindex Wimplicit
 @opindex Wno-implicit
 Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
@@ -3641,36 +3621,11 @@ comparisons, so this warning level will give a very large number of
 false positives.
 @end table
 
-@item -Wsuggest-attribute=@r{[}const@r{|}pure@r{]}
-@opindex Wsuggest-attribute=
-@opindex Wno-suggest-attribute=
-Warn for cases where adding an attribute may be beneficial. The
-attributes currently supported are listed below.
-
-@table @gcctabopt
-@item -Wsuggest-attribute=pure
-@itemx -Wsuggest-attribute=const
-@opindex Wsuggest-attribute=pure
-@opindex Wno-suggest-attribute=pure
-@opindex Wsuggest-attribute=const
-@opindex Wno-suggest-attribute=const
-
-Warn about functions which might be candidates for attributes
-@code{pure} or @code{const}.  The compiler only warns for functions
-visible in other compilation units or if it cannot prove that the
-function returns normally. A function returns normally if it doesn't
-contain an infinite loop nor returns abnormally by throwing, calling
-@code{abort()} or trapping.  This analysis requires option
-@option{-fipa-pure-const}, which is enabled by default at @option{-O}
-and higher.  Higher optimization levels improve the accuracy of the
-analysis.
-@end table
-
 @item -Warray-bounds
 @opindex Wno-array-bounds
 @opindex Warray-bounds
 This option is only active when @option{-ftree-vrp} is active
-(default for @option{-O2} and above). It warns about subscripts to arrays
+(default for -O2 and above). It warns about subscripts to arrays
 that are always out of bounds. This warning is enabled by @option{-Wall}.
 
 @item -Wno-div-by-zero
@@ -6633,7 +6588,8 @@ Perform structure reorganization optimization, that change C-like structures
 layout in order to better utilize spatial locality.  This transformation is
 affective for programs containing arrays of structures.  Available in two
 compilation modes: profile-based (enabled with @option{-fprofile-generate})
-or static (which uses built-in heuristics).  It works only in whole program
+or static (which uses built-in heuristics).  Require @option{-fipa-type-escape}
+to provide the safety of this transformation.  It works only in whole program
 mode, so it requires @option{-fwhole-program} and @option{-combine} to be
 enabled.  Structures considered @samp{cold} by this transformation are not
 affected (see @option{--param struct-reorg-cold-struct-ratio=@var{value}}).
@@ -6647,6 +6603,15 @@ and reference analysis.  This option can cause excessive memory and
 compile-time usage on large compilation units.  It is not enabled by
 default at any optimization level.
 
+@item -fipa-profile
+@opindex fipa-profile
+Perform interprocedural profile propagation.  The functions called only from
+cold functions are marked as cold. Also functions executed once (such as
+@code{cold}, @code{noreturn}, static constructors or destructors) are identified. Cold
+functions and loop less parts of functions executed once are then optimized for
+size.
+Enabled by default at @option{-O} and higher.
+
 @item -fipa-cp
 @opindex fipa-cp
 Perform interprocedural constant propagation.
@@ -7447,6 +7412,8 @@ that otherwise would not fit in memory.  This option enables
 
 Disabled by default.
 
+This option is experimental.
+
 @item -fwpa
 @opindex fwpa
 This is an internal option used by GCC when compiling with
@@ -8507,7 +8474,8 @@ The size of L2 cache, in kilobytes.
 
 @item min-insn-to-prefetch-ratio
 The minimum ratio between the number of instructions and the
-number of prefetches to enable prefetching in a loop.
+number of prefetches to enable prefetching in a loop with an
+unknown trip count.
 
 @item prefetch-min-insn-to-mem-ratio
 The minimum ratio between the number of instructions and the
@@ -9738,6 +9706,13 @@ Put functions, data, and readonly data in @var{text-section},
 by default.  This can be overridden with the @code{section} attribute.
 @xref{Variable Attributes}.
 
+@item -mfix-cortex-m3-ldrd
+@opindex mfix-cortex-m3-ldrd
+Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
+with overlapping destination and base registers are used.  This option avoids
+generating these instructions.  This option is enabled by default when
+@option{-mcpu=cortex-m3} is specified.
+
 @end table
 
 @node ARM Options
@@ -10084,13 +10059,6 @@ This is enabled by default on targets (uClinux, SymbianOS) where the runtime
 loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
 is specified.
 
-@item -mfix-cortex-m3-ldrd
-@opindex mfix-cortex-m3-ldrd
-Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
-with overlapping destination and base registers are used.  This option avoids
-generating these instructions.  This option is enabled by default when
-@option{-mcpu=cortex-m3} is specified.
-
 @end table
 
 @node AVR Options
index 8295357..00488b2 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -762,3 +762,83 @@ debug_cgraph_node_set (cgraph_node_set set)
   dump_cgraph_node_set (stderr, set);
 }
 
+/* Simple ipa profile pass propagating frequencies across the callgraph.  */
+
+static unsigned int
+ipa_profile (void)
+{
+  struct cgraph_node **order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
+  struct cgraph_edge *e;
+  int order_pos;
+  bool something_changed = false;
+  int i;
+
+  order_pos = cgraph_postorder (order);
+  for (i = order_pos - 1; i >= 0; i--)
+    {
+      if (order[i]->local.local && cgraph_propagate_frequency (order[i]))
+       {
+         for (e = order[i]->callees; e; e = e->next_callee)
+           if (e->callee->local.local && !e->callee->aux)
+             {
+               something_changed = true;
+               e->callee->aux = (void *)1;
+             }
+       }
+      order[i]->aux = NULL;
+    }
+
+  while (something_changed)
+    {
+      something_changed = false;
+      for (i = order_pos - 1; i >= 0; i--)
+       {
+         if (order[i]->aux && cgraph_propagate_frequency (order[i]))
+           {
+             for (e = order[i]->callees; e; e = e->next_callee)
+               if (e->callee->local.local && !e->callee->aux)
+                 {
+                   something_changed = true;
+                   e->callee->aux = (void *)1;
+                 }
+           }
+         order[i]->aux = NULL;
+       }
+    }
+  free (order);
+  return 0;
+}
+
+static bool
+gate_ipa_profile (void)
+{
+  return flag_ipa_profile;
+}
+
+struct ipa_opt_pass_d pass_ipa_profile =
+{
+ {
+  IPA_PASS,
+  "ipa-profile",                       /* name */
+  gate_ipa_profile,                    /* gate */
+  ipa_profile,                         /* execute */
+  NULL,                                        /* sub */
+  NULL,                                        /* next */
+  0,                                   /* static_pass_number */
+  TV_IPA_PROFILE,                      /* tv_id */
+  0,                                   /* properties_required */
+  0,                                   /* properties_provided */
+  0,                                   /* properties_destroyed */
+  0,                                   /* todo_flags_start */
+  0                                     /* todo_flags_finish */
+ },
+ NULL,                                 /* generate_summary */
+ NULL,                                 /* write_summary */
+ NULL,                                 /* read_summary */
+ NULL,                                 /* write_optimization_summary */
+ NULL,                                 /* read_optimization_summary */
+ NULL,                                 /* stmt_fixup */
+ 0,                                    /* TODOs */
+ NULL,                                 /* function_transform */
+ NULL                                  /* variable_transform */
+};
index 0009a74..507b502 100644 (file)
@@ -858,6 +858,7 @@ decode_options (unsigned int argc, const char **argv)
   flag_if_conversion2 = opt1;
   flag_ipa_pure_const = opt1;
   flag_ipa_reference = opt1;
+  flag_ipa_profile = opt1;
   flag_merge_constants = opt1;
   flag_split_wide_types = opt1;
   flag_tree_ccp = opt1;
index e503dc6..ee6de54 100644 (file)
@@ -803,6 +803,7 @@ init_optimization_passes (void)
 
   p = &all_regular_ipa_passes;
   NEXT_PASS (pass_ipa_whole_program_visibility);
+  NEXT_PASS (pass_ipa_profile);
   NEXT_PASS (pass_ipa_cp);
   NEXT_PASS (pass_ipa_inline);
   NEXT_PASS (pass_ipa_reference);
index 3d7798e..a82dc83 100644 (file)
@@ -459,6 +459,7 @@ extern struct simple_ipa_opt_pass pass_ipa_pta;
 extern struct simple_ipa_opt_pass pass_ipa_struct_reorg;
 extern struct ipa_opt_pass_d pass_ipa_lto_wpa_fixup;
 extern struct ipa_opt_pass_d pass_ipa_lto_finish_out;
+extern struct ipa_opt_pass_d pass_ipa_profile;
 
 extern struct gimple_opt_pass pass_all_optimizations;
 extern struct gimple_opt_pass pass_cleanup_cfg_post_optimizing;