1 //===- bolt/Passes/AllocCombiner.h ------------------------------*- C++ -*-===// 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 BOLT_PASSES_FRAMEDEFRAG_H 10 #define BOLT_PASSES_FRAMEDEFRAG_H 11 12 #include "bolt/Passes/BinaryPasses.h" 13 14 namespace llvm { 15 namespace bolt { 16 17 class AllocCombinerPass : public BinaryFunctionPass { 18 /// Stats aggregating variables 19 uint64_t NumCombined{0}; 20 uint64_t DynamicCountCombined{0}; 21 DenseSet<const BinaryFunction *> FuncsChanged; 22 23 void combineAdjustments(BinaryFunction &BF); 24 25 public: AllocCombinerPass(const cl::opt<bool> & PrintPass)26 explicit AllocCombinerPass(const cl::opt<bool> &PrintPass) 27 : BinaryFunctionPass(PrintPass) {} 28 getName()29 const char *getName() const override { return "alloc-combiner"; } 30 shouldPrint(const BinaryFunction & BF)31 bool shouldPrint(const BinaryFunction &BF) const override { 32 return BinaryFunctionPass::shouldPrint(BF) && FuncsChanged.count(&BF) > 0; 33 } 34 35 /// Pass entry point 36 Error runOnFunctions(BinaryContext &BC) override; 37 }; 38 39 } // namespace bolt 40 } // namespace llvm 41 42 #endif 43