[llvm] r304476 - Add opt-bisect support for region passes.
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 14:22:27 PDT 2017
Author: efriedma
Date: Thu Jun 1 16:22:26 2017
New Revision: 304476
URL: http://llvm.org/viewvc/llvm-project?rev=304476&view=rev
Log:
Add opt-bisect support for region passes.
This is necessary to get opt-bisect working with polly.
Differential Revision: https://reviews.llvm.org/D33751
Modified:
llvm/trunk/include/llvm/Analysis/RegionPass.h
llvm/trunk/lib/Analysis/RegionPass.cpp
llvm/trunk/lib/IR/OptBisect.cpp
Modified: llvm/trunk/include/llvm/Analysis/RegionPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/RegionPass.h?rev=304476&r1=304475&r2=304476&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/RegionPass.h (original)
+++ llvm/trunk/include/llvm/Analysis/RegionPass.h Thu Jun 1 16:22:26 2017
@@ -78,6 +78,11 @@ public:
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.
Modified: llvm/trunk/lib/Analysis/RegionPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/RegionPass.cpp?rev=304476&r1=304475&r2=304476&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/RegionPass.cpp (original)
+++ llvm/trunk/lib/Analysis/RegionPass.cpp Thu Jun 1 16:22:26 2017
@@ -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 @@ Pass *RegionPass::createPrinterPass(raw_
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;
+}
Modified: llvm/trunk/lib/IR/OptBisect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/OptBisect.cpp?rev=304476&r1=304475&r2=304476&view=diff
==============================================================================
--- llvm/trunk/lib/IR/OptBisect.cpp (original)
+++ llvm/trunk/lib/IR/OptBisect.cpp Thu Jun 1 16:22:26 2017
@@ -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"
@@ -53,13 +54,20 @@ static std::string getDescription(const
}
static std::string getDescription(const Loop &L) {
- // FIXME: I'd like to be able to provide a better description here, but
- // calling L->getHeader() would introduce a new dependency on the
- // LLVMCore library.
+ // FIXME: Move into LoopInfo so we can get a better description
+ // (and avoid a circular dependency between IR and Analysis).
return "loop";
}
+static std::string getDescription(const Region &R) {
+ // FIXME: Move into RegionInfo so we can get a better description
+ // (and avoid a circular dependency between IR and Analysis).
+ return "region";
+}
+
static std::string getDescription(const CallGraphSCC &SCC) {
+ // FIXME: Move into CallGraphSCCPass to avoid circular dependency between
+ // IR and Analysis.
std::string Desc = "SCC (";
bool First = true;
for (CallGraphNode *CGN : SCC) {
@@ -83,6 +91,7 @@ template bool OptBisect::shouldRunPass(c
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) {
More information about the llvm-commits
mailing list