[lld] [lld]Add lld/Common/BPSectionOrdererBase from MachO for reuse in ELF (PR #117514)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 26 10:08:51 PST 2025
MaskRay wrote:
Spent more time on BP. I believe that the virtual classes as done by this PR `BPSectionBase`/`BPSymbol` is quite wasteful. `BPSectionBase`/`BPSymbol` are thin wrappers that contain just one pointer. This is quite wasteful.
Perhaps we should treat Symbol and InputSection as `void *` in BPSectionOrderer.cpp and use the following class hierarchy instead.
```
class BPBase {
virtual getSectionSize(void *);
virtual isCodeSection(void *);
virtual StringRef getSymbolName(void *);
virtual uint64_t getSymbolValue(void *);
};
class BPMachO;
class BPELF; // future
```
Then we can avoid allocating a large section and `inputSections` (expensive for large ELF applications).
We could also leverage Curiously Recurring Template Pattern if we want to retain type information of symbols and sections.
https://github.com/llvm/llvm-project/pull/117514
More information about the llvm-commits
mailing list