1//===- BPSectionOrderer.h -------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// This file uses Balanced Partitioning to order sections to improve startup
10/// time and compressed size.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLD_ELF_BPSECTION_ORDERER_H
15#define LLD_ELF_BPSECTION_ORDERER_H
16
17#include "lld/Common/BPSectionOrdererBase.h"
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/DenseMap.h"
20#include "llvm/ADT/StringRef.h"
21
22namespace lld::elf {
23struct Ctx;
24class InputSectionBase;
25
26/// Run Balanced Partitioning to find the optimal function and data order to
27/// improve startup time and compressed size.
28///
29/// It is important that -ffunction-sections and -fdata-sections compiler flags
30/// are used to ensure functions and data are in their own sections and thus
31/// can be reordered.
32llvm::DenseMap<const InputSectionBase *, int> runBalancedPartitioning(
33 Ctx &ctx, llvm::StringRef profilePath,
34 llvm::ArrayRef<BPCompressionSortSpec> compressionSortSpecs,
35 bool forFunctionCompression, bool forDataCompression,
36 bool compressionSortStartupFunctions, bool verbose);
37
38} // namespace lld::elf
39
40#endif
41