diff options
author | Jan Hubicka <jh@suse.cz> | 2007-03-06 19:57:27 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2007-03-06 18:57:27 +0000 |
commit | 52bf96d2f299e9e69db82b5d0ae7186ab949339b (patch) | |
tree | 6db0f16a08d3e0f5d8feea8a59bd2d27420fa52d /gcc/doc | |
parent | 20f326d7103a4d9d821a54ad5fa030c8a9aa2478 (diff) | |
download | gcc-52bf96d2f299e9e69db82b5d0ae7186ab949339b.zip gcc-52bf96d2f299e9e69db82b5d0ae7186ab949339b.tar.gz gcc-52bf96d2f299e9e69db82b5d0ae7186ab949339b.tar.bz2 |
errors.h (warning, [...]): Mark as cold.
* errors.h (warning, error, fatal, internal_error): Mark as cold.
* predict.c (maybe_hot_bb): Cold functions are never hot; hot functions
are hot.
(probably_cold_bb_p): Cold functions are cold.
(probably_never_executed_bb_p): Cold functions are cold.
(tree_bb_level_predictions): Predict calls to cold functions as not
taken.
(compute_function_frequency): Check hot/cold attributes.
* function.h (function_frequency): Update comments.
* predict.def (PRED_COLD_FUNCTION): Predict cold function.
* c-common.c (handle_hot_attribute, handle_cold_attribute): New.
(c_common_att): Add cold and hot.
* doc/extend.texi (hot,cold attributes): Document.
* ansidecl.h (ATTRIBUTE_COLD, ATTRIBUTE_HOT): New.
From-SVN: r122632
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/extend.texi | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index dfa4f5d..788cbfc 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -1578,10 +1578,11 @@ attributes are currently defined for functions on all targets: @code{section}, @code{constructor}, @code{destructor}, @code{used}, @code{unused}, @code{deprecated}, @code{weak}, @code{malloc}, @code{alias}, @code{warn_unused_result}, @code{nonnull}, -@code{gnu_inline} and @code{externally_visible}. Several other -attributes are defined for functions on particular target systems. Other -attributes, including @code{section} are supported for variables declarations -(@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}). +@code{gnu_inline} and @code{externally_visible}, @code{hot}, @code{cold}. +Several other attributes are defined for functions on particular target +systems. Other attributes, including @code{section} are supported for +variables declarations (@pxref{Variable Attributes}) and for types (@pxref{Type +Attributes}). You may also specify attributes with @samp{__} preceding and following each keyword. This allows you to use them in header files without @@ -2242,6 +2243,35 @@ two consecutive calls (such as @code{feof} in a multithreading environment). The attribute @code{pure} is not implemented in GCC versions earlier than 2.96. +@item hot +@cindex @code{hot} function attribute +The @code{hot} attribute is used to inform the compiler that a function is a +hot spot of the compiled program. The function is optimized more aggressively +and on many target it is placed into special subsection of the text section so +all hot functions appears close together improving locality. + +When profile feedback is available, via @option{-fprofile-use}, hot functions +are automatically detected and this attribute is ignored. + +The @code{hot} attribute is not implemented in GCC versions earlier than 4.3. + +@item cold +@cindex @code{cold} function attribute +The @code{cold} attribute is used to inform the compiler that a function is +unlikely executed. The function is optimized for size rather than speed and on +many targets it is placed into special subsection of the text section so all +cold functions appears close together improving code locality of non-cold parts +of program. The paths leading to call of cold functions within code are marked +as unlikely by the branch prediction mechanizm. It is thus useful to mark +functions used to handle unlikely conditions, such as @code{perror}, as cold to +improve optimization of hot functions that do call marked functions in rare +occasions. + +When profile feedback is available, via @option{-fprofile-use}, hot functions +are automatically detected and this attribute is ignored. + +The @code{hot} attribute is not implemented in GCC versions earlier than 4.3. + @item regparm (@var{number}) @cindex @code{regparm} attribute @cindex functions that are passed arguments in registers on the 386 |