[lld] [lld][macho] Support order cstrings with -order_file_cstring (PR #140307)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Fri May 30 13:52:37 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());
----------------
ellishg wrote:
Ideally we would use `;` in place of `:`, but this is a breaking change. Maybe in the future we can support both and then eventually drop support for `:`, but that would definitely require an RFC since it would break existing orderfiles.
For now, I think we can use the `CSTR;` format.
https://github.com/llvm/llvm-project/pull/140307
More information about the llvm-commits
mailing list