diff options
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/OptBisect.cpp | 76 | ||||
-rw-r--r-- | llvm/lib/IR/Pass.cpp | 22 |
2 files changed, 22 insertions, 76 deletions
diff --git a/llvm/lib/IR/OptBisect.cpp b/llvm/lib/IR/OptBisect.cpp index 6f4d954d822..3104b90f307 100644 --- a/llvm/lib/IR/OptBisect.cpp +++ b/llvm/lib/IR/OptBisect.cpp @@ -14,13 +14,6 @@ #include "llvm/IR/OptBisect.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Analysis/CallGraph.h" -#include "llvm/Analysis/CallGraphSCCPass.h" -#include "llvm/Analysis/LoopInfo.h" -#include "llvm/Analysis/RegionInfo.h" -#include "llvm/IR/BasicBlock.h" -#include "llvm/IR/Function.h" -#include "llvm/IR/Module.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" @@ -46,73 +39,10 @@ static void printPassMessage(const StringRef &Name, int PassNum, << "(" << PassNum << ") " << Name << " on " << TargetDesc << "\n"; } -static std::string getDescription(const Module &M) { - return "module (" + M.getName().str() + ")"; -} - -static std::string getDescription(const Function &F) { - return "function (" + F.getName().str() + ")"; -} - -static std::string getDescription(const BasicBlock &BB) { - return "basic block (" + BB.getName().str() + ") in function (" + - BB.getParent()->getName().str() + ")"; -} - -static std::string getDescription(const Loop &L) { - // 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) { - if (First) - First = false; - else - Desc += ", "; - Function *F = CGN->getFunction(); - if (F) - Desc += F->getName(); - else - Desc += "<<null function>>"; - } - Desc += ")"; - return Desc; -} - -bool OptBisect::shouldRunPass(const Pass *P, const Module &U) { - return !BisectEnabled || checkPass(P->getPassName(), getDescription(U)); -} - -bool OptBisect::shouldRunPass(const Pass *P, const Function &U) { - return !BisectEnabled || checkPass(P->getPassName(), getDescription(U)); -} - -bool OptBisect::shouldRunPass(const Pass *P, const BasicBlock &U) { - return !BisectEnabled || checkPass(P->getPassName(), getDescription(U)); -} - -bool OptBisect::shouldRunPass(const Pass *P, const Region &U) { - return !BisectEnabled || checkPass(P->getPassName(), getDescription(U)); -} - -bool OptBisect::shouldRunPass(const Pass *P, const Loop &U) { - return !BisectEnabled || checkPass(P->getPassName(), getDescription(U)); -} +bool OptBisect::shouldRunPass(const Pass *P, StringRef IRDescription) { + assert(BisectEnabled); -bool OptBisect::shouldRunPass(const Pass *P, const CallGraphSCC &U) { - return !BisectEnabled || checkPass(P->getPassName(), getDescription(U)); + return checkPass(P->getPassName(), IRDescription); } bool OptBisect::checkPass(const StringRef PassName, diff --git a/llvm/lib/IR/Pass.cpp b/llvm/lib/IR/Pass.cpp index e9a0c68495b..4038205e044 100644 --- a/llvm/lib/IR/Pass.cpp +++ b/llvm/lib/IR/Pass.cpp @@ -55,8 +55,13 @@ PassManagerType ModulePass::getPotentialPassManagerType() const { return PMT_ModulePassManager; } +static std::string getDescription(const Module &M) { + return "module (" + M.getName().str() + ")"; +} + bool ModulePass::skipModule(Module &M) const { - return !M.getContext().getOptPassGate().shouldRunPass(this, M); + OptPassGate &Gate = M.getContext().getOptPassGate(); + return Gate.isEnabled() && !Gate.shouldRunPass(this, getDescription(M)); } bool Pass::mustPreserveAnalysisID(char &AID) const { @@ -154,8 +159,13 @@ PassManagerType FunctionPass::getPotentialPassManagerType() const { return PMT_FunctionPassManager; } +static std::string getDescription(const Function &F) { + return "function (" + F.getName().str() + ")"; +} + bool FunctionPass::skipFunction(const Function &F) const { - if (!F.getContext().getOptPassGate().shouldRunPass(this, F)) + OptPassGate &Gate = F.getContext().getOptPassGate(); + if (Gate.isEnabled() && !Gate.shouldRunPass(this, getDescription(F))) return true; if (F.hasFnAttribute(Attribute::OptimizeNone)) { @@ -185,11 +195,17 @@ bool BasicBlockPass::doFinalization(Function &) { return false; } +static std::string getDescription(const BasicBlock &BB) { + return "basic block (" + BB.getName().str() + ") in function (" + + BB.getParent()->getName().str() + ")"; +} + bool BasicBlockPass::skipBasicBlock(const BasicBlock &BB) const { const Function *F = BB.getParent(); if (!F) return false; - if (!F->getContext().getOptPassGate().shouldRunPass(this, BB)) + OptPassGate &Gate = F->getContext().getOptPassGate(); + if (Gate.isEnabled() && !Gate.shouldRunPass(this, getDescription(BB))) return true; if (F->hasFnAttribute(Attribute::OptimizeNone)) { // Report this only once per function. |