This decreases sizeof(lld::elf::InputSectionDescription) from 264 to 232.
// determine the insertion point. This is ok as we only merge into an
// InputSectionDescription once per pass, and at the end of the pass
// assignAddresses() will recalculate all the outSecOff values.
- std::vector<InputSection *> tmp;
+ SmallVector<InputSection *, 0> tmp;
tmp.reserve(isd.sections.size() + patches.size());
auto mergeCmp = [](const InputSection *a, const InputSection *b) {
if (a->outSecOff != b->outSecOff)
// determine the insertion point. This is ok as we only merge into an
// InputSectionDescription once per pass, and at the end of the pass
// assignAddresses() will recalculate all the outSecOff values.
- std::vector<InputSection *> tmp;
+ SmallVector<InputSection *, 0> tmp;
tmp.reserve(isd.sections.size() + patches.size());
auto mergeCmp = [](const InputSection *a, const InputSection *b) {
if (a->outSecOff != b->outSecOff)
// Collect section/value pairs of linker-script-defined symbols. This is used to
// check whether symbol values converge.
-static SymbolAssignmentMap getSymbolAssignmentValues(
- const std::vector<SectionCommand *> §ionCommands) {
+static SymbolAssignmentMap
+getSymbolAssignmentValues(ArrayRef<SectionCommand *> sectionCommands) {
SymbolAssignmentMap ret;
for (SectionCommand *cmd : sectionCommands) {
if (auto *assign = dyn_cast<SymbolAssignment>(cmd)) {
}
// Compute and remember which sections the InputSectionDescription matches.
-std::vector<InputSectionBase *>
+SmallVector<InputSectionBase *, 0>
LinkerScript::computeInputSections(const InputSectionDescription *cmd,
ArrayRef<InputSectionBase *> sections) {
- std::vector<InputSectionBase *> ret;
+ SmallVector<InputSectionBase *, 0> ret;
std::vector<size_t> indexes;
DenseSet<size_t> seen;
auto sortByPositionThenCommandLine = [&](size_t begin, size_t end) {
std::vector<InputSectionBase *> secs(part.armExidx->exidxSections.begin(),
part.armExidx->exidxSections.end());
for (SectionCommand *cmd : outCmd.commands)
- if (auto *isd = dyn_cast<InputSectionDescription>(cmd)) {
- std::vector<InputSectionBase *> matches =
- computeInputSections(isd, secs);
- for (InputSectionBase *s : matches)
+ if (auto *isd = dyn_cast<InputSectionDescription>(cmd))
+ for (InputSectionBase *s : computeInputSections(isd, secs))
discard(*s);
- }
}
}
-std::vector<InputSectionBase *>
+SmallVector<InputSectionBase *, 0>
LinkerScript::createInputSectionList(OutputSection &outCmd) {
- std::vector<InputSectionBase *> ret;
+ SmallVector<InputSectionBase *, 0> ret;
for (SectionCommand *cmd : outCmd.commands) {
if (auto *isd = dyn_cast<InputSectionDescription>(cmd)) {
// Create output sections described by SECTIONS commands.
void LinkerScript::processSectionCommands() {
auto process = [this](OutputSection *osec) {
- std::vector<InputSectionBase *> v = createInputSectionList(*osec);
+ SmallVector<InputSectionBase *, 0> v = createInputSectionList(*osec);
// The output section name `/DISCARD/' is special.
// Any input section assigned to it is discarded.
// Input sections that matches at least one of SectionPatterns
// will be associated with this InputSectionDescription.
- std::vector<SectionPattern> sectionPatterns;
+ SmallVector<SectionPattern, 0> sectionPatterns;
// Includes InputSections and MergeInputSections. Used temporarily during
// assignment of input sections to output sections.
- std::vector<InputSectionBase *> sectionBases;
+ SmallVector<InputSectionBase *, 0> sectionBases;
// Used after the finalizeInputSections() pass. MergeInputSections have been
// merged into MergeSyntheticSections.
- std::vector<InputSection *> sections;
+ SmallVector<InputSection *, 0> sections;
// Temporary record of synthetic ThunkSection instances and the pass that
// they were created in. This is used to insert newly created ThunkSections
// into Sections at the end of a createThunks() pass.
- std::vector<std::pair<ThunkSection *, uint32_t>> thunkSections;
+ SmallVector<std::pair<ThunkSection *, uint32_t>, 0> thunkSections;
// SectionPatterns can be filtered with the INPUT_SECTION_FLAGS command.
uint64_t withFlags;
void expandOutputSection(uint64_t size);
void expandMemoryRegions(uint64_t size);
- std::vector<InputSectionBase *>
+ SmallVector<InputSectionBase *, 0>
computeInputSections(const InputSectionDescription *,
ArrayRef<InputSectionBase *>);
- std::vector<InputSectionBase *> createInputSectionList(OutputSection &cmd);
+ SmallVector<InputSectionBase *, 0> createInputSectionList(OutputSection &cmd);
void discardSynthetic(OutputSection &);
// List of section patterns specified with KEEP commands. They will
// be kept even if they are unused and --gc-sections is specified.
- std::vector<InputSectionDescription *> keptSections;
+ SmallVector<InputSectionDescription *, 0> keptSections;
// A map from memory region name to a memory region descriptor.
llvm::MapVector<llvm::StringRef, MemoryRegion *> memoryRegions;
// A list of symbols referenced by the script.
- std::vector<llvm::StringRef> referencedSymbols;
+ SmallVector<llvm::StringRef, 0> referencedSymbols;
// Used to implement INSERT [AFTER|BEFORE]. Contains output sections that need
// to be reordered.
- std::vector<InsertCommand> insertCommands;
+ SmallVector<InsertCommand, 0> insertCommands;
// OutputSections specified by OVERWRITE_SECTIONS.
- std::vector<OutputSection *> overwriteSections;
+ SmallVector<OutputSection *, 0> overwriteSections;
// Sections that will be warned/errored by --orphan-handling.
- std::vector<const InputSectionBase *> orphanSections;
+ SmallVector<const InputSectionBase *, 0> orphanSections;
};
extern std::unique_ptr<LinkerScript> script;
});
// Merge sorted vectors of Thunks and InputSections by outSecOff
- std::vector<InputSection *> tmp;
+ SmallVector<InputSection *, 0> tmp;
tmp.reserve(isd->sections.size() + newThunks.size());
std::merge(isd->sections.begin(), isd->sections.end(),