@@ -38,20 +38,21 @@ lld::elf::runBalancedPartitioning(Ctx &ctx, llvm::StringRef profilePath,
38
38
SmallVector<std::unique_ptr<BPSectionBase>> sections;
39
39
DenseSet<const InputSectionBase *> seenSections;
40
40
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
+
41
50
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);
47
52
48
53
for (ELFFileBase *file : ctx.objectFiles )
49
54
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);
55
56
56
57
auto reorderedSections = BPSectionBase::reorderSectionsByBalancedPartitioning (
57
58
profilePath, forFunctionCompression, forDataCompression,
0 commit comments