Linker support for -freorder-functions?
H. J. Lu
hjl@lucon.org
Thu Aug 5 22:38:00 GMT 2004
On Thu, Aug 05, 2004 at 03:02:27PM -0700, Mike Stump wrote:
> On Aug 5, 2004, at 1:58 PM, H. J. Lu wrote:
> >But it is useless without linker support. Should linker group
> >text.hot/text.unlikely like
> >
> >*(.text.hot)
> >*(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
> >KEEP (*(.text.*personality*))
> >*(.text.unlikely)
>
> Seems almost reasonable from my humble perspective... though, hot
> would be all together in the .text.* area... so, listing it first
> isn't strictly necessary.... and, likewise, unlikely would tend to
> group together as well, so strictly speaking, listing it last should
> not be necessary...
I was wondering what the reasonable memory layout for this is. I
don't think you want .text.unlikely to be next to .text.hot.
>
> The change might be wrong from a {non-,}RELOCATING perspective, a
> script wizz should be able to offer advice...
>
> >Also, should section names be .text.hot/.text.unlikely instead of
> >text.hot/text.unlikely?
>
> Again, seems reasonable...
Here is a patch.
H.J.
---
2004-08-05 H.J. Lu <hongjiu.lu@intel.com>
* doc/invoke.text (freorder-functions): Add a leading `.' to
"text.hot" and "text.unlikely" sections.
--- gcc/doc/invoke.texi.sec 2004-07-13 14:43:22.000000000 -0700
+++ gcc/doc/invoke.texi 2004-08-05 15:34:37.046887526 -0700
@@ -4198,8 +4198,8 @@ Enabled at levels @option{-O2}, @option{
@opindex freorder-functions
Reorder basic blocks in the compiled function in order to reduce number of
taken branches and improve code locality. This is implemented by using special
-subsections @code{text.hot} for most frequently executed functions and
-@code{text.unlikely} for unlikely executed functions. Reordering is done by
+subsections @code{.text.hot} for most frequently executed functions and
+@code{.text.unlikely} for unlikely executed functions. Reordering is done by
the linker so object file format must support named sections and linker must
place them in a reasonable way.
More information about the Binutils
mailing list