From: Riccardo Mori Date: Mon, 19 Jul 2021 08:47:52 +0000 (+0200) Subject: [Polly][Isl] Stop generating isl::union_{set,map} from isl::space. NFC X-Git-Tag: llvmorg-14-init~1089 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bad3ebbaae3d5a99c1608f38b1ca597433b89e7c;p=platform%2Fupstream%2Fllvm.git [Polly][Isl] Stop generating isl::union_{set,map} from isl::space. NFC This is part of an effort to reduce the differences between the custom C++ bindings used right now by polly in `lib/External/isl/include/isl/isl-noxceptions.h` and the official isl C++ interface. Changes made: - Stop generating `isl::union_set` and isl::union_map` from `isl::space` and instead generate them from `isl::ctx` - Disable clang-format on `isl-noexceptions.h` - Removed `isl::union_{set,map}` generator from `isl::space` from `isl-noexceptions.h` - `isl-noexceptions.h` has been generated by this https://github.com/patacca/isl/commit/87c3413b6f1d62ca3dddf716352f90a0b8533353 Reviewed By: Meinersbur Differential Revision: https://reviews.llvm.org/D106059 --- diff --git a/polly/lib/Analysis/DependenceInfo.cpp b/polly/lib/Analysis/DependenceInfo.cpp index fc3c7a4..73ec706 100644 --- a/polly/lib/Analysis/DependenceInfo.cpp +++ b/polly/lib/Analysis/DependenceInfo.cpp @@ -642,8 +642,7 @@ bool Dependences::isValidSchedule( return true; isl::union_map Dependences = getDependences(TYPE_RAW | TYPE_WAW | TYPE_WAR); - isl::space Space = S.getParamSpace(); - isl::union_map Schedule = isl::union_map::empty(Space); + isl::union_map Schedule = isl::union_map::empty(S.getIslCtx()); isl::space ScheduleSpace; @@ -778,7 +777,7 @@ void Dependences::releaseMemory() { isl::union_map Dependences::getDependences(int Kinds) const { assert(hasValidDependences() && "No valid dependences available"); isl::space Space = isl::manage_copy(RAW).get_space(); - isl::union_map Deps = Deps.empty(Space); + isl::union_map Deps = Deps.empty(Space.ctx()); if (Kinds & TYPE_RAW) Deps = Deps.unite(isl::manage_copy(RAW)); diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp index 012a793..84316ea 100644 --- a/polly/lib/Analysis/ScopBuilder.cpp +++ b/polly/lib/Analysis/ScopBuilder.cpp @@ -3366,7 +3366,7 @@ bool ScopBuilder::calculateMinMaxAccess(AliasGroupTy AliasGroup, MinMaxAccesses.reserve(AliasGroup.size()); isl::union_set Domains = scop->getDomains(); - isl::union_map Accesses = isl::union_map::empty(scop->getParamSpace()); + isl::union_map Accesses = isl::union_map::empty(scop->getIslCtx()); for (MemoryAccess *MA : AliasGroup) Accesses = Accesses.add_map(MA->getAccessRelation()); diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index 2839f3f..728b8af 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -2314,7 +2314,7 @@ isl::pw_aff Scop::getPwAffOnly(const SCEV *E, BasicBlock *BB, isl::union_map Scop::getAccessesOfType(std::function Predicate) { - isl::union_map Accesses = isl::union_map::empty(getParamSpace()); + isl::union_map Accesses = isl::union_map::empty(getIslCtx()); for (ScopStmt &Stmt : *this) { for (MemoryAccess *MA : Stmt) { diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp index 77886f1..aaa365c 100644 --- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp +++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp @@ -219,8 +219,8 @@ static MustKillsInfo computeMustKillsInfo(const Scop &S) { KillMemIds.push_back(isl::manage(SAI->getBasePtrId().release())); } - Info.TaggedMustKills = isl::union_map::empty(ParamSpace); - Info.MustKills = isl::union_map::empty(ParamSpace); + Info.TaggedMustKills = isl::union_map::empty(ParamSpace.ctx()); + Info.MustKills = isl::union_map::empty(ParamSpace.ctx()); // Initialising KillsSchedule to `isl_set_empty` creates an empty node in the // schedule: diff --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp index 348778e..4ef0101 100644 --- a/polly/lib/Exchange/JSONExporter.cpp +++ b/polly/lib/Exchange/JSONExporter.cpp @@ -321,7 +321,7 @@ static bool importSchedule(Scop &S, const json::Object &JScop, return false; } - auto ScheduleMap = isl::union_map::empty(S.getParamSpace()); + auto ScheduleMap = isl::union_map::empty(S.getIslCtx()); for (ScopStmt &Stmt : S) { if (NewSchedule.find(&Stmt) != NewSchedule.end()) ScheduleMap = ScheduleMap.add_map(NewSchedule[&Stmt]); diff --git a/polly/lib/External/isl/include/isl/isl-noexceptions.h b/polly/lib/External/isl/include/isl/isl-noexceptions.h index 4fcf4ff..fcccf09 100644 --- a/polly/lib/External/isl/include/isl/isl-noexceptions.h +++ b/polly/lib/External/isl/include/isl/isl-noexceptions.h @@ -5,6 +5,8 @@ /// polyhedral compilation, ranging from dependence analysis over scheduling /// to AST generation. +// clang-format off + #ifndef ISL_CPP_CHECKED #define ISL_CPP_CHECKED @@ -3228,9 +3230,7 @@ public: inline isl::union_map domain_map() const; inline isl::union_pw_multi_aff domain_map_union_pw_multi_aff() const; inline isl::union_map domain_product(isl::union_map umap2) const; - static inline isl::union_map empty(isl::space space); static inline isl::union_map empty(isl::ctx ctx); - static inline isl::union_map empty_space(isl::space space); inline isl::union_map eq_at(isl::multi_union_pw_aff mupa) const; inline isl::map extract_map(isl::space space) const; inline isl::union_map factor_domain() const; @@ -3708,9 +3708,7 @@ public: inline boolean contains(const isl::space &space) const; inline isl::union_set detect_equalities() const; inline isl_size dim(isl::dim type) const; - static inline isl::union_set empty(isl::space space); static inline isl::union_set empty(isl::ctx ctx); - static inline isl::union_set empty_space(isl::space space); inline isl::set extract_set(isl::space space) const; inline stat foreach_point(const std::function &fn) const; inline stat foreach_set(const std::function &fn) const; @@ -17579,24 +17577,12 @@ isl::union_map union_map::domain_product(isl::union_map umap2) const return manage(res); } -isl::union_map union_map::empty(isl::space space) -{ - auto res = isl_union_map_empty(space.release()); - return manage(res); -} - isl::union_map union_map::empty(isl::ctx ctx) { auto res = isl_union_map_empty_ctx(ctx.release()); return manage(res); } -isl::union_map union_map::empty_space(isl::space space) -{ - auto res = isl_union_map_empty_space(space.release()); - return manage(res); -} - isl::union_map union_map::eq_at(isl::multi_union_pw_aff mupa) const { auto res = isl_union_map_eq_at_multi_union_pw_aff(copy(), mupa.release()); @@ -19793,24 +19779,12 @@ isl_size union_set::dim(isl::dim type) const return res; } -isl::union_set union_set::empty(isl::space space) -{ - auto res = isl_union_set_empty(space.release()); - return manage(res); -} - isl::union_set union_set::empty(isl::ctx ctx) { auto res = isl_union_set_empty_ctx(ctx.release()); return manage(res); } -isl::union_set union_set::empty_space(isl::space space) -{ - auto res = isl_union_set_empty_space(space.release()); - return manage(res); -} - isl::set union_set::extract_set(isl::space space) const { auto res = isl_union_set_extract_set(get(), space.release()); diff --git a/polly/lib/Support/ISLTools.cpp b/polly/lib/Support/ISLTools.cpp index 8ab18a2..1b18282 100644 --- a/polly/lib/Support/ISLTools.cpp +++ b/polly/lib/Support/ISLTools.cpp @@ -90,7 +90,7 @@ isl::map polly::beforeScatter(isl::map Map, bool Strict) { } isl::union_map polly::beforeScatter(isl::union_map UMap, bool Strict) { - isl::union_map Result = isl::union_map::empty(UMap.get_space()); + isl::union_map Result = isl::union_map::empty(UMap.ctx()); for (isl::map Map : UMap.get_map_list()) { isl::map After = beforeScatter(Map, Strict); @@ -108,7 +108,7 @@ isl::map polly::afterScatter(isl::map Map, bool Strict) { } isl::union_map polly::afterScatter(const isl::union_map &UMap, bool Strict) { - isl::union_map Result = isl::union_map::empty(UMap.get_space()); + isl::union_map Result = isl::union_map::empty(UMap.ctx()); for (isl::map Map : UMap.get_map_list()) { isl::map After = afterScatter(Map, Strict); Result = Result.add_map(After); @@ -188,7 +188,7 @@ isl::map polly::makeIdentityMap(const isl::set &Set, bool RestrictDomain) { isl::union_map polly::makeIdentityMap(const isl::union_set &USet, bool RestrictDomain) { - isl::union_map Result = isl::union_map::empty(USet.get_space()); + isl::union_map Result = isl::union_map::empty(USet.ctx()); for (isl::set Set : USet.get_set_list()) { isl::map IdentityMap = makeIdentityMap(Set, RestrictDomain); Result = Result.add_map(IdentityMap); @@ -205,7 +205,7 @@ isl::map polly::reverseDomain(isl::map Map) { } isl::union_map polly::reverseDomain(const isl::union_map &UMap) { - isl::union_map Result = isl::union_map::empty(UMap.get_space()); + isl::union_map Result = isl::union_map::empty(UMap.ctx()); for (isl::map Map : UMap.get_map_list()) { auto Reversed = reverseDomain(std::move(Map)); Result = Result.add_map(Reversed); @@ -226,7 +226,7 @@ isl::set polly::shiftDim(isl::set Set, int Pos, int Amount) { } isl::union_set polly::shiftDim(isl::union_set USet, int Pos, int Amount) { - isl::union_set Result = isl::union_set::empty(USet.get_space()); + isl::union_set Result = isl::union_set::empty(USet.ctx()); for (isl::set Set : USet.get_set_list()) { isl::set Shifted = shiftDim(Set, Pos, Amount); Result = Result.unite(Shifted); @@ -265,7 +265,7 @@ isl::map polly::shiftDim(isl::map Map, isl::dim Dim, int Pos, int Amount) { isl::union_map polly::shiftDim(isl::union_map UMap, isl::dim Dim, int Pos, int Amount) { - isl::union_map Result = isl::union_map::empty(UMap.get_space()); + isl::union_map Result = isl::union_map::empty(UMap.ctx()); for (isl::map Map : UMap.get_map_list()) { isl::map Shifted = shiftDim(Map, Dim, Pos, Amount); @@ -486,7 +486,7 @@ isl::map polly::distributeDomain(isl::map Map) { } isl::union_map polly::distributeDomain(isl::union_map UMap) { - isl::union_map Result = isl::union_map::empty(UMap.get_space()); + isl::union_map Result = isl::union_map::empty(UMap.ctx()); for (isl::map Map : UMap.get_map_list()) { auto Distributed = distributeDomain(Map); Result = Result.add_map(Distributed); @@ -824,7 +824,7 @@ static isl::set expand(const isl::set &Set) { /// /// @see expand(const isl::set) static isl::union_set expand(const isl::union_set &USet) { - isl::union_set Expanded = isl::union_set::empty(USet.get_space()); + isl::union_set Expanded = isl::union_set::empty(USet.ctx()); for (isl::set Set : USet.get_set_list()) { isl::set SetExpanded = expand(Set); Expanded = Expanded.unite(SetExpanded); diff --git a/polly/lib/Transform/DeLICM.cpp b/polly/lib/Transform/DeLICM.cpp index d96d4b2..d5a54cd 100644 --- a/polly/lib/Transform/DeLICM.cpp +++ b/polly/lib/Transform/DeLICM.cpp @@ -882,7 +882,7 @@ private: simplify(WritesTarget); // { DomainWrite[] } - auto UniverseWritesDom = isl::union_set::empty(ParamSpace); + auto UniverseWritesDom = isl::union_set::empty(ParamSpace.ctx()); for (auto *MA : S->getPHIIncomings(SAI)) UniverseWritesDom = UniverseWritesDom.unite(getDomainFor(MA)); diff --git a/polly/lib/Transform/FlattenAlgo.cpp b/polly/lib/Transform/FlattenAlgo.cpp index b1aa362..de70a98 100644 --- a/polly/lib/Transform/FlattenAlgo.cpp +++ b/polly/lib/Transform/FlattenAlgo.cpp @@ -116,7 +116,7 @@ isl::union_map scheduleProjectOut(const isl::union_map &UMap, unsigned first, return UMap; /* isl_map_project_out would also reset the tuple, which should have no effect on schedule ranges */ - auto Result = isl::union_map::empty(UMap.get_space()); + auto Result = isl::union_map::empty(UMap.ctx()); for (isl::map Map : UMap.get_map_list()) { auto Outprojected = Map.project_out(isl::dim::out, first, n); Result = Result.add_map(Outprojected); @@ -142,7 +142,7 @@ isl_size scheduleScatterDims(const isl::union_map &Schedule) { /// Return the @p pos' range dimension, converted to an isl_union_pw_aff. isl::union_pw_aff scheduleExtractDimAff(isl::union_map UMap, unsigned pos) { - auto SingleUMap = isl::union_map::empty(UMap.get_space()); + auto SingleUMap = isl::union_map::empty(UMap.ctx()); for (isl::map Map : UMap.get_map_list()) { unsigned MapDims = Map.range_tuple_dim(); isl::map SingleMap = Map.project_out(isl::dim::out, 0, pos); @@ -191,7 +191,7 @@ isl::union_map tryFlattenSequence(isl::union_map Schedule) { auto AllDomains = Schedule.domain(); auto AllDomainsToNull = isl::union_pw_multi_aff(AllDomains); - auto NewSchedule = isl::union_map::empty(ParamSpace); + auto NewSchedule = isl::union_map::empty(ParamSpace.ctx()); auto Counter = isl::pw_aff(isl::local_space(ParamSpace.set_from_params())); while (!ScatterSet.is_empty()) { diff --git a/polly/lib/Transform/MaximalStaticExpansion.cpp b/polly/lib/Transform/MaximalStaticExpansion.cpp index 5ca4b52..a4800ad 100644 --- a/polly/lib/Transform/MaximalStaticExpansion.cpp +++ b/polly/lib/Transform/MaximalStaticExpansion.cpp @@ -136,7 +136,7 @@ isl::union_map MaximalStaticExpander::filterDependences( auto AccessDomainSet = MA->getAccessRelation().domain(); auto AccessDomainId = AccessDomainSet.get_tuple_id(); - isl::union_map MapDependences = isl::union_map::empty(S.getParamSpace()); + isl::union_map MapDependences = isl::union_map::empty(S.getIslCtx()); for (isl::map Map : Dependences.get_map_list()) { // Filter out Statement to Statement dependences. @@ -184,7 +184,7 @@ bool MaximalStaticExpander::isExpandable( auto Writes = S.getPHIIncomings(SAI); // Get the domain where all the writes are writing to. - auto WriteDomain = isl::union_set::empty(S.getParamSpace()); + auto WriteDomain = isl::union_set::empty(S.getIslCtx()); for (auto Write : Writes) { auto MapDeps = filterDependences(S, Dependences, Write); @@ -209,8 +209,8 @@ bool MaximalStaticExpander::isExpandable( int NumberWrites = 0; for (ScopStmt &Stmt : S) { - auto StmtReads = isl::union_map::empty(S.getParamSpace()); - auto StmtWrites = isl::union_map::empty(S.getParamSpace()); + auto StmtReads = isl::union_map::empty(S.getIslCtx()); + auto StmtWrites = isl::union_map::empty(S.getIslCtx()); for (MemoryAccess *MA : Stmt) { // Check if the current MemoryAccess involved the current SAI. diff --git a/polly/lib/Transform/ScheduleTreeTransform.cpp b/polly/lib/Transform/ScheduleTreeTransform.cpp index b98c0c0..537e889 100644 --- a/polly/lib/Transform/ScheduleTreeTransform.cpp +++ b/polly/lib/Transform/ScheduleTreeTransform.cpp @@ -217,8 +217,7 @@ struct ExtensionNodeRewriter isl::schedule visitLeaf(const isl::schedule_node &Leaf, const isl::union_set &Domain, isl::union_map &Extensions) { - isl::ctx Ctx = Leaf.ctx(); - Extensions = isl::union_map::empty(isl::space::params_alloc(Ctx, 0)); + Extensions = isl::union_map::empty(Leaf.ctx()); return isl::schedule::from_domain(Domain); } @@ -233,7 +232,7 @@ struct ExtensionNodeRewriter isl::schedule NewChild = visit(OldChild, Domain, NewChildExtensions); // Add the extensions to the partial schedule. - OuterExtensions = isl::union_map::empty(NewChildExtensions.get_space()); + OuterExtensions = isl::union_map::empty(NewChildExtensions.ctx()); isl::union_map NewPartialSchedMap = isl::union_map::from(PartialSched); unsigned BandDims = isl_schedule_node_band_n_member(OldNode.get()); for (isl::map Ext : NewChildExtensions.get_map_list()) { diff --git a/polly/lib/Transform/Simplify.cpp b/polly/lib/Transform/Simplify.cpp index 47ccaaf..01d2a1e 100644 --- a/polly/lib/Transform/Simplify.cpp +++ b/polly/lib/Transform/Simplify.cpp @@ -248,8 +248,7 @@ void SimplifyImpl::removeEmptyDomainStmts() { void SimplifyImpl::removeOverwrites() { for (auto &Stmt : *S) { isl::set Domain = Stmt.getDomain(); - isl::union_map WillBeOverwritten = - isl::union_map::empty(S->getParamSpace()); + isl::union_map WillBeOverwritten = isl::union_map::empty(S->getIslCtx()); SmallVector Accesses(getAccessesInOrder(Stmt)); @@ -330,7 +329,7 @@ void SimplifyImpl::coalesceWrites() { // List of all eligible (for coalescing) writes of the future. // { [Domain[] -> Element[]] -> [Value[] -> MemoryAccess[]] } - isl::union_map FutureWrites = isl::union_map::empty(S->getParamSpace()); + isl::union_map FutureWrites = isl::union_map::empty(S->getIslCtx()); // Iterate over accesses from the last to the first. SmallVector Accesses(getAccessesInOrder(Stmt)); @@ -444,7 +443,7 @@ void SimplifyImpl::coalesceWrites() { TouchedAccesses.insert(MA); } isl::union_map NewFutureWrites = - isl::union_map::empty(FutureWrites.get_space()); + isl::union_map::empty(FutureWrites.ctx()); for (isl::map FutureWrite : FutureWrites.get_map_list()) { MemoryAccess *MA = (MemoryAccess *)FutureWrite.get_space() .range() @@ -499,7 +498,7 @@ void SimplifyImpl::removeRedundantWrites() { // List of element reads that still have the same value while iterating // through the MemoryAccesses. // { [Domain[] -> Element[]] -> Val[] } - isl::union_map Known = isl::union_map::empty(S->getParamSpace()); + isl::union_map Known = isl::union_map::empty(S->getIslCtx()); SmallVector Accesses(getAccessesInOrder(Stmt)); for (MemoryAccess *MA : Accesses) { diff --git a/polly/lib/Transform/ZoneAlgo.cpp b/polly/lib/Transform/ZoneAlgo.cpp index 78b9e7c..77d564a 100644 --- a/polly/lib/Transform/ZoneAlgo.cpp +++ b/polly/lib/Transform/ZoneAlgo.cpp @@ -250,7 +250,7 @@ static bool isMapToUnknown(const isl::map &Map) { } isl::union_map polly::filterKnownValInst(const isl::union_map &UMap) { - isl::union_map Result = isl::union_map::empty(UMap.get_space()); + isl::union_map Result = isl::union_map::empty(UMap.ctx()); for (isl::map Map : UMap.get_map_list()) { if (!isMapToUnknown(Map)) Result = Result.add_map(Map); @@ -587,11 +587,11 @@ isl::union_map ZoneAlgorithm::computePerPHI(const ScopArrayInfo *SAI) { } isl::union_set ZoneAlgorithm::makeEmptyUnionSet() const { - return isl::union_set::empty(ParamSpace); + return isl::union_set::empty(ParamSpace.ctx()); } isl::union_map ZoneAlgorithm::makeEmptyUnionMap() const { - return isl::union_map::empty(ParamSpace); + return isl::union_map::empty(ParamSpace.ctx()); } void ZoneAlgorithm::collectCompatibleElts() { @@ -845,7 +845,7 @@ isl::map ZoneAlgorithm::makeValInst(Value *Val, ScopStmt *UserStmt, Loop *Scope, static isl::union_map normalizeValInst(isl::union_map Input, const DenseSet &ComputedPHIs, isl::union_map NormalizeMap) { - isl::union_map Result = isl::union_map::empty(Input.get_space()); + isl::union_map Result = isl::union_map::empty(Input.ctx()); for (isl::map Map : Input.get_map_list()) { isl::space Space = Map.get_space(); isl::space RangeSpace = Space.range(); diff --git a/polly/unittests/DeLICM/DeLICMTest.cpp b/polly/unittests/DeLICM/DeLICMTest.cpp index 34a7306..b11b146 100644 --- a/polly/unittests/DeLICM/DeLICMTest.cpp +++ b/polly/unittests/DeLICM/DeLICMTest.cpp @@ -23,7 +23,7 @@ namespace { /// Get the universes of all spaces in @p USet. isl::union_set unionSpace(const isl::union_set &USet) { - auto Result = isl::union_set::empty(USet.get_space()); + auto Result = isl::union_set::empty(USet.ctx()); for (isl::set Set : USet.get_set_list()) { isl::space Space = Set.get_space(); isl::set Universe = isl::set::universe(Space); @@ -45,7 +45,7 @@ void completeLifetime(isl::union_set Universe, isl::union_map OccupiedAndKnown, if (!OccupiedAndKnown.is_null()) { assert(Known.is_null()); - Known = isl::union_map::empty(ParamSpace); + Known = isl::union_map::empty(ParamSpace.ctx()); if (Occupied.is_null()) Occupied = OccupiedAndKnown.domain(); @@ -63,7 +63,7 @@ void completeLifetime(isl::union_set Universe, isl::union_map OccupiedAndKnown, } if (Known.is_null()) { // By default, nothing is known. - Known = isl::union_map::empty(ParamSpace); + Known = isl::union_map::empty(ParamSpace.ctx()); } // Conditions that must hold when returning. @@ -96,7 +96,7 @@ bool checkIsConflictingNonsymmetricCommon( isl::union_map ProposedOccupiedAndKnown, isl::union_set ProposedUnused, isl::union_map ProposedWritten) { // Determine universe (set of all possible domains). - auto Universe = isl::union_set::empty(isl::space::params_alloc(Ctx, 0)); + auto Universe = isl::union_set::empty(Ctx); if (!ExistingOccupiedAndKnown.is_null()) Universe = Universe.unite(ExistingOccupiedAndKnown.domain()); if (!ExistingUnused.is_null())