[DeLICM] Fortify against exceeding isl's max operations counter.

Control flow would flow-through after the check whether the operations
quota exceeded, with the intention that it would later be caught by
Knowledge::isUsable(). However, the Knowledge constructor has its own
assertions to check consistency which would fail if its fields have only
been initialized partially because some sets have been computed correctly
before the operations quota takes effect.

Fix by erroring-out early instead of falling-throught into the code that
might expect that everything has been computed correctly. For robustness,
also bail-out if any of the fields contain nullptr values instead of
relying on isl always setting exactly this error code if something went
wrong.

This should fix the
perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable
(-polly-process-unprofitable -polly-position=before-vectorizer
-polly-enable-delicm) buildbot.

llvm-svn: 296022
This commit is contained in:
Michael Kruse 2017-02-23 21:58:20 +00:00
parent 78468e48cf
commit e199f285b0
1 changed files with 9 additions and 6 deletions

View File

@ -1569,8 +1569,12 @@ public:
EltUnused = computeLifetime();
EltWritten = computeWritten();
}
DeLICMAnalyzed++;
if (isl_ctx_last_error(IslCtx.get()) == isl_error_quota) {
if (!EltUnused || !EltWritten) {
assert(isl_ctx_last_error(IslCtx.get()) == isl_error_quota &&
"The only reason that these things have not been computed should "
"be if the max-operations limit hit");
DeLICMOutOfQuota++;
DEBUG(dbgs() << "DeLICM analysis exceeded max_operations\n");
DebugLoc Begin, End;
@ -1579,15 +1583,14 @@ public:
S->getEntry());
R << "maximal number of operations exceeded during zone analysis";
S->getFunction().getContext().diagnose(R);
return false;
}
DeLICMAnalyzed++;
OriginalZone = Knowledge(nullptr, EltUnused, EltWritten);
Zone = OriginalZone = Knowledge(nullptr, EltUnused, EltWritten);
DEBUG(dbgs() << "Computed Zone:\n"; OriginalZone.print(dbgs(), 4));
Zone = OriginalZone;
return DelicmMaxOps == 0 || Zone.isUsable();
assert(Zone.isUsable() && OriginalZone.isUsable());
return true;
}
/// Try to map as many scalars to unused array elements as possible.