[PATCH] D124899: [BOLT][NFC] Move getInliningInfo out of Inliner class

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 3 19:14:17 PDT 2022


Amir created this revision.
Herald added a reviewer: rafauler.
Herald added a subscriber: ayermolo.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

`getInliningInfo` is useful in other passes that need to check inlining
eligibility for some function. Move the declaration and InliningInfo definition
out of Inliner class. Prepare for subsequent use in ICP.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124899

Files:
  bolt/include/bolt/Passes/Inliner.h
  bolt/lib/Passes/Inliner.cpp


Index: bolt/lib/Passes/Inliner.cpp
===================================================================
--- bolt/lib/Passes/Inliner.cpp
+++ bolt/lib/Passes/Inliner.cpp
@@ -167,10 +167,7 @@
   return SizeOfTailCallInst;
 }
 
-Inliner::InliningInfo Inliner::getInliningInfo(const BinaryFunction &BF) const {
-  if (!shouldOptimize(BF))
-    return INL_NONE;
-
+InliningInfo getInliningInfo(const BinaryFunction &BF) {
   const BinaryContext &BC = BF.getBinaryContext();
   bool DirectSP = false;
   bool HasCFI = false;
@@ -250,6 +247,8 @@
 void Inliner::findInliningCandidates(BinaryContext &BC) {
   for (const auto &BFI : BC.getBinaryFunctions()) {
     const BinaryFunction &Function = BFI.second;
+    if (!shouldOptimize(Function))
+      continue;
     const InliningInfo InlInfo = getInliningInfo(Function);
     if (InlInfo.Type != INL_NONE)
       InliningCandidates[&Function] = InlInfo;
Index: bolt/include/bolt/Passes/Inliner.h
===================================================================
--- bolt/include/bolt/Passes/Inliner.h
+++ bolt/include/bolt/Passes/Inliner.h
@@ -18,22 +18,24 @@
 namespace llvm {
 namespace bolt {
 
-class Inliner : public BinaryFunctionPass {
-private:
-  enum InliningType : char {
-    INL_NONE = 0, /// Cannot inline
-    INL_TAILCALL, /// Can inline at tail call site
-    INL_ANY       /// Can inline at any call site
-  };
+enum InliningType : char {
+  INL_NONE = 0, /// Cannot inline
+  INL_TAILCALL, /// Can inline at tail call site
+  INL_ANY       /// Can inline at any call site
+};
+
+struct InliningInfo {
+  InliningType Type{INL_NONE};
+  uint64_t SizeAfterInlining{0};
+  uint64_t SizeAfterTailCallInlining{0};
 
-  struct InliningInfo {
-    InliningType Type{INL_NONE};
-    uint64_t SizeAfterInlining{0};
-    uint64_t SizeAfterTailCallInlining{0};
+  InliningInfo(InliningType Type = INL_NONE) : Type(Type) {}
+};
 
-    InliningInfo(InliningType Type = INL_NONE) : Type(Type) {}
-  };
+/// Check if the inliner can handle inlining of \p BF.
+InliningInfo getInliningInfo(const BinaryFunction &BF);
 
+class Inliner : public BinaryFunctionPass {
   std::unordered_map<const BinaryFunction *, InliningInfo> InliningCandidates;
 
   /// Count total amount of bytes inlined for all instances of Inliner.
@@ -74,9 +76,6 @@
   inlineCall(BinaryBasicBlock &CallerBB, BinaryBasicBlock::iterator CallInst,
              const BinaryFunction &Callee);
 
-  /// Check if the inliner can handle inlining of \p BF.
-  InliningInfo getInliningInfo(const BinaryFunction &BF) const;
-
 public:
   explicit Inliner(const cl::opt<bool> &PrintPass)
       : BinaryFunctionPass(PrintPass) {}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124899.426896.patch
Type: text/x-patch
Size: 2638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220504/d7cc1b1b/attachment.bin>


More information about the llvm-commits mailing list