diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-07-26 21:31:40 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-07-26 21:31:40 +0000 |
commit | 758a38ab2638ab5bb760a3f0f17970e505c754ca (patch) | |
tree | 20c51469f397cdea4c543dc55b62a9a1b3ce14d1 /gcc/doc | |
parent | 7d8df2aeddf6eb4b31431baf2b140ee49f405f5b (diff) | |
download | gcc-758a38ab2638ab5bb760a3f0f17970e505c754ca.tar.gz |
Hot/cold attributes for labels.
gcc/
* doc/extend.texi (attribute): Document hot/cold for labels.
* predict.c (tree_estimate_probability_bb): Handle hot/cold
attributes on user labels.
* predict.def (PRED_HOT_LABEL, PRED_COLD_LABEL): New.
gcc/c-family/
* c-common.c (handle_hot_attribute): Allow labels.
(handle_cold_attribute): Likewise.
gcc/testsuite/
* gcc.dg/attr-hotcold-1.c: New.
* gcc.dg/tree-ssa/attr-hotcold-2.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@189898 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/extend.texi | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index c3faf09efff..5d851a7386b 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -3345,33 +3345,53 @@ 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. +The @code{hot} attribute on a function is used to inform the compiler that +the 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. +The @code{hot} attribute on functions is not implemented in GCC versions +earlier than 4.3. + +@cindex @code{hot} label attribute +The @code{hot} attribute on a label is used to inform the compiler that +path following the label are more likely than paths that are not so +annotated. This attribute is used in cases where @code{__builtin_expect} +cannot be used, for instance with computed goto or @code{asm goto}. + +The @code{hot} attribute on labels is not implemented in GCC versions +earlier than 4.8. @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 mechanism. 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 +The @code{cold} attribute on functions is used to inform the compiler that +the function is unlikely to be 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 mechanism. 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}, cold functions are automatically detected and this attribute is ignored. -The @code{cold} attribute is not implemented in GCC versions earlier than 4.3. +The @code{cold} attribute on functions is not implemented in GCC versions +earlier than 4.3. + +@cindex @code{cold} label attribute +The @code{cold} attribute on labels is used to inform the compiler that +the path following the label is unlikely to be executed. This attribute +is used in cases where @code{__builtin_expect} cannot be used, for instance +with computed goto or @code{asm goto}. + +The @code{cold} attribute on labels is not implemented in GCC versions +earlier than 4.8. @item regparm (@var{number}) @cindex @code{regparm} attribute |