From 08cfd39990e6819a82bd1fcab9c07422d4165927 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 21 Jan 2010 10:54:51 +0100 Subject: [PATCH] isl_tab_basic_map_partial_lexopt: properly handle empty input map In particular, when no empty set is requested (i.e., empty == NULL), then we shouldn't try to add the context to the empty set. --- isl_tab_pip.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/isl_tab_pip.c b/isl_tab_pip.c index 4d48d1a8..b1b1fcaa 100644 --- a/isl_tab_pip.c +++ b/isl_tab_pip.c @@ -548,6 +548,18 @@ static void sol_map_add_empty_wrap(struct isl_sol *sol, sol_map_add_empty((struct isl_sol_map *)sol, bset); } +/* Add bset to sol's empty, but only if we are actually collecting + * the empty set. + */ +static void sol_map_add_empty_if_needed(struct isl_sol_map *sol, + struct isl_basic_set *bset) +{ + if (sol->empty) + sol_map_add_empty(sol, bset); + else + isl_basic_set_free(bset); +} + /* Given a basic map "dom" that represents the context and an affine * matrix "M" that maps the dimensions of the context to the * output variables, construct a basic map with the same parameters @@ -3935,8 +3947,8 @@ struct isl_map *isl_tab_basic_map_partial_lexopt( if (isl_basic_set_fast_is_empty(context->op->peek_basic_set(context))) /* nothing */; else if (isl_basic_map_fast_is_empty(bmap)) - sol_map_add_empty(sol_map, - isl_basic_set_dup(context->op->peek_basic_set(context))); + sol_map_add_empty_if_needed(sol_map, + isl_basic_set_copy(context->op->peek_basic_set(context))); else { tab = tab_for_lexmin(bmap, context->op->peek_basic_set(context), 1, max); -- 2.11.4.GIT