Use a stricter return type in buildSectionOrder. NFC.

We sort inside output sections, so all the sections we see should be
InputSectionBase.

I noticed the patch adding callgraph based section ordering used this
type and changing this separately makes the merge easier.

llvm-svn: 325094
This commit is contained in:
Rafael Espindola 2018-02-14 01:42:26 +00:00
parent 0bae6d8c14
commit 1d76120d9a
1 changed files with 10 additions and 9 deletions

View File

@ -1017,8 +1017,8 @@ findOrphanPos(std::vector<BaseCommand *>::iterator B,
}
// Builds section order for handling --symbol-ordering-file.
static DenseMap<SectionBase *, int> buildSectionOrder() {
DenseMap<SectionBase *, int> SectionOrder;
static DenseMap<const InputSectionBase *, int> buildSectionOrder() {
DenseMap<const InputSectionBase *, int> SectionOrder;
if (Config->SymbolOrderingFile.empty())
return SectionOrder;
@ -1033,18 +1033,19 @@ static DenseMap<SectionBase *, int> buildSectionOrder() {
// Build a map from sections to their priorities.
for (InputFile *File : ObjectFiles) {
for (Symbol *Sym : File->getSymbols()) {
auto *D = dyn_cast<Defined>(Sym);
if (!D || !D->Section)
continue;
int &Priority = SectionOrder[D->Section];
Priority = std::min(Priority, SymbolOrder.lookup(D->getName()));
if (auto *D = dyn_cast<Defined>(Sym)) {
if (auto *Sec = dyn_cast_or_null<InputSectionBase>(D->Section)) {
int &Priority = SectionOrder[Sec];
Priority = std::min(Priority, SymbolOrder.lookup(D->getName()));
}
}
}
}
return SectionOrder;
}
static void sortSection(OutputSection *Sec,
const DenseMap<SectionBase *, int> &Order) {
const DenseMap<const InputSectionBase *, int> &Order) {
if (!Sec->Live)
return;
StringRef Name = Sec->Name;
@ -1078,7 +1079,7 @@ static void sortSection(OutputSection *Sec,
// sorting for special input sections. This also handles --symbol-ordering-file.
template <class ELFT> void Writer<ELFT>::sortInputSections() {
// Build the order once since it is expensive.
DenseMap<SectionBase *, int> Order = buildSectionOrder();
DenseMap<const InputSectionBase *, int> Order = buildSectionOrder();
for (BaseCommand *Base : Script->SectionCommands)
if (auto *Sec = dyn_cast<OutputSection>(Base))
sortSection(Sec, Order);