[PATCH] D103315: add InlineOrder to abstract Calls

Liqiang Tao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 28 06:29:16 PDT 2021


taolq created this revision.
Herald added subscribers: hiraditya, eraman.
taolq requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103315

Files:
  llvm/include/llvm/Analysis/InlineOrder.h
  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
@@ -31,6 +31,7 @@
 #include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/InlineAdvisor.h"
 #include "llvm/Analysis/InlineCost.h"
+#include "llvm/Analysis/InlineOrder.h"
 #include "llvm/Analysis/LazyCallGraph.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/Analysis/ProfileSummaryInfo.h"
@@ -714,7 +715,8 @@
   // 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;
+  // SmallVector<std::pair<CallBase *, int>, 16> Calls;
 
   // Populate the initial list of calls in this SCC.
   for (auto &N : InitialC) {
Index: llvm/include/llvm/Analysis/InlineOrder.h
===================================================================
--- /dev/null
+++ llvm/include/llvm/Analysis/InlineOrder.h
@@ -0,0 +1,52 @@
+
+//===- InlineOrder.h - Inlining order abstraction -*- C++ ---*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+#ifndef LLVM_ANALYSIS_INLINEORDER_H
+#define LLVM_ANALYSIS_INLINEORDER_H
+
+#include "llvm/ADT/SmallVector.h"
+
+namespace llvm {
+
+class InlineOrder {
+public:
+  using T = std::pair<CallBase *, int>;
+  using iterator = T *;
+  using const_iterator = const T *;
+  using reference = T &;
+
+  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) { return Calls[idx]; }
+  void push_back(const T &Elt) { Calls.push_back(Elt); }
+  T pop() { return Calls.pop_back_val(); }
+  iterator erase(const_iterator CB, const_iterator CE) {
+    return Calls.erase(CB, CE);
+  }
+  iterator begin() { return Calls.begin(); }
+  iterator end() { return Calls.end(); }
+
+private:
+  SmallVector<T, 16> Calls;
+};
+
+} // namespace llvm
+#endif // LLVM_ANALYSIS_INLINEORDER_H


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103315.348509.patch
Type: text/x-patch
Size: 2729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210528/d55427c9/attachment.bin>


More information about the llvm-commits mailing list