@@ -26,20 +26,16 @@ struct BPOrdererMachO;
2626}
2727template <> struct lld ::BPOrdererTraits<struct BPOrdererMachO > {
2828 using Section = macho::InputSection;
29- using Symbol = macho::Symbol ;
29+ using Defined = macho::Defined ;
3030};
3131namespace {
3232struct BPOrdererMachO : lld::BPOrderer<BPOrdererMachO> {
3333 static uint64_t getSize (const Section &sec) { return sec.getSize (); }
3434 static bool isCodeSection (const Section &sec) {
3535 return macho::isCodeSection (&sec);
3636 }
37- static SmallVector<Symbol *, 0 > getSymbols (const Section &sec) {
38- SmallVector<Symbol *, 0 > symbols;
39- for (auto *sym : sec.symbols )
40- if (auto *d = llvm::dyn_cast_or_null<Defined>(sym))
41- symbols.emplace_back (d);
42- return symbols;
37+ static ArrayRef<Defined *> getSymbols (const Section &sec) {
38+ return sec.symbols ;
4339 }
4440
4541 // Linkage names can be prefixed with "_" or "l_" on Mach-O. See
@@ -80,17 +76,11 @@ struct BPOrdererMachO : lld::BPOrderer<BPOrdererMachO> {
8076 hashes.erase (std::unique (hashes.begin (), hashes.end ()), hashes.end ());
8177 }
8278
83- static llvm::StringRef getSymName (const Symbol &sym) { return sym.getName (); }
84- static uint64_t getSymValue (const Symbol &sym) {
85- if (auto *d = dyn_cast<Defined>(&sym))
86- return d->value ;
87- return 0 ;
88- }
89- static uint64_t getSymSize (const Symbol &sym) {
90- if (auto *d = dyn_cast<Defined>(&sym))
91- return d->size ;
92- return 0 ;
79+ static llvm::StringRef getSymName (const Defined &sym) {
80+ return sym.getName ();
9381 }
82+ static uint64_t getSymValue (const Defined &sym) { return sym.value ; }
83+ static uint64_t getSymSize (const Defined &sym) { return sym.size ; }
9484
9585private:
9686 static uint64_t
@@ -141,8 +131,8 @@ DenseMap<const InputSection *, int> lld::macho::runBalancedPartitioning(
141131 }
142132 }
143133
144- return BPOrdererMachO:: computeOrder (profilePath, forFunctionCompression,
145- forDataCompression,
146- compressionSortStartupFunctions, verbose,
147- sections, rootSymbolToSectionIdxs);
134+ return BPOrdererMachO (). computeOrder (profilePath, forFunctionCompression,
135+ forDataCompression,
136+ compressionSortStartupFunctions, verbose,
137+ sections, rootSymbolToSectionIdxs);
148138}
0 commit comments