[PATCH] D33751: Add opt-bisect support for region passes

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 31 18:36:42 PDT 2017


efriedma created this revision.

This is necessary to get opt-bisect working with polly.


Repository:
  rL LLVM

https://reviews.llvm.org/D33751

Files:
  include/llvm/Analysis/RegionPass.h
  lib/Analysis/RegionPass.cpp
  lib/IR/OptBisect.cpp


Index: lib/IR/OptBisect.cpp
===================================================================
--- lib/IR/OptBisect.cpp
+++ lib/IR/OptBisect.cpp
@@ -16,6 +16,7 @@
 #include "llvm/Analysis/CallGraphSCCPass.h"
 #include "llvm/Analysis/LazyCallGraph.h"
 #include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Analysis/RegionInfo.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/OptBisect.h"
 #include "llvm/Pass.h"
@@ -59,6 +60,11 @@
   return "loop";
 }
 
+static std::string getDescription(const Region &R) {
+  // FIXME: Can we do better here?
+  return "region";
+}
+
 static std::string getDescription(const CallGraphSCC &SCC) {
   std::string Desc = "SCC (";
   bool First = true;
@@ -83,6 +89,7 @@
 template bool OptBisect::shouldRunPass(const Pass *, const BasicBlock &);
 template bool OptBisect::shouldRunPass(const Pass *, const Loop &);
 template bool OptBisect::shouldRunPass(const Pass *, const CallGraphSCC &);
+template bool OptBisect::shouldRunPass(const Pass *, const Region &);
 
 template <class UnitT>
 bool OptBisect::shouldRunPass(const Pass *P, const UnitT &U) {
Index: lib/Analysis/RegionPass.cpp
===================================================================
--- lib/Analysis/RegionPass.cpp
+++ lib/Analysis/RegionPass.cpp
@@ -15,6 +15,7 @@
 //===----------------------------------------------------------------------===//
 #include "llvm/Analysis/RegionPass.h"
 #include "llvm/Analysis/RegionIterator.h"
+#include "llvm/IR/OptBisect.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
@@ -280,3 +281,18 @@
                                   const std::string &Banner) const {
   return new PrintRegionPass(Banner, O);
 }
+
+bool RegionPass::skipRegion(Region &R) const {
+  Function *F = R.getEntry()->getParent();
+  if (!F->getContext().getOptBisect().shouldRunPass(this, R))
+    return true;
+
+  if (F->hasFnAttribute(Attribute::OptimizeNone)) {
+    // Report this only once per function.
+    if (R.getEntry() == &F->getEntryBlock())
+      DEBUG(dbgs() << "Skipping pass '" << getPassName()
+            << "' on function " << F->getName() << "\n");
+    return true;
+  }
+  return false;
+}
Index: include/llvm/Analysis/RegionPass.h
===================================================================
--- include/llvm/Analysis/RegionPass.h
+++ include/llvm/Analysis/RegionPass.h
@@ -78,6 +78,11 @@
     return PMT_RegionPassManager;
   }
   //@}
+
+protected:
+  /// Optional passes call this function to check whether the pass should be
+  /// skipped. This is the case when optimization bisect is over the limit.
+  bool skipRegion(Region &R) const;
 };
 
 /// @brief The pass manager to schedule RegionPasses.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33751.100956.patch
Type: text/x-patch
Size: 2708 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170601/0cdc1598/attachment.bin>


More information about the llvm-commits mailing list