[ScopInliner] Add a simple Scop-based inliner to polly.
We add a ScopInliner pass which inlines functions based on a simple heuristic:
Let `g` call `f`.
If we can model all of `f` as a Scop, we inline `f` into `g`.
This requires `-polly-detect-full-function` to be enabled. So, the pass
asserts that `-polly-detect-full-function` is enabled.
Differential Revision: https://reviews.llvm.org/D36832
llvm-svn: 311126
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 18496d4..6b5ed84 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -1,4 +1,3 @@
-//===----- ScopDetection.cpp - Detect Scops --------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -107,10 +106,12 @@
"ANY of the regexes provided."),
cl::ZeroOrMore, cl::CommaSeparated, cl::cat(PollyCategory));
-static cl::opt<bool>
- AllowFullFunction("polly-detect-full-functions",
- cl::desc("Allow the detection of full functions"),
- cl::init(false), cl::cat(PollyCategory));
+bool polly::PollyAllowFullFunction;
+static cl::opt<bool, true>
+ XAllowFullFunction("polly-detect-full-functions",
+ cl::desc("Allow the detection of full functions"),
+ cl::location(polly::PollyAllowFullFunction),
+ cl::init(false), cl::cat(PollyCategory));
static cl::opt<std::string> OnlyRegion(
"polly-only-region",
@@ -1541,7 +1542,7 @@
DEBUG(dbgs() << "Checking region: " << CurRegion.getNameStr() << "\n\t");
- if (!AllowFullFunction && CurRegion.isTopLevelRegion()) {
+ if (!PollyAllowFullFunction && CurRegion.isTopLevelRegion()) {
DEBUG(dbgs() << "Top level region is invalid\n");
return false;
}
@@ -1564,7 +1565,7 @@
// SCoP cannot contain the entry block of the function, because we need
// to insert alloca instruction there when translate scalar to array.
- if (!AllowFullFunction &&
+ if (!PollyAllowFullFunction &&
CurRegion.getEntry() ==
&(CurRegion.getEntry()->getParent()->getEntryBlock()))
return invalid<ReportEntry>(Context, /*Assert=*/true, CurRegion.getEntry());