Add --bp-compression-sort-section=<glob>[=<layout_priority>[=<match_priority>]] to let users split input sections into multiple compression groups, run balanced partitioning independently per group, and leave out sections that are poor candidates for BP. This replaces the old coarse --bp-compression-sort with a more explicit, user-controlled one. In ELF, the glob matches input section names (.text.unlikely.cold1). In Mach-O, it matches the concatenated segment+section name (__TEXT__text). layout_priority controls group placement in the final layout. match_priority resolves conflicts when multiple globs match the same section: explicit priority beats positional matching, and among positional specs the last match wins. A CRTP hook getCompressionSubgroupKey() allows backends to further subdivide glob groups into independent BP instances. This allows Mach-O backend to separate cold functions via N_COLD_FUNC in the future. The deprecated --bp-compression-sort option keeps its existing function/data behavior by assigning sections to fixed legacy groups.
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
//===- BPSectionOrderer.h -------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// This file uses Balanced Partitioning to order sections to improve startup
|
|
/// time and compressed size.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLD_MACHO_BPSECTION_ORDERER_H
|
|
#define LLD_MACHO_BPSECTION_ORDERER_H
|
|
|
|
#include "lld/Common/BPSectionOrdererBase.h"
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
#include "llvm/ADT/DenseMap.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
namespace lld::macho {
|
|
class InputSection;
|
|
|
|
/// Run Balanced Partitioning to find the optimal function and data order to
|
|
/// improve startup time and compressed size.
|
|
///
|
|
/// It is important that .subsections_via_symbols is used to ensure functions
|
|
/// and data are in their own sections and thus can be reordered.
|
|
llvm::DenseMap<const InputSection *, int> runBalancedPartitioning(
|
|
llvm::StringRef profilePath,
|
|
llvm::ArrayRef<BPCompressionSortSpec> compressionSortSpecs,
|
|
bool forFunctionCompression, bool forDataCompression,
|
|
bool compressionSortStartupFunctions, bool verbose);
|
|
|
|
} // namespace lld::macho
|
|
|
|
#endif
|