Treat conditionally executed non-pure calls as errors
This replaces the support for user defined error functions by a
heuristic that tries to determine if a call to a non-pure function
should be considered "an error". If so the block is assumed not to be
executed at runtime. While treating all non-pure function calls as
errors will allow a lot more regions to be analyzed, it will also
cause us to dismiss a lot again due to an infeasible runtime context.
This patch tries to limit that effect. A non-pure function call is
considered an error if it is executed only in conditionally with
regards to a cheap but simple heuristic.
llvm-svn: 249611
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 05a5213..315ef71 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -1698,11 +1698,12 @@
return NumBlocks;
}
-static bool containsErrorBlock(RegionNode *RN) {
+static bool containsErrorBlock(RegionNode *RN, const Region &R, LoopInfo &LI,
+ const DominatorTree &DT) {
if (!RN->isSubRegion())
- return isErrorBlock(*RN->getNodeAs<BasicBlock>());
+ return isErrorBlock(*RN->getNodeAs<BasicBlock>(), R, LI, DT);
for (BasicBlock *BB : RN->getNodeAs<Region>()->blocks())
- if (isErrorBlock(*BB))
+ if (isErrorBlock(*BB, R, LI, DT))
return true;
return false;
}
@@ -1785,7 +1786,7 @@
// the predecessors and can therefor look at the domain of a error block.
// That allows us to generate the assumptions needed for them not to be
// executed at runtime.
- if (containsErrorBlock(RN))
+ if (containsErrorBlock(RN, getRegion(), LI, DT))
continue;
BasicBlock *BB = getRegionNodeBasicBlock(RN);
@@ -1993,7 +1994,7 @@
addLoopBoundsToHeaderDomain(BBLoop);
// Add assumptions for error blocks.
- if (containsErrorBlock(RN)) {
+ if (containsErrorBlock(RN, getRegion(), LI, DT)) {
IsOptimized = true;
isl_set *DomPar = isl_set_params(isl_set_copy(Domain));
addAssumption(isl_set_complement(DomPar));
@@ -2888,7 +2889,7 @@
return true;
// Check if error blocks are contained.
- if (containsErrorBlock(RN))
+ if (containsErrorBlock(RN, getRegion(), LI, DT))
return true;
return false;