[PATCH] D103315: Add interface to order inlining

Liqiang Tao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 30 06:34:34 PDT 2021


taolq updated this revision to Diff 348694.
taolq added a comment.

Updating D103315 <https://reviews.llvm.org/D103315>: Add interface to order inlining

1.
2. Enter a brief description of the changes included in this update.
3. The first line is used as subject, next lines as comment.
4.
5. If you intended to create a new revision, use:
6. $ arc diff --create


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103315/new/

https://reviews.llvm.org/D103315

Files:
  llvm/lib/Transforms/IPO/Inliner.cpp


Index: llvm/lib/Transforms/IPO/Inliner.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Inliner.cpp
+++ llvm/lib/Transforms/IPO/Inliner.cpp
@@ -670,6 +670,42 @@
   return *IAA->getAdvisor();
 }
 
+class InlineOrder {
+public:
+  using T = std::pair<CallBase *, int>;
+  using iterator = T *;
+  using const_iterator = const T *;
+  using reference = T &;
+
+  virtual ~InlineOrder() {}
+
+  virtual size_t size() = 0;
+  virtual reference operator[](size_t idx) = 0;
+  virtual void push_back(const T &Elt) = 0;
+  virtual T pop() = 0;
+  virtual iterator erase(const_iterator B, const_iterator E) = 0;
+  virtual iterator begin() = 0;
+  virtual iterator end() = 0;
+
+  bool empty() { return !size(); }
+};
+
+class DefaultInlineOrder : public InlineOrder {
+public:
+  size_t size() override { return Calls.size(); }
+  reference operator[](size_t idx) override { return Calls[idx]; }
+  void push_back(const T &Elt) override { Calls.push_back(Elt); }
+  T pop() override { return Calls.pop_back_val(); }
+  iterator erase(const_iterator CB, const_iterator CE) override {
+    return Calls.erase(CB, CE);
+  }
+  iterator begin() override { return Calls.begin(); }
+  iterator end() override { return Calls.end(); }
+
+private:
+  SmallVector<T, 16> Calls;
+};
+
 PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
                                    CGSCCAnalysisManager &AM, LazyCallGraph &CG,
                                    CGSCCUpdateResult &UR) {
@@ -714,7 +750,7 @@
   // this model, but it is uniformly spread across all the functions in the SCC
   // and eventually they all become too large to inline, rather than
   // incrementally maknig a single function grow in a super linear fashion.
-  SmallVector<std::pair<CallBase *, int>, 16> Calls;
+  DefaultInlineOrder Calls;
 
   // Populate the initial list of calls in this SCC.
   for (auto &N : InitialC) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103315.348694.patch
Type: text/x-patch
Size: 1942 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210530/26f79893/attachment.bin>


More information about the llvm-commits mailing list