Skip to content

Commit 5569078

Browse files
ColibrowMaskRay
authored andcommitted
try to refine symbol/section
1 parent 14658cc commit 5569078

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lld/ELF/BPSectionOrderer.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,21 @@ lld::elf::runBalancedPartitioning(Ctx &ctx, llvm::StringRef profilePath,
3838
SmallVector<std::unique_ptr<BPSectionBase>> sections;
3939
DenseSet<const InputSectionBase *> seenSections;
4040

41+
auto addSection = [&](Symbol &sym) {
42+
if (sym.getSize() == 0)
43+
return;
44+
if (auto *d = dyn_cast<Defined>(&sym))
45+
if (auto *sec = dyn_cast_or_null<InputSectionBase>(d->section))
46+
if (seenSections.insert(sec).second)
47+
sections.emplace_back(std::make_unique<BPSectionELF>(sec));
48+
};
49+
4150
for (Symbol *sym : ctx.symtab->getSymbols())
42-
if (sym->getSize() > 0)
43-
if (auto *d = dyn_cast<Defined>(sym))
44-
if (auto *sec = dyn_cast_or_null<InputSectionBase>(d->section))
45-
if (seenSections.insert(sec).second)
46-
sections.emplace_back(std::make_unique<BPSectionELF>(sec));
51+
addSection(*sym);
4752

4853
for (ELFFileBase *file : ctx.objectFiles)
4954
for (Symbol *sym : file->getLocalSymbols())
50-
if (sym->getSize() > 0)
51-
if (auto *d = dyn_cast<Defined>(sym))
52-
if (auto *sec = dyn_cast_or_null<InputSectionBase>(d->section))
53-
if (seenSections.insert(sec).second)
54-
sections.emplace_back(std::make_unique<BPSectionELF>(sec));
55+
addSection(*sym);
5556

5657
auto reorderedSections = BPSectionBase::reorderSectionsByBalancedPartitioning(
5758
profilePath, forFunctionCompression, forDataCompression,

0 commit comments

Comments
 (0)