[FIX] Create error-restrictions late

  Before this patch we generated error-restrictions only for
  error-blocks, thus blocks (or regions) containing a not represented
  function call. However, the same reasoning is needed if the invalid
  domain of a statement subsumes its actual domain. To this end we move
  the generation of error-restrictions after the propagation of the
  invalid domains. Consequently, error-statements are now defined more
  general as statements that are assumed to be not executed.
  Additionally, we do not record an empty domain for such statements but
  a nullptr instead. This allows to distinguish between error-statements
  and dead-statements.

llvm-svn: 269053
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index cb192f8..f02a807 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -2383,8 +2383,10 @@
     } else {
       isl_set_free(InvalidDomain);
       InvalidDomain = Domain;
-      auto *EmptyDom = isl_set_empty(isl_set_get_space(InvalidDomain));
-      Domain = EmptyDom;
+      isl_set *DomPar = isl_set_params(isl_set_copy(Domain));
+      recordAssumption(ERRORBLOCK, DomPar, BB->getTerminator()->getDebugLoc(),
+                       AS_RESTRICTION);
+      Domain = nullptr;
     }
 
     if (isl_set_is_empty(InvalidDomain)) {
@@ -2706,14 +2708,6 @@
     Loop *BBLoop = getRegionNodeLoop(RN, LI);
     if (BBLoop && BBLoop->getHeader() == BB && getRegion().contains(BBLoop))
       addLoopBoundsToHeaderDomain(BBLoop, LI);
-
-    // Add assumptions for error blocks.
-    if (containsErrorBlock(RN, getRegion(), LI, DT)) {
-      IsOptimized = true;
-      isl_set *DomPar = isl_set_params(isl_set_copy(Domain));
-      recordAssumption(ERRORBLOCK, DomPar, BB->getTerminator()->getDebugLoc(),
-                       AS_RESTRICTION);
-    }
   }
 }
 
@@ -3180,7 +3174,7 @@
 
     bool RemoveStmt = Stmt.isEmpty();
     if (!RemoveStmt)
-      RemoveStmt = isl_set_is_empty(DomainMap[Stmt.getEntryBlock()]);
+      RemoveStmt = !DomainMap[Stmt.getEntryBlock()];
 
     // Remove read only statements only after invariant loop hoisting.
     if (!RemoveStmt && AfterHoisting) {
@@ -3647,6 +3641,13 @@
       continue;
     }
 
+    // If the domain was deleted the assumptions are void.
+    isl_set *Dom = getDomainConditions(AS.BB);
+    if (!Dom) {
+      isl_set_free(AS.Set);
+      continue;
+    }
+
     // If a basic block was given use its domain to simplify the assumption.
     // In case of restrictions we know they only have to hold on the domain,
     // thus we can intersect them with the domain of the block. However, for
@@ -3657,7 +3658,6 @@
     // To avoid the complement we will register A - B as a restricton not an
     // assumption.
     isl_set *S = AS.Set;
-    isl_set *Dom = getDomainConditions(AS.BB);
     if (AS.Sign == AS_RESTRICTION)
       S = isl_set_params(isl_set_intersect(S, Dom));
     else /* (AS.Sign == AS_ASSUMPTION) */