[llvm][NFC] Factor some common data in InlineAdvice

Summary:
Other derivations will all want to emit optimization remarks and, as
part of that, use debug info.

Additionally, drive-by const-ing.

Reviewers: davidxl, dblaikie

Subscribers: aprantl, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81507
diff --git a/llvm/lib/Analysis/InlineAdvisor.cpp b/llvm/lib/Analysis/InlineAdvisor.cpp
index 4d8a241..d5b71f6 100644
--- a/llvm/lib/Analysis/InlineAdvisor.cpp
+++ b/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) {