Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Verdoolaege committed Apr 10, 2021
2 parents 65f5ac7 + 9594244 commit 647edd6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
9 changes: 6 additions & 3 deletions isl_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -2147,19 +2147,22 @@ static __isl_give isl_basic_map *isl_basic_map_swap_vars(
* Since the basic map has conflicting constraints,
* it must have at least one constraint, except perhaps
* if it was already explicitly marked as being empty.
* Do nothing in the latter case.
* Do nothing in the latter case, i.e., if it has been marked empty and
* has no constraints.
*/
__isl_give isl_basic_map *isl_basic_map_set_to_empty(
__isl_take isl_basic_map *bmap)
{
int i = 0;
isl_bool empty;
isl_size n;
isl_size total;

n = isl_basic_map_n_constraint(bmap);
empty = isl_basic_map_plain_is_empty(bmap);
if (empty < 0)
if (n < 0 || empty < 0)
return isl_basic_map_free(bmap);
if (empty)
if (n == 0 && empty)
return bmap;
total = isl_basic_map_dim(bmap, isl_dim_all);
if (total < 0)
Expand Down
29 changes: 29 additions & 0 deletions isl_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8693,6 +8693,34 @@ int test_sample(isl_ctx *ctx)
return 0;
}

/* Perform a projection on a basic set that is known to be empty
* but that has not been assigned a canonical representation.
* Earlier versions of isl would run into a stack overflow
* on this example.
*/
static int test_empty_projection(isl_ctx *ctx)
{
const char *str;
isl_bool empty;
isl_basic_set *bset;

str = "{ [a, b, c, d, e, f, g, h] : 5f = 1 + 4a - b + 5c - d - 2e and "
"3h = 2 + b + c and 14c >= 9 - 3a + 25b and "
"4c <= 50 - 3a + 23b and 6b <= -39 + a and "
"9g >= -6 + 3a + b + c and e < a + b - 2d and "
"7d >= -5 + 2a + 2b and 5g >= -14 + a - 4b + d + 2e and "
"9g <= -28 - 5b - 2c + 3d + 6e }";
bset = isl_basic_set_read_from_str(ctx, str);
empty = isl_basic_set_is_empty(bset);
bset = isl_basic_set_params(bset);
isl_basic_set_free(bset);

if (empty < 0)
return -1;

return 0;
}

int test_fixed_power(isl_ctx *ctx)
{
const char *str;
Expand Down Expand Up @@ -10825,6 +10853,7 @@ struct {
{ "slice", &test_slice },
{ "fixed power", &test_fixed_power },
{ "sample", &test_sample },
{ "empty projection", &test_empty_projection },
{ "output", &test_output },
{ "vertices", &test_vertices },
{ "chambers", &test_chambers },
Expand Down

0 comments on commit 647edd6

Please sign in to comment.