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

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 23 13:58:20 PST 2017


Author: meinersbur
Date: Thu Feb 23 15:58:20 2017
New Revision: 296022

URL: http://llvm.org/viewvc/llvm-project?rev=296022&view=rev
Log:
[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.

Modified:
    polly/trunk/lib/Transform/DeLICM.cpp

Modified: polly/trunk/lib/Transform/DeLICM.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Transform/DeLICM.cpp?rev=296022&r1=296021&r2=296022&view=diff
==============================================================================
--- polly/trunk/lib/Transform/DeLICM.cpp (original)
+++ polly/trunk/lib/Transform/DeLICM.cpp Thu Feb 23 15:58:20 2017
@@ -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.




More information about the llvm-commits mailing list