[PATCH] D81507: [llvm][NFC] Factor some common data in InlineAdvice
Mircea Trofin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 9 14:54:51 PDT 2020
mtrofin created this revision.
mtrofin added reviewers: davidxl, dblaikie.
Herald added subscribers: llvm-commits, hiraditya, aprantl.
Herald added a project: LLVM.
Other derivations will all want to emit optimization remarks and, as
part of that, use debug info.
Additionally, drive-by const-ing.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81507
Files:
llvm/include/llvm/Analysis/InlineAdvisor.h
llvm/lib/Analysis/InlineAdvisor.cpp
Index: llvm/lib/Analysis/InlineAdvisor.cpp
===================================================================
--- llvm/lib/Analysis/InlineAdvisor.cpp
+++ llvm/lib/Analysis/InlineAdvisor.cpp
@@ -52,8 +52,8 @@
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 {
@@ -79,13 +79,6 @@
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
@@ -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) {
Index: llvm/include/llvm/Analysis/InlineAdvisor.h
===================================================================
--- llvm/include/llvm/Analysis/InlineAdvisor.h
+++ 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<Function *> DeletedFunctions;
+ std::unordered_set<const Function *> DeletedFunctions;
};
/// The default (manual heuristics) implementation of the InlineAdvisor. This
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81507.269680.patch
Type: text/x-patch
Size: 3641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200609/e3884d17/attachment-0001.bin>
More information about the llvm-commits
mailing list