[lld] [lld][macho] Support order cstrings with -order_file_cstring (PR #140307)
Snehasish Kumar via llvm-commits
llvm-commits at lists.llvm.org
Fri May 30 14:04:17 PDT 2025
================
@@ -388,3 +401,41 @@ macho::PriorityBuilder::buildInputSectionPriorities() {
return sectionPriorities;
}
+
+std::vector<StringPiecePair> macho::PriorityBuilder::buildCStringPriorities(
+ ArrayRef<CStringInputSection *> inputs) {
+ // Split the input strings into hold and cold sets.
+ // Order hot set based on -order_file_cstring for performance improvement;
+ // TODO: Order cold set of cstrings for compression via BP.
+ std::vector<std::pair<int, StringPiecePair>>
+ hotStringPrioritiesAndStringPieces;
+ std::vector<StringPiecePair> coldStringPieces;
+ std::vector<StringPiecePair> orderedStringPieces;
+
+ for (CStringInputSection *isec : inputs) {
+ for (const auto &[stringPieceIdx, piece] : llvm::enumerate(isec->pieces)) {
+ if (!piece.live)
+ continue;
+
+ std::optional<int> priority = getSymbolOrCStringPriority(
+ std::to_string(piece.hash), isec->getFile());
----------------
snehasish wrote:
/bikeshedding
I believe the only character disallowed in the symbolname would be the null character (at least for ELF). More practical constraints on symbol names arise from the programming language used to generate the executable. So in this case I believe most c-like languages that we care about disallow `:` and `;` in identifier names so they are equal in this regard. Given the existing usage of ':' I'd prefer we continue using the same prefix delimiter.
https://github.com/llvm/llvm-project/pull/140307
More information about the llvm-commits
mailing list