[PATCH] D61629: [ELF] Try placing newly created ThunkSection at the end of the InputSection first

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 02:27:49 PDT 2019


MaskRay added a comment.

In D61629#1493047 <https://reviews.llvm.org/D61629#1493047>, @peter.smith wrote:

> I don't think it will do any harm, but it is probably not going to make a lot of difference. The thunk code makes the assumption that there is one branch range for the thunk section spacing, the vast majority will get placed in these sections. The no suitable ThunkSection case is for the small number of edge cases that don't fit the model, for example in Thumb there is one very rare branch that has a much shorter range so it may need to use this, but there aren't enough of them to make reuse opportunities that likely.


`createInitialThunkSections()` looks to me a very good global heuristic. Without it, `Relocations.cpp:1669 getISDThunkSec` is making local decisions that may not be very good. I think it this way. There are three positions to create the thunk:

- `IS->OutSecOff`: current status
- `IS->OutSecOff + IS->getSize()`: this patch. It improves sharing slightly.
- The last InputSection whose start address is before `IS->OutputSecOff + getThunkSectionSpacing()`. This is the best place to insert the thunk. (This is heuristically achieved by the proactive `createInitialThunkSections()`.

If you think the marginal benefit is not bad to have, I'll update the tests:)


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D61629





More information about the llvm-commits mailing list