[polly] [Polly] Guard ISL ast gen compute out (PR #201859)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 17 04:02:13 PDT 2026


================
@@ -717,34 +717,44 @@ bool Dependences::isParallel(__isl_keep isl_union_map *Schedule,
                              __isl_give isl_pw_aff **MinDistancePtr) const {
   isl_set *Deltas, *Distance;
   isl_map *ScheduleDeps;
-  unsigned Dimension;
+  int Dimension;
   bool IsParallel;
 
   Deps = isl_union_map_apply_range(Deps, isl_union_map_copy(Schedule));
   Deps = isl_union_map_apply_domain(Deps, isl_union_map_copy(Schedule));
+  isl_bool UnionMapIsEmpty = isl_union_map_is_empty(Deps);
 
-  if (isl_union_map_is_empty(Deps)) {
+  if (UnionMapIsEmpty != isl_bool_false) {
     isl_union_map_free(Deps);
-    return true;
+    return UnionMapIsEmpty == isl_bool_true;
   }
 
   ScheduleDeps = isl_map_from_union_map(Deps);
+  // In the event isl_map_dim() returns isl_size_error which is -1
+  // then Dimension being an unsigned variable would store a very large
+  // wrap-around value. This could result in compilation issues like indefinite
+  // hang. Thus changed Dimension into an signed integer storage
   Dimension = isl_map_dim(ScheduleDeps, isl_dim_out) - 1;
 
-  for (unsigned i = 0; i < Dimension; i++)
+  if (Dimension < 0) {
+    isl_map_free(ScheduleDeps);
+    return false;
----------------
Meinersbur wrote:

[not a change request] I don't think it needs to be a tristate. Even if it detects some dependencies, due to dependence analysis being conservative, there may still not actually be real dependencies at runtime. That is, users should not need to discriminate between "could not compute any dependencies (for whatever reason)", and "could not rule out race condition with overapproxmiated dependencies". Using `std::boolean` follows ISL's pattern though.

https://github.com/llvm/llvm-project/pull/201859


More information about the llvm-commits mailing list