From 87613b9051ff5323f747d13455252f7e855b6c1d Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 28 Apr 2015 16:51:23 +0200 Subject: [PATCH] isl_ast_graft_list_extract_shared_enforced: allow empty list of grafts We usually do not start generating a for node unless there are any statement instances that need to be executed by that for loop. It therefore makes sense to error out if it turns out such a situation occurs. However, it is perfectly possible to recover from such situations and so we might as well do that, even though the result will look somewhat awkward as it will contain an empty loop guarded by an "if (0)". Also, when we change build_ast_from_extension to only intersect the extension with the simple hull of generated domain in a subsequent commit, we may introduce such cases if (part of) the extension conflicts with the generated domain, but not with its simple hull. Signed-off-by: Sven Verdoolaege --- isl_ast_graft.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/isl_ast_graft.c b/isl_ast_graft.c index cfcfbd38..6d90dd2b 100644 --- a/isl_ast_graft.c +++ b/isl_ast_graft.c @@ -719,7 +719,7 @@ static __isl_give isl_ast_node_list *extract_node_list( /* Look for shared enforced constraints by all the elements in "list" * on outer loops (with respect to the current depth) and return the result. * - * We assume that the number of children is at least one. + * If there are no elements in "list", then return the empty set. */ __isl_give isl_basic_set *isl_ast_graft_list_extract_shared_enforced( __isl_keep isl_ast_graft_list *list, @@ -733,16 +733,11 @@ __isl_give isl_basic_set *isl_ast_graft_list_extract_shared_enforced( if (!list) return NULL; - n = isl_ast_graft_list_n_ast_graft(list); - if (n == 0) - isl_die(isl_ast_graft_list_get_ctx(list), isl_error_invalid, - "for node should have at least one child", - return NULL); - space = isl_ast_build_get_space(build, 1); enforced = isl_basic_set_empty(space); depth = isl_ast_build_get_depth(build); + n = isl_ast_graft_list_n_ast_graft(list); for (i = 0; i < n; ++i) { isl_ast_graft *graft; -- 2.11.4.GIT