Add an OutputDesc class inheriting from SectionCommand. An OutputDesc wraps an
OutputSection.
With this change, we can inline InputSection::getParent.
My lld executable is 2.3KiB smaller.
Paths
| Differential D120650
[ELF] Don't use multiple inheritance for OutputSection. NFC ClosedPublic Authored by MaskRay on Feb 28 2022, 1:36 AM.
Details Summary Add an OutputDesc class inheriting from SectionCommand. An OutputDesc wraps an With this change, we can inline InputSection::getParent. My lld executable is 2.3KiB smaller.
Diff Detail
Event TimelineComment Actions No objections for the change. I think it makes sense to logically separate OutputSection from SectionCommand. I'd like to see if anyone else has a strong opinion as there are quite a few changes and some more dynamic memory allocations. I'm wondering if there may be a way of avoiding those somehow, for example could an implicit conversion operator to OutputSection* be added?
Comment Actions
I have switched to struct OutputDesc final : SectionCommand { OutputSection osec; ... }; make<OutputDesc> is used in replace of previous make<OutputDescription>. There is no extra allocation.
The majority differences are due to dyn_cast<OutputSection> => dyn_cast<OutputDesc> which need changes. An conversion operator may help a few osd->osec places but they are typically coupled with dyn_cast<OutputDesc>, so the total number of changes may not decrease a lot.
Comment Actions Just one small comment on some function names, although that is not a strong opinion. No objections to making the changes, will wait a few days before setting approved to see if there are dissenting opinions. This revision is now accepted and ready to land.Mar 7 2022, 9:22 AM This revision was landed with ongoing or failed builds.Mar 8 2022, 11:23 AM Closed by commit rG6c814931bcaa: [ELF] Don't use multiple inheritance for OutputSection. NFC (authored by MaskRay). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 411855 lld/ELF/Driver.cpp
lld/ELF/ICF.cpp
lld/ELF/InputSection.h
lld/ELF/InputSection.cpp
lld/ELF/LinkerScript.h
lld/ELF/LinkerScript.cpp
lld/ELF/MapFile.cpp
lld/ELF/OutputSections.h
lld/ELF/OutputSections.cpp
lld/ELF/ScriptParser.cpp
lld/ELF/SyntheticSections.cpp
lld/ELF/Writer.cpp
|
Given that this doesn't use anything about the representation of OutputSection, would it be better to move it to the LinkerScript.h header.