From 11354e507640f9602f7a4e56f1c92b9996c3e2cd Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 13 Sep 2017 14:32:30 +0200 Subject: [PATCH] isl_scheduler.c: extract_edge: do not add edges that turn out to be empty Even though extract_edge should only be called on non-empty dependence relations, the relation may become empty after intersection with the constraints used during compression. Adding an empty edge is not usually a problem because graph_has_edge will ignore such edges. However, for edges of types that can appear multiple times between the same pair of nodes, an empty edge may shadow a non-empty edge, in which case the non-empty edge(s) would be ignored. Refrain from adding empty edges to avoid this potential problem. Signed-off-by: Sven Verdoolaege --- isl_scheduler.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/isl_scheduler.c b/isl_scheduler.c index e3dbb764..2add06be 100644 --- a/isl_scheduler.c +++ b/isl_scheduler.c @@ -1214,6 +1214,7 @@ static isl_stat skip_edge(__isl_take isl_map *map, __isl_take isl_map *tagged) */ static isl_stat extract_edge(__isl_take isl_map *map, void *user) { + isl_bool empty; isl_ctx *ctx = isl_map_get_ctx(map); struct isl_extract_edge_data *data = user; struct isl_sched_graph *graph = data->graph; @@ -1245,6 +1246,12 @@ static isl_stat extract_edge(__isl_take isl_map *map, void *user) map = isl_map_intersect(map, hull); } + empty = isl_map_plain_is_empty(map); + if (empty < 0) + goto error; + if (empty) + return skip_edge(map, tagged); + graph->edge[graph->n_edge].src = src; graph->edge[graph->n_edge].dst = dst; graph->edge[graph->n_edge].map = map; @@ -1272,6 +1279,10 @@ static isl_stat extract_edge(__isl_take isl_map *map, void *user) return -1; return graph_edge_table_add(ctx, graph, data->type, edge); +error: + isl_map_free(map); + isl_map_free(tagged); + return isl_stat_error; } /* Initialize the schedule graph "graph" from the schedule constraints "sc". -- 2.11.4.GIT