xref: /freebsd/contrib/llvm-project/lld/ELF/BPSectionOrderer.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
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 "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/StringRef.h"
19 
20 namespace lld::elf {
21 struct Ctx;
22 class InputSectionBase;
23 
24 /// Run Balanced Partitioning to find the optimal function and data order to
25 /// improve startup time and compressed size.
26 ///
27 /// It is important that -ffunction-sections and -fdata-sections compiler flags
28 /// are used to ensure functions and data are in their own sections and thus
29 /// can be reordered.
30 llvm::DenseMap<const InputSectionBase *, int>
31 runBalancedPartitioning(Ctx &ctx, llvm::StringRef profilePath,
32                         bool forFunctionCompression, bool forDataCompression,
33                         bool compressionSortStartupFunctions, bool verbose);
34 
35 } // namespace lld::elf
36 
37 #endif
38