diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h --- a/lld/MachO/Config.h +++ b/lld/MachO/Config.h @@ -30,7 +30,6 @@ class InputSection; class Symbol; -struct SymbolPriorityEntry; using NamePair = std::pair; using SectionRenameMap = llvm::DenseMap; @@ -191,20 +190,6 @@ } }; -// The symbol with the highest priority should be ordered first in the output -// section (modulo input section contiguity constraints). Using priority -// (highest first) instead of order (lowest first) has the convenient property -// that the default-constructed zero priority -- for symbols/sections without a -// user-defined order -- naturally ends up putting them at the end of the -// output. -struct SymbolPriorityEntry { - // The priority given to a matching symbol, regardless of which object file - // it originated from. - size_t anyObjectFile = 0; - // The priority given to a matching symbol from a particular object file. - llvm::DenseMap objectFiles; -}; - // Whether to force-load an archive. enum class ForceLoad { Default, // Apply -all_load or -ObjC behaviors if those flags are enabled diff --git a/lld/MachO/SectionPriorities.h b/lld/MachO/SectionPriorities.h --- a/lld/MachO/SectionPriorities.h +++ b/lld/MachO/SectionPriorities.h @@ -56,6 +56,20 @@ llvm::DenseMap buildInputSectionPriorities(); private: + // The symbol with the highest priority should be ordered first in the output + // section (modulo input section contiguity constraints). Using priority + // (highest first) instead of order (lowest first) has the convenient property + // that the default-constructed zero priority -- for symbols/sections without + // a user-defined order -- naturally ends up putting them at the end of the + // output. + struct SymbolPriorityEntry { + // The priority given to a matching symbol, regardless of which object file + // it originated from. + size_t anyObjectFile = 0; + // The priority given to a matching symbol from a particular object file. + llvm::DenseMap objectFiles; + }; + llvm::Optional getSymbolPriority(const Defined *sym); llvm::DenseMap priorities; llvm::MapVector callGraphProfile; diff --git a/lld/MachO/SectionPriorities.cpp b/lld/MachO/SectionPriorities.cpp --- a/lld/MachO/SectionPriorities.cpp +++ b/lld/MachO/SectionPriorities.cpp @@ -283,11 +283,10 @@ entry.toIndex < obj->symbols.size()); auto *fromSym = dyn_cast_or_null(obj->symbols[entry.fromIndex]); auto *toSym = dyn_cast_or_null(obj->symbols[entry.toIndex]); - if (!fromSym || !toSym || - (hasOrderFile && - (getSymbolPriority(fromSym) || getSymbolPriority(toSym)))) - continue; - callGraphProfile[{fromSym->isec, toSym->isec}] += entry.count; + if (fromSym && toSym && + (!hasOrderFile || + (!getSymbolPriority(fromSym) && !getSymbolPriority(toSym)))) + callGraphProfile[{fromSym->isec, toSym->isec}] += entry.count; } } }