summaryrefslogtreecommitdiffstats
path: root/polly/lib/Analysis/ScopInfo.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <doerfert@cs.uni-saarland.de>2015-09-10 17:51:27 +0000
committerJohannes Doerfert <doerfert@cs.uni-saarland.de>2015-09-10 17:51:27 +0000
commit90db75ed24fdfe533ca0cbfa7771618959a9fd41 (patch)
tree42eede43fa74b461a3ac262eec9a1f8f4bfc7fcf /polly/lib/Analysis/ScopInfo.cpp
parent053701399d42c76fdaff6c16f44494516c046c80 (diff)
downloadbcm5719-llvm-90db75ed24fdfe533ca0cbfa7771618959a9fd41.tar.gz
bcm5719-llvm-90db75ed24fdfe533ca0cbfa7771618959a9fd41.zip
Runtime error check elimination
Hoist runtime checks in the loop nest if they guard an "error" like event. Such events are recognized as blocks with an unreachable terminator or a call to the ubsan function that deals with out of bound accesses. Other "error" events can be added easily. We will ignore these blocks when we detect/model/optmize and code generate SCoPs but we will make sure that they would not have been executed using the assumption framework. llvm-svn: 247310
Diffstat (limited to 'polly/lib/Analysis/ScopInfo.cpp')
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 0fcde7d308e..dddef6689d1 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -1554,6 +1554,15 @@ void Scop::buildDomainsWithBranchConstraints(Region *R, LoopInfo &LI,
}
BasicBlock *BB = getRegionNodeBasicBlock(RN);
+ TerminatorInst *TI = BB->getTerminator();
+
+ // Unreachable instructions do not have successors so we can skip them.
+ if (isa<UnreachableInst>(TI)) {
+ // Assume unreachables only in error blocks.
+ assert(isErrorBlock(*BB));
+ continue;
+ }
+
isl_set *Domain = DomainMap[BB];
DEBUG(dbgs() << "\tVisit: " << BB->getName() << " : " << Domain << "\n");
assert(Domain && "Due to reverse post order traversal of the region all "
@@ -1569,7 +1578,7 @@ void Scop::buildDomainsWithBranchConstraints(Region *R, LoopInfo &LI,
// exit node, hence the single entry node domain is the condition set. For
// basic blocks we use the helper function buildConditionSets.
SmallVector<isl_set *, 2> ConditionSets;
- BranchInst *BI = cast<BranchInst>(BB->getTerminator());
+ BranchInst *BI = cast<BranchInst>(TI);
if (RN->isSubRegion())
ConditionSets.push_back(isl_set_copy(Domain));
else
@@ -1738,6 +1747,13 @@ void Scop::propagateDomainConstraints(Region *R, LoopInfo &LI,
// Under the union of all predecessor conditions we can reach this block.
Domain = isl_set_intersect(Domain, PredDom);
+
+ // Add assumptions for error blocks.
+ if (isErrorBlock(*BB)) {
+ IsOptimized = true;
+ isl_set *DomPar = isl_set_params(isl_set_copy(Domain));
+ addAssumption(isl_set_complement(DomPar));
+ }
}
}
@@ -2435,7 +2451,7 @@ bool Scop::restrictDomains(__isl_take isl_union_set *Domain) {
ScalarEvolution *Scop::getSE() const { return SE; }
bool Scop::isTrivialBB(BasicBlock *BB, TempScop &tempScop) {
- if (tempScop.getAccessFunctions(BB))
+ if (tempScop.getAccessFunctions(BB) && !isErrorBlock(*BB))
return false;
return true;
OpenPOWER on IntegriCloud