[Polly] [ScopDetection] Allow passing multiple functions to `-polly-only-func`.
- This is useful to run optimisations on only certain functions.
Differential Revision: https://reviews.llvm.org/D33990
llvm-svn: 305060
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 0d36414..9aa13b4 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -90,11 +90,13 @@
cl::location(PollyProcessUnprofitable), cl::init(false), cl::ZeroOrMore,
cl::cat(PollyCategory));
-static cl::opt<std::string> OnlyFunction(
+static cl::list<std::string> OnlyFunctions(
"polly-only-func",
- cl::desc("Only run on functions that contain a certain string"),
- cl::value_desc("string"), cl::ValueRequired, cl::init(""),
- cl::cat(PollyCategory));
+ cl::desc("Only run on functions that contain a certain string. "
+ "Multiple strings can be comma separated. "
+ "Scop detection will run on all functions that contain "
+ "any of the strings provided."),
+ cl::ZeroOrMore, cl::CommaSeparated, cl::cat(PollyCategory));
static cl::opt<bool>
AllowFullFunction("polly-detect-full-functions",
@@ -271,6 +273,12 @@
DP << FileName << ":" << ExitLine << ": End of scop";
}
+static bool IsFnNameListedInOnlyFunctions(StringRef FnName) {
+ for (auto Name : OnlyFunctions)
+ if (FnName.count(Name) > 0)
+ return true;
+ return false;
+}
//===----------------------------------------------------------------------===//
// ScopDetection.
@@ -284,7 +292,7 @@
Region *TopRegion = RI.getTopLevelRegion();
- if (OnlyFunction != "" && !F.getName().count(OnlyFunction))
+ if (OnlyFunctions.size() > 0 && !IsFnNameListedInOnlyFunctions(F.getName()))
return;
if (!isValidFunction(F))