1 //===- ReplayInlineAdvisor.h - Replay Inline Advisor interface -*- 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 LLVM_ANALYSIS_REPLAYINLINEADVISOR_H 10 #define LLVM_ANALYSIS_REPLAYINLINEADVISOR_H 11 12 #include "llvm/ADT/StringSet.h" 13 #include "llvm/Analysis/InlineAdvisor.h" 14 #include "llvm/IR/LLVMContext.h" 15 16 namespace llvm { 17 class BasicBlock; 18 class CallBase; 19 class Function; 20 class Module; 21 class OptimizationRemarkEmitter; 22 23 /// Replay inline advisor that uses optimization remarks from inlining of 24 /// previous build to guide current inlining. This is useful for inliner tuning. 25 class ReplayInlineAdvisor : public InlineAdvisor { 26 public: 27 ReplayInlineAdvisor(Module &M, FunctionAnalysisManager &FAM, 28 LLVMContext &Context, 29 std::unique_ptr<InlineAdvisor> OriginalAdvisor, 30 StringRef RemarksFile, bool EmitRemarks); 31 std::unique_ptr<InlineAdvice> getAdviceImpl(CallBase &CB) override; areReplayRemarksLoaded()32 bool areReplayRemarksLoaded() const { return HasReplayRemarks; } 33 34 private: 35 StringSet<> InlineSitesFromRemarks; 36 std::unique_ptr<InlineAdvisor> OriginalAdvisor; 37 bool HasReplayRemarks = false; 38 bool EmitRemarks = false; 39 }; 40 } // namespace llvm 41 #endif // LLVM_ANALYSIS_REPLAYINLINEADVISOR_H 42