[PATCH] D69446: [llvm][MachineOutliner] Add support for repeating machine outliner N times.

Puyan Lotfi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 25 12:57:40 PDT 2019


plotfi created this revision.
plotfi added reviewers: kyulee, paquette.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

This has been discussed for a while now, that rerunning the outliner can have some size wins.
So I am posting this change for review to address this.

Special Thanks to Kyungwoo Lee for experimenting on this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69446

Files:
  llvm/lib/CodeGen/MachineOutliner.cpp


Index: llvm/lib/CodeGen/MachineOutliner.cpp
===================================================================
--- llvm/lib/CodeGen/MachineOutliner.cpp
+++ llvm/lib/CodeGen/MachineOutliner.cpp
@@ -96,6 +96,10 @@
     cl::desc("Enable the machine outliner on linkonceodr functions"),
     cl::init(false));
 
+static cl::opt<unsigned> Iterations(
+    "outlining-iteration", cl::init(1), cl::Hidden,
+    cl::desc("Total number of outlining iterations to perform"));
+
 namespace {
 
 /// Represents an undefined index in the suffix tree.
@@ -896,9 +900,13 @@
                                           unsigned Name);
 
   /// Construct a suffix tree on the instructions in \p M and outline repeated
-  /// strings from that tree.
+  /// strings from that tree. This will be run doOutline on M Iterations times.
   bool runOnModule(Module &M) override;
 
+  /// Construct a suffix tree on the instructions in \p M and outline repeated
+  /// strings from that tree. This will do outlining on M once.
+  bool doOutline(Module &M);
+
   /// Return a DISubprogram for OF if one exists, and null otherwise. Helper
   /// function for remark emission.
   DISubprogram *getSubprogramOrNull(const OutlinedFunction &OF) {
@@ -1427,6 +1435,20 @@
   if (M.empty())
     return false;
 
+  if (Iterations > 1) {
+    bool Changed = false;
+    for (unsigned I = 0; I < Iterations; ++I)
+      if (doOutline(M))
+        Changed = true;
+      else
+        return Changed;
+    return Changed;
+  }
+
+  return doOutline(M);
+}
+
+bool MachineOutliner::doOutline(Module &M) {
   MachineModuleInfo &MMI = getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
 
   // If the user passed -enable-machine-outliner=always or


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69446.226489.patch
Type: text/x-patch
Size: 1710 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191025/999c51e2/attachment.bin>


More information about the llvm-commits mailing list