Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -2301,18 +2301,24 @@ } /// Add the minimal/maximal access in @p Set to @p User. -static isl::stat -buildMinMaxAccess(isl::set Set, Scop::MinMaxVectorTy &MinMaxAccesses, Scop &S) { +static void buildMinMaxAccess(isl::set Set, + Scop::MinMaxVectorTy &MinMaxAccesses, Scop &S, + bool &Aborted) { isl::pw_multi_aff MinPMA, MaxPMA; isl::pw_aff LastDimAff; isl::aff OneAff; unsigned Pos; isl::ctx Ctx = Set.get_ctx(); + if (Aborted) + return; + Set = Set.remove_divs(); - if (isl_set_n_basic_set(Set.get()) >= MaxDisjunctsInDomain) - return isl::stat::error; + if (isl_set_n_basic_set(Set.get()) >= MaxDisjunctsInDomain) { + Aborted = true; + return; + } // Restrict the number of parameters involved in the access as the lexmin/ // lexmax computation will take too long if this number is high. @@ -2334,18 +2340,24 @@ if (Set.involves_dims(isl::dim::param, u, 1)) InvolvedParams++; - if (InvolvedParams > RunTimeChecksMaxParameters) - return isl::stat::error; + if (InvolvedParams > RunTimeChecksMaxParameters) { + Aborted = true; + return; + } } - if (isl_set_n_basic_set(Set.get()) > RunTimeChecksMaxAccessDisjuncts) - return isl::stat::error; + if (isl_set_n_basic_set(Set.get()) > RunTimeChecksMaxAccessDisjuncts) { + Aborted = true; + return; + } MinPMA = Set.lexmin_pw_multi_aff(); MaxPMA = Set.lexmax_pw_multi_aff(); - if (isl_ctx_last_error(Ctx.get()) == isl_error_quota) - return isl::stat::error; + if (isl_ctx_last_error(Ctx.get()) == isl_error_quota) { + Aborted = true; + return; + } MinPMA = MinPMA.coalesce(); MaxPMA = MaxPMA.coalesce(); @@ -2363,8 +2375,6 @@ MaxPMA = MaxPMA.set_pw_aff(Pos, LastDimAff); MinMaxAccesses.push_back(std::make_pair(MinPMA, MaxPMA)); - - return isl::stat::ok; } static __isl_give isl_set *getAccessDomain(MemoryAccess *MA) { @@ -2389,10 +2399,14 @@ Locations = Locations.coalesce(); Locations = Locations.detect_equalities(); - auto Lambda = [&MinMaxAccesses, &S](isl::set Set) -> isl::stat { - return buildMinMaxAccess(Set, MinMaxAccesses, S); + bool Aborted = false; + auto Lambda = [&MinMaxAccesses, &S, &Aborted](isl::set Set) -> isl::stat { + buildMinMaxAccess(Set, MinMaxAccesses, S, Aborted); + return isl::stat::ok; }; - return Locations.foreach_set(Lambda) == isl::stat::ok; + Locations.foreach_set(Lambda); + + return !Aborted; } /// Helper to treat non-affine regions and basic blocks the same. @@ -4605,10 +4619,7 @@ return isl::stat::ok; }; - isl::stat Res = USet.foreach_set(Lambda); - (void)Res; - - assert(Res == isl::stat::ok); + USet.foreach_set(Lambda); return isl::multi_union_pw_aff(isl::union_pw_multi_aff(Result)); } Index: lib/Support/ISLTools.cpp =================================================================== --- lib/Support/ISLTools.cpp +++ lib/Support/ISLTools.cpp @@ -470,13 +470,11 @@ isl::union_map polly::distributeDomain(isl::union_map UMap) { isl::union_map Result = isl::union_map::empty(UMap.get_space()); - isl::stat Success = UMap.foreach_map([=, &Result](isl::map Map) { + UMap.foreach_map([=, &Result](isl::map Map) { auto Distributed = distributeDomain(Map); Result = Result.add_map(Distributed); return isl::stat::ok; }); - if (Success != isl::stat::ok) - return {}; return Result; } @@ -522,7 +520,7 @@ // Set is constant-bounded. if (!Aff.is_cst()) { Result = isl::val::nan(Aff.get_ctx()); - return isl::stat::error; + return isl::stat::ok; } isl::val ThisVal = Aff.get_constant_val(); @@ -546,7 +544,7 @@ // Not compatible Result = isl::val::nan(Aff.get_ctx()); - return isl::stat::error; + return isl::stat::ok; }); return Result; } Index: lib/Transform/FlattenAlgo.cpp =================================================================== --- lib/Transform/FlattenAlgo.cpp +++ lib/Transform/FlattenAlgo.cpp @@ -54,20 +54,28 @@ /// Whether Map's first out dimension is no constant nor piecewise constant. bool isVariableDim(const isl::map &Map) { - return Map.foreach_basic_map([](isl::basic_map BMap) -> isl::stat { + bool IsVariableDim = false; + + Map.foreach_basic_map([&](isl::basic_map BMap) -> isl::stat { if (isVariableDim(BMap)) - return isl::stat::error; + IsVariableDim = true; return isl::stat::ok; - }) == isl::stat::ok; + }); + + return IsVariableDim; } /// Whether UMap's first out dimension is no (piecewise) constant. bool isVariableDim(const isl::union_map &UMap) { - return UMap.foreach_map([](isl::map Map) -> isl::stat { + bool IsVariableDim = false; + + UMap.foreach_map([&](isl::map Map) { if (isVariableDim(Map)) - return isl::stat::error; + IsVariableDim = true; return isl::stat::ok; - }) == isl::stat::ok; + }); + + return IsVariableDim; } /// Compute @p UPwAff - @p Val. Index: lib/Transform/ForwardOpTree.cpp =================================================================== --- lib/Transform/ForwardOpTree.cpp +++ lib/Transform/ForwardOpTree.cpp @@ -243,8 +243,12 @@ // (i.e. not: { Dom[0] -> A[0]; Dom[1] -> B[1] }). // Look through all spaces until we find one that contains at least the // wanted statement instance.s + bool Aborted = false; MustKnown.foreach_map([&](isl::map Map) -> isl::stat { // Get the array this is accessing. + if (Aborted) + return isl::stat::ok; + isl::id ArrayId = Map.get_tuple_id(isl::dim::out); ScopArrayInfo *SAI = static_cast(ArrayId.get_user()); @@ -262,7 +266,9 @@ // mapping, we do not care about which one. // TODO: Get the simplest access function. Result = Map.lexmin(); - return isl::stat::error; // break + + Aborted = true; + return isl::stat::ok; // break }); return Result; Index: lib/Transform/Simplify.cpp =================================================================== --- lib/Transform/Simplify.cpp +++ lib/Transform/Simplify.cpp @@ -97,15 +97,28 @@ return UMap.add_map(Map); isl::map Result = isl::map::empty(PrevMap.get_space()); - PrevMap.foreach_basic_map([&Result](isl::basic_map BMap) -> isl::stat { - if (isl_map_n_basic_map(Result.get()) > SimplifyMaxDisjuncts) - return isl::stat::error; - Result = Result.unite(BMap); - return isl::stat::ok; - }); - Map.foreach_basic_map([&Result](isl::basic_map BMap) -> isl::stat { - if (isl_map_n_basic_map(Result.get()) > SimplifyMaxDisjuncts) - return isl::stat::error; + bool Aborted; + + Aborted = false; + PrevMap.foreach_basic_map( + [&Result, &Aborted](isl::basic_map BMap) -> isl::stat { + if (Aborted) + return isl::stat::ok; + + if (isl_map_n_basic_map(Result.get()) > SimplifyMaxDisjuncts) { + Aborted = true; + return isl::stat::ok; + } + Result = Result.unite(BMap); + return isl::stat::ok; + }); + + Aborted = false; + Map.foreach_basic_map([&Result, &Aborted](isl::basic_map BMap) -> isl::stat { + if (isl_map_n_basic_map(Result.get()) > SimplifyMaxDisjuncts) { + Aborted = true; + return isl::stat::ok; + } Result = Result.unite(BMap); return isl::stat::ok; }); @@ -312,7 +325,10 @@ FutureWrites.uncurry().intersect_domain(Filter.wrap()); // Iterate through the candidates. + bool Aborted = false; Filtered.foreach_map([&, this](isl::map Map) -> isl::stat { + if (Aborted) + return isl::stat::ok; MemoryAccess *OtherMA = (MemoryAccess *)Map.get_space() .get_tuple_id(isl::dim::out) .get_user(); @@ -342,7 +358,8 @@ WritesCoalesced++; // Don't look for more candidates. - return isl::stat::error; + Aborted = true; + return isl::stat::ok; }); } Index: lib/Transform/ZoneAlgo.cpp =================================================================== --- lib/Transform/ZoneAlgo.cpp +++ lib/Transform/ZoneAlgo.cpp @@ -252,13 +252,11 @@ isl::union_map polly::filterKnownValInst(const isl::union_map &UMap) { isl::union_map Result = isl::union_map::empty(UMap.get_space()); - isl::stat Success = UMap.foreach_map([=, &Result](isl::map Map) -> isl::stat { + UMap.foreach_map([=, &Result](isl::map Map) -> isl::stat { if (!isMapToUnknown(Map)) Result = Result.add_map(Map); return isl::stat::ok; }); - if (Success != isl::stat::ok) - return {}; return Result; } @@ -863,12 +861,13 @@ } bool ZoneAlgorithm::isNormalized(isl::union_map UMap) { - auto Result = UMap.foreach_map([this](isl::map Map) -> isl::stat { - if (isNormalized(Map)) - return isl::stat::ok; - return isl::stat::error; + bool IsNormalized = true; + UMap.foreach_map([&](isl::map Map) -> isl::stat { + if (!isNormalized(Map)) + IsNormalized = false; + return isl::stat::ok; }); - return Result == isl::stat::ok; + return IsNormalized; } void ZoneAlgorithm::computeCommon() {