diff --git a/llvm/include/llvm/Analysis/InlineAdvisor.h b/llvm/include/llvm/Analysis/InlineAdvisor.h --- a/llvm/include/llvm/Analysis/InlineAdvisor.h +++ b/llvm/include/llvm/Analysis/InlineAdvisor.h @@ -48,6 +48,9 @@ /// obligations. class InlineAdvice { public: + InlineAdvice(InlineAdvisor *Advisor, CallBase &CB, + OptimizationRemarkEmitter &ORE, bool IsInliningRecommended); + InlineAdvice(InlineAdvice &&) = delete; InlineAdvice(const InlineAdvice &) = delete; virtual ~InlineAdvice() { @@ -81,11 +84,10 @@ /// Get the inlining recommendation. bool isInliningRecommended() const { return IsInliningRecommended; } + const DebugLoc &getOriginalCallSiteDebugLoc() const { return DLoc; } + const BasicBlock *getOriginalCallSiteBasicBlock() const { return Block; } protected: - InlineAdvice(InlineAdvisor *Advisor, CallBase &CB, - bool IsInliningRecommended); - virtual void recordInliningImpl() {} virtual void recordInliningWithCalleeDeletedImpl() {} virtual void recordUnsuccessfulInliningImpl(const InlineResult &Result) {} @@ -95,6 +97,13 @@ /// Caller and Callee are pre-inlining. Function *const Caller; Function *const Callee; + + // Capture the context of CB before inlining, as a successful inlining may + // change that context, and we want to report success or failure in the + // original context. + const DebugLoc DLoc; + const BasicBlock *const Block; + OptimizationRemarkEmitter &ORE; const bool IsInliningRecommended; private: @@ -142,14 +151,14 @@ /// after each SCC inlining (e.g. argument promotion does that). void freeDeletedFunctions(); - bool isFunctionDeleted(Function *F) const { + bool isFunctionDeleted(const Function *F) const { return DeletedFunctions.count(F); } private: friend class InlineAdvice; void markFunctionAsDeleted(Function *F); - std::unordered_set DeletedFunctions; + std::unordered_set DeletedFunctions; }; /// The default (manual heuristics) implementation of the InlineAdvisor. This diff --git a/llvm/lib/Analysis/InlineAdvisor.cpp b/llvm/lib/Analysis/InlineAdvisor.cpp --- a/llvm/lib/Analysis/InlineAdvisor.cpp +++ b/llvm/lib/Analysis/InlineAdvisor.cpp @@ -52,8 +52,8 @@ public: DefaultInlineAdvice(DefaultInlineAdvisor *Advisor, CallBase &CB, Optional OIC, OptimizationRemarkEmitter &ORE) - : InlineAdvice(Advisor, CB, OIC.hasValue()), OriginalCB(&CB), OIC(OIC), - ORE(ORE), DLoc(CB.getDebugLoc()), Block(CB.getParent()) {} + : InlineAdvice(Advisor, CB, ORE, OIC.hasValue()), OriginalCB(&CB), + OIC(OIC) {} private: void recordUnsuccessfulInliningImpl(const InlineResult &Result) override { @@ -79,13 +79,6 @@ private: CallBase *const OriginalCB; Optional OIC; - OptimizationRemarkEmitter &ORE; - - // Capture the context of CB before inlining, as a successful inlining may - // change that context, and we want to report success or failure in the - // original context. - const DebugLoc DLoc; - const BasicBlock *const Block; }; } // namespace @@ -124,8 +117,10 @@ } InlineAdvice::InlineAdvice(InlineAdvisor *Advisor, CallBase &CB, + OptimizationRemarkEmitter &ORE, bool IsInliningRecommended) : Advisor(Advisor), Caller(CB.getCaller()), Callee(CB.getCalledFunction()), + DLoc(CB.getDebugLoc()), Block(CB.getParent()), ORE(ORE), IsInliningRecommended(IsInliningRecommended) {} void InlineAdvisor::markFunctionAsDeleted(Function *F) {