//===- bolt/Core/FunctionLayout.h - Fragmented Function Layout --*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file contains the declaration of the FunctionLayout class. The layout of // a function is the order of basic blocks, in which we will arrange them in the // new binary. Normally, when not optimizing for code layout, the blocks of a // function are contiguous. However, we can split the layout into multiple // fragments. The blocks within a fragment are contiguous, but the fragments // itself are disjoint. Fragments could be used to enhance code layout, e.g. to // separate the blocks into hot and cold sections. // //===----------------------------------------------------------------------===// #ifndef BOLT_CORE_FUNCTION_LAYOUT_H #define BOLT_CORE_FUNCTION_LAYOUT_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" #include <iterator> namespace llvm { namespace bolt { class BinaryFunction; class BinaryBasicBlock; class FunctionLayout; class FragmentNum { … }; /// A freestanding subset of contiguous blocks of a function. class FunctionFragment { … }; /// The function layout represents the fragments we split a function into and /// the order of basic blocks within each fragment. /// /// Internally, the function layout stores blocks across fragments contiguously. /// This is necessary to retain compatibility with existing code and tests that /// iterate over all blocks of the layout and depend on that order. When /// writing new code, avoid iterating using FunctionLayout::blocks() by /// iterating either over fragments or over BinaryFunction::begin()..end(). class FunctionLayout { … }; } // namespace bolt } // namespace llvm #endif