[PATCH] D28694: Add pass insertion point EP_BeforeLoopIdiom

Krzysztof Parzyszek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 16 10:53:17 PST 2017


kparzysz retitled this revision from "Hexagon-specific loop idiom recognition" to "Add pass insertion point EP_BeforeLoopIdiom".
kparzysz updated the summary for this revision.
kparzysz added a reviewer: mehdi_amini.
kparzysz updated this revision to Diff 84578.
kparzysz added a comment.

Extracted the implementation of the new insertion point, with the previous comments reflected.


Repository:
  rL LLVM

https://reviews.llvm.org/D28694

Files:
  include/llvm/Target/TargetMachine.h
  include/llvm/Transforms/IPO/PassManagerBuilder.h
  lib/Transforms/IPO/PassManagerBuilder.cpp
  tools/opt/opt.cpp


Index: tools/opt/opt.cpp
===================================================================
--- tools/opt/opt.cpp
+++ tools/opt/opt.cpp
@@ -288,12 +288,18 @@
       DisableSLPVectorization ? false : OptLevel > 1 && SizeLevel < 2;
 
   // Add target-specific passes that need to run as early as possible.
-  if (TM)
+  if (TM) {
     Builder.addExtension(
         PassManagerBuilder::EP_EarlyAsPossible,
         [&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
           TM->addEarlyAsPossiblePasses(PM);
         });
+    Builder.addExtension(
+        PassManagerBuilder::EP_BeforeLoopIdiom,
+        [&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
+          TM->addBeforeLoopIdiomPasses(PM);
+        });
+  }
 
   if (Coroutines)
     addCoroutinePassesToExtensionPoints(Builder);
Index: lib/Transforms/IPO/PassManagerBuilder.cpp
===================================================================
--- lib/Transforms/IPO/PassManagerBuilder.cpp
+++ lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -315,6 +315,9 @@
   MPM.add(createCFGSimplificationPass());
   addInstructionCombiningPass(MPM);
   MPM.add(createIndVarSimplifyPass());        // Canonicalize indvars
+
+  addExtensionsToPM(EP_BeforeLoopIdiom, MPM);
+
   MPM.add(createLoopIdiomPass());             // Recognize idioms like memset.
   MPM.add(createLoopDeletionPass());          // Delete dead loops
   if (EnableLoopInterchange) {
Index: include/llvm/Transforms/IPO/PassManagerBuilder.h
===================================================================
--- include/llvm/Transforms/IPO/PassManagerBuilder.h
+++ include/llvm/Transforms/IPO/PassManagerBuilder.h
@@ -100,6 +100,11 @@
     /// will be inserted after each instance of the instruction combiner pass.
     EP_Peephole,
 
+    /// EP_BeforeLoopIdiom - This extension point allows adding passes before
+    /// loop-idiom recognition passes. It can be used, for example, by a
+    /// target to add a specific loop-idiom recognition pass.
+    EP_BeforeLoopIdiom,
+
     /// EP_CGSCCOptimizerLate - This extension point allows adding CallGraphSCC
     /// passes at the end of the main CallGraphSCC passes and before any
     /// function simplification passes run by CGPassManager.
Index: include/llvm/Target/TargetMachine.h
===================================================================
--- include/llvm/Target/TargetMachine.h
+++ include/llvm/Target/TargetMachine.h
@@ -210,6 +210,11 @@
   /// passes.
   virtual void addEarlyAsPossiblePasses(PassManagerBase &) {}
 
+  /// Add target-specific passes that run before the loop idiom recognition
+  /// passes. This could be used to implement target-specific loop idiom
+  /// recognition.
+  virtual void addBeforeLoopIdiomPasses(PassManagerBase &) {}
+
   /// These enums are meant to be passed into addPassesToEmitFile to indicate
   /// what type of file to emit, and returned by it to indicate what type of
   /// file could actually be made.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28694.84578.patch
Type: text/x-patch
Size: 2961 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170116/f7ce7e76/attachment.bin>


More information about the llvm-commits mailing list