aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/Pass.cpp')
-rw-r--r--llvm/lib/IR/Pass.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/llvm/lib/IR/Pass.cpp b/llvm/lib/IR/Pass.cpp
index 2c5ef71..dec7c9a 100644
--- a/llvm/lib/IR/Pass.cpp
+++ b/llvm/lib/IR/Pass.cpp
@@ -62,8 +62,12 @@ static std::string getDescription(const Module &M) {
bool ModulePass::skipModule(const Module &M) const {
const OptPassGate &Gate = M.getContext().getOptPassGate();
- return Gate.isEnabled() &&
- !Gate.shouldRunPass(this->getPassName(), getDescription(M));
+
+ StringRef PassName = getPassArgument();
+ if (PassName.empty())
+ PassName = this->getPassName();
+
+ return Gate.isEnabled() && !Gate.shouldRunPass(PassName, getDescription(M));
}
bool Pass::mustPreserveAnalysisID(char &AID) const {
@@ -86,6 +90,16 @@ StringRef Pass::getPassName() const {
return "Unnamed pass: implement Pass::getPassName()";
}
+/// getPassArgument - Return a nice clean name for a pass
+/// corresponding to that used to enable the pass in opt
+StringRef Pass::getPassArgument() const {
+ AnalysisID AID = getPassID();
+ const PassInfo *PI = Pass::lookupPassInfo(AID);
+ if (PI)
+ return PI->getPassArgument();
+ return "";
+}
+
void Pass::preparePassManager(PMStack &) {
// By default, don't do anything.
}
@@ -173,8 +187,12 @@ static std::string getDescription(const Function &F) {
bool FunctionPass::skipFunction(const Function &F) const {
OptPassGate &Gate = F.getContext().getOptPassGate();
- if (Gate.isEnabled() &&
- !Gate.shouldRunPass(this->getPassName(), getDescription(F)))
+
+ StringRef PassName = getPassArgument();
+ if (PassName.empty())
+ PassName = this->getPassName();
+
+ if (Gate.isEnabled() && !Gate.shouldRunPass(PassName, getDescription(F)))
return true;
if (F.hasOptNone()) {