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