@@ -26,20 +26,16 @@ struct BPOrdererMachO;
26
26
}
27
27
template <> struct lld ::BPOrdererTraits<struct BPOrdererMachO > {
28
28
using Section = macho::InputSection;
29
- using Symbol = macho::Symbol ;
29
+ using Defined = macho::Defined ;
30
30
};
31
31
namespace {
32
32
struct BPOrdererMachO : lld::BPOrderer<BPOrdererMachO> {
33
33
static uint64_t getSize (const Section &sec) { return sec.getSize (); }
34
34
static bool isCodeSection (const Section &sec) {
35
35
return macho::isCodeSection (&sec);
36
36
}
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 ;
43
39
}
44
40
45
41
// Linkage names can be prefixed with "_" or "l_" on Mach-O. See
@@ -80,17 +76,11 @@ struct BPOrdererMachO : lld::BPOrderer<BPOrdererMachO> {
80
76
hashes.erase (std::unique (hashes.begin (), hashes.end ()), hashes.end ());
81
77
}
82
78
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 ();
93
81
}
82
+ static uint64_t getSymValue (const Defined &sym) { return sym.value ; }
83
+ static uint64_t getSymSize (const Defined &sym) { return sym.size ; }
94
84
95
85
private:
96
86
static uint64_t
@@ -141,8 +131,8 @@ DenseMap<const InputSection *, int> lld::macho::runBalancedPartitioning(
141
131
}
142
132
}
143
133
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);
148
138
}
0 commit comments