//===- bolt/Passes/HFSort.h - Cluster functions by hotness ------*- 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 // //===----------------------------------------------------------------------===// // // Implementation of HFSort algorithm for function ordering: // https://research.fb.com/wp-content/uploads/2017/01/cgo2017-hfsort-final1.pdf // // Cluster functions by hotness. There are three clustering algorithms: // 1. clusterize // 2. pettisAndHansen // 3. randomClusters // //===----------------------------------------------------------------------===// #ifndef BOLT_PASSES_HFSORT_H #define BOLT_PASSES_HFSORT_H #include "bolt/Core/CallGraph.h" #include <string> #include <vector> namespace llvm { namespace bolt { class Cluster { … }; // Maximum size of a cluster, in bytes. constexpr uint32_t MaxClusterSize = …; // Size of a huge page in bytes. constexpr uint32_t HugePageSize = …; inline bool compareClustersDensity(const Cluster &C1, const Cluster &C2) { … } /* * Cluster functions in order to minimize call distance. */ std::vector<Cluster> clusterize(const CallGraph &Cg); /* * Pettis-Hansen code layout algorithm * reference: K. Pettis and R. C. Hansen, "Profile Guided Code Positioning", * PLDI '90 */ std::vector<Cluster> pettisAndHansen(const CallGraph &Cg); /* Group functions into clusters randomly. */ std::vector<Cluster> randomClusters(const CallGraph &Cg); } // end namespace bolt } // end namespace llvm #endif // BOLT_PASSES_HFSORT_H