1 //===- BasicBlockSectionUtils.h - Utilities for basic block sections --===// 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 #ifndef LLVM_CODEGEN_BASICBLOCKSECTIONUTILS_H 10 #define LLVM_CODEGEN_BASICBLOCKSECTIONUTILS_H 11 12 #include "llvm/ADT/STLExtras.h" 13 #include "llvm/Support/CommandLine.h" 14 15 namespace llvm { 16 17 extern cl::opt<std::string> BBSectionsColdTextPrefix; 18 19 class MachineFunction; 20 class MachineBasicBlock; 21 22 using MachineBasicBlockComparator = 23 function_ref<bool(const MachineBasicBlock &, const MachineBasicBlock &)>; 24 25 void sortBasicBlocksAndUpdateBranches(MachineFunction &MF, 26 MachineBasicBlockComparator MBBCmp); 27 28 void avoidZeroOffsetLandingPad(MachineFunction &MF); 29 30 /// This checks if the source of this function has drifted since this binary was 31 /// profiled previously. 32 /// For now, we are piggy backing on what PGO does to 33 /// detect this with instrumented profiles. PGO emits an hash of the IR and 34 /// checks if the hash has changed. Advanced basic block layout is usually done 35 /// on top of PGO optimized binaries and hence this check works well in 36 /// practice. 37 bool hasInstrProfHashMismatch(MachineFunction &MF); 38 39 } // end namespace llvm 40 41 #endif // LLVM_CODEGEN_BASICBLOCKSECTIONUTILS_H 42