Adapt coscheduled_source to handle error conditions returned by level_before
authorTobias Grosser <tobias@grosser.es>
Tue, 25 Jul 2017 16:52:46 +0000 (25 18:52 +0200)
committerSven Verdoolaege <sven.verdoolaege@gmail.com>
Wed, 26 Jul 2017 15:38:45 +0000 (26 17:38 +0200)
When isl-0.14-306-g5e596b8c2f started to use the isl schedule tree to
detect the order of accesses, it introduced a level_before function that
may also return -1, but failed to introduce code for handling such error
conditions in the callers. This resulted in unspecified behavior and
crashes, in cases where level_before returned a failure, e.g. in case of
a compute out. When isl-0.18-753-g9963b91 introduced code to handle
coscheduled dependences it did not take into account the possible error
condition, similarly how all existing code was not aware of this error
condition. All code already released in isl-0.18 has been corrected in
isl-0.18-80-g1a47003. This commit takes care of the necessary changes
in coscheduled_source.

Signed-off-by: Tobias Grosser <tobias@grosser.es>
Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>
isl_flow.c

index ccdbe72..21872b2 100644 (file)
@@ -903,6 +903,8 @@ static __isl_give isl_map *all_intermediate_sources(
  * uncurried to [T -> S] -> K.
  * This result is then intersected with the dependence relation S -> K
  * to form the output.
+ *
+ * In case a negative depth is given, NULL is returned to indicate an error.
  */
 static __isl_give isl_map *coscheduled_source(__isl_keep isl_access_info *acc,
        __isl_keep isl_map *old_map, int pos, int depth)
@@ -915,6 +917,9 @@ static __isl_give isl_map *coscheduled_source(__isl_keep isl_access_info *acc,
        isl_map *equal;
        isl_map *map;
 
+       if (depth < 0)
+               return NULL;
+
        set_C = isl_map_range(isl_map_copy(old_map));
        read_map = isl_map_copy(acc->sink.map);
        read_map = isl_map_intersect_domain(read_map, set_C);