Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -1222,30 +1222,20 @@ //===----------------------------------------------------------------------===// isl::map ScopStmt::getSchedule() const { - isl_set *Domain = getDomain().release(); - if (isl_set_is_empty(Domain)) { - isl_set_free(Domain); - return isl::manage(isl_map_from_aff(isl_aff_zero_on_domain( - isl_local_space_from_space(getDomainSpace().release())))); - } - auto *Schedule = getParent()->getSchedule().release(); - if (!Schedule) { - isl_set_free(Domain); + isl::set Domain = getDomain(); + if (Domain.is_empty()) + return isl::map::from_aff(isl::aff(isl::local_space(getDomainSpace()))); + auto Schedule = getParent()->getSchedule(); + if (!Schedule) return nullptr; - } - Schedule = isl_union_map_intersect_domain( - Schedule, isl_union_set_from_set(isl_set_copy(Domain))); - if (isl_union_map_is_empty(Schedule)) { - isl_set_free(Domain); - isl_union_map_free(Schedule); - return isl::manage(isl_map_from_aff(isl_aff_zero_on_domain( - isl_local_space_from_space(getDomainSpace().release())))); - } - auto *M = isl_map_from_union_map(Schedule); - M = isl_map_coalesce(M); - M = isl_map_gist_domain(M, Domain); - M = isl_map_coalesce(M); - return isl::manage(M); + Schedule = Schedule.intersect_domain(isl::union_set(Domain)); + if (Schedule.is_empty()) + return isl::map::from_aff(isl::aff(isl::local_space(getDomainSpace()))); + isl::map M = M.from_union_map(Schedule); + M = M.coalesce(); + M = M.gist_domain(Domain); + M = M.coalesce(); + return M; } void ScopStmt::restrictDomain(isl::set NewDomain) {