[PATCH] D128382: [LLD] Two tweaks to symbol ordering scheme

YongKang Zhu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 15:55:04 PDT 2022


yozhu added a comment.

>>> In D128382#3603513 <https://reviews.llvm.org/D128382#3603513>, @MaskRay wrote:
>>>
>>>> How does it save one page?
>>>
>>> Hot code will always be placed together, so where it starts impact how many pages it will occupy.  Moving it towards the beginning of the output section increases the possibility that one less page will be taken.
>>
>> I am not sure this is true.
>> For -z separate-code layout, PT_LOAD program header has an aligned start address. I agree that placing hot code at the start may potentially remove one hot page.
>> For -z noseparate-code layout, I think we can construct a case that placing hot code at the start may use one more page.
>
> This is to follow what ordering implies.  For CISC machine target the linker won't do anything but just strictly follow the specified order.

For the `-z noseparate-code` case, it would be the same probability for the impact on number of pages used by hot contributions. We don't know where in a page .text section will start, so it will be purely random or with equal probability that hot contribution may take one more page, one less page, or take same number of pages, between placing hot contributions at section start (like what the linker does for CISC machines) and shuffling some amount of cold contributions before hot ones.

The current logic is to avoid generating branch thunks only.  So if we know branch thunk is no needed, why bother doing the extra shuffling working?

And for the `-z separarte-code` case, it is guaranteed to be better (or being same in rare cases).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128382/new/

https://reviews.llvm.org/D128382



More information about the llvm-commits mailing list