xref: /freebsd-src/contrib/llvm-project/llvm/include/llvm/CodeGen/BasicBlockSectionUtils.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
1e8d8bef9SDimitry Andric //===- BasicBlockSectionUtils.h - Utilities for basic block sections     --===//
2e8d8bef9SDimitry Andric //
3e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e8d8bef9SDimitry Andric //
7e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
8e8d8bef9SDimitry Andric 
9e8d8bef9SDimitry Andric #ifndef LLVM_CODEGEN_BASICBLOCKSECTIONUTILS_H
10e8d8bef9SDimitry Andric #define LLVM_CODEGEN_BASICBLOCKSECTIONUTILS_H
11e8d8bef9SDimitry Andric 
12e8d8bef9SDimitry Andric #include "llvm/ADT/STLExtras.h"
13e8d8bef9SDimitry Andric #include "llvm/Support/CommandLine.h"
14e8d8bef9SDimitry Andric 
15e8d8bef9SDimitry Andric namespace llvm {
16e8d8bef9SDimitry Andric 
17e8d8bef9SDimitry Andric extern cl::opt<std::string> BBSectionsColdTextPrefix;
18e8d8bef9SDimitry Andric 
19e8d8bef9SDimitry Andric class MachineFunction;
20e8d8bef9SDimitry Andric class MachineBasicBlock;
21e8d8bef9SDimitry Andric 
22e8d8bef9SDimitry Andric using MachineBasicBlockComparator =
23e8d8bef9SDimitry Andric     function_ref<bool(const MachineBasicBlock &, const MachineBasicBlock &)>;
24e8d8bef9SDimitry Andric 
25e8d8bef9SDimitry Andric void sortBasicBlocksAndUpdateBranches(MachineFunction &MF,
26e8d8bef9SDimitry Andric                                       MachineBasicBlockComparator MBBCmp);
27e8d8bef9SDimitry Andric 
28fcaf7f86SDimitry Andric void avoidZeroOffsetLandingPad(MachineFunction &MF);
29fcaf7f86SDimitry Andric 
30*5f757f3fSDimitry Andric /// This checks if the source of this function has drifted since this binary was
31*5f757f3fSDimitry Andric /// profiled previously.
32*5f757f3fSDimitry Andric /// For now, we are piggy backing on what PGO does to
33*5f757f3fSDimitry Andric /// detect this with instrumented profiles.  PGO emits an hash of the IR and
34*5f757f3fSDimitry Andric /// checks if the hash has changed.  Advanced basic block layout is usually done
35*5f757f3fSDimitry Andric /// on top of PGO optimized binaries and hence this check works well in
36*5f757f3fSDimitry Andric /// practice.
37*5f757f3fSDimitry Andric bool hasInstrProfHashMismatch(MachineFunction &MF);
38*5f757f3fSDimitry Andric 
39e8d8bef9SDimitry Andric } // end namespace llvm
40e8d8bef9SDimitry Andric 
41e8d8bef9SDimitry Andric #endif // LLVM_CODEGEN_BASICBLOCKSECTIONUTILS_H
42