[PATCH] D122752: [lld-macho][NFC] Encapsulate symbol priority implementation.
Roger Kim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 30 11:08:36 PDT 2022
Roger created this revision.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
Roger requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Just some code clean up.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122752
Files:
lld/MachO/Config.h
lld/MachO/SectionPriorities.cpp
lld/MachO/SectionPriorities.h
Index: lld/MachO/SectionPriorities.h
===================================================================
--- lld/MachO/SectionPriorities.h
+++ lld/MachO/SectionPriorities.h
@@ -56,6 +56,20 @@
llvm::DenseMap<const InputSection *, size_t> 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<llvm::StringRef, size_t> objectFiles;
+ };
+
llvm::Optional<size_t> getSymbolPriority(const Defined *sym);
llvm::DenseMap<llvm::StringRef, SymbolPriorityEntry> priorities;
llvm::MapVector<SectionPair, uint64_t> callGraphProfile;
Index: lld/MachO/SectionPriorities.cpp
===================================================================
--- lld/MachO/SectionPriorities.cpp
+++ lld/MachO/SectionPriorities.cpp
@@ -283,11 +283,10 @@
entry.toIndex < obj->symbols.size());
auto *fromSym = dyn_cast_or_null<Defined>(obj->symbols[entry.fromIndex]);
auto *toSym = dyn_cast_or_null<Defined>(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;
}
}
}
Index: lld/MachO/Config.h
===================================================================
--- lld/MachO/Config.h
+++ lld/MachO/Config.h
@@ -30,7 +30,6 @@
class InputSection;
class Symbol;
-struct SymbolPriorityEntry;
using NamePair = std::pair<llvm::StringRef, llvm::StringRef>;
using SectionRenameMap = llvm::DenseMap<NamePair, NamePair>;
@@ -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<llvm::StringRef, size_t> objectFiles;
-};
-
// Whether to force-load an archive.
enum class ForceLoad {
Default, // Apply -all_load or -ObjC behaviors if those flags are enabled
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122752.419221.patch
Type: text/x-patch
Size: 3285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220330/35d5ab46/attachment.bin>
More information about the llvm-commits
mailing list