/// obligations.
class InlineAdvice {
public:
+ InlineAdvice(InlineAdvisor *Advisor, CallBase &CB,
+ OptimizationRemarkEmitter &ORE, bool IsInliningRecommended);
+
InlineAdvice(InlineAdvice &&) = delete;
InlineAdvice(const InlineAdvice &) = delete;
virtual ~InlineAdvice() {
/// 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) {}
/// 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:
/// 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<Function *> DeletedFunctions;
+ std::unordered_set<const Function *> DeletedFunctions;
};
/// The default (manual heuristics) implementation of the InlineAdvisor. This
public:
DefaultInlineAdvice(DefaultInlineAdvisor *Advisor, CallBase &CB,
Optional<InlineCost> 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 {
private:
CallBase *const OriginalCB;
Optional<InlineCost> 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
}
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) {