[PATCH] D45841: Keep the output text sections with prefixes ".text.hot" , ".text.unlikely", ".text.startup", ".text.exit" separate

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 20 11:12:26 PDT 2018


pcc added a comment.

In https://reviews.llvm.org/D45841#1073829, @tmsriram wrote:

> In https://reviews.llvm.org/D45841#1072734, @pcc wrote:
>
> > In https://reviews.llvm.org/D45841#1072731, @tmsriram wrote:
> >
> > > In https://reviews.llvm.org/D45841#1072712, @pcc wrote:
> > >
> > > > Note that this ordering isn't necessarily best for every architecture. On ARM for example it is best to put the hot sections in the middle (see also https://reviews.llvm.org/D44969).
> > >
> > >
> > > When you say "this ordering" I am confused because currently there is no ordering of the output sections with prefix ".text".   Looking at it, seems like the order in which they were seen is the order in the final binary.
> >
> >
> > Yes, I meant the ordering imposed by this patch which would be hot followed by unlikely, startup, etc.
>
>
> Ok, this patch itself does not impose an ordering among output sections.  The ordering is arbitrary and follows what is seen first by the linker.  Look at the test case shown.  If I swap .text.exit and .text.startup for instance, the order would be different.


Got it. Sorry I missed that part.

>>>> I think that for hot sections my preference would be to treat them as if they were listed in `--symbol-ordering-file`. The behaviour for the other sections seems fine to me.
>>> 
>>> So, this patch would break any symbol ordering across prefixes.  Maybe it is better to disable this feature if symbol-ordering-file is used, what do you think?
>> 
>> That would also work for now.
> 
> I was thinking a lot more about this and playing with it.  Two things:
> 
> - This patch will break symbol-ordering-file for symbols that are in two different output sections.
> - This patch could also affect linker scripts which assume all .text is in the same output section.
> 
>   Given this, I believe it might be better to not change the default behavior and have this feature under a flag, just like what gold does.  What do you think?

Seems reasonable. Even if we made it conditional on presence of `--symbol-ordering-file` or a linker script I think it would be a little confusing for either of those things to have that sort of effect on prefixed output sections.


https://reviews.llvm.org/D45841





More information about the llvm-commits mailing list