diff options
author | Michael Kruse <llvm@meinersbur.de> | 2018-08-10 22:33:27 +0000 |
---|---|---|
committer | Michael Kruse <llvm@meinersbur.de> | 2018-08-10 22:33:27 +0000 |
commit | 0e4e6e5e87a7829cabb9fa6fc1a6cbefe2663d56 (patch) | |
tree | 8a8dbabd9899c61bb72ca32ea933a8a8bb82dc3c | |
parent | 25f1f7325feac42b3bf05fd408e15b6a6be7d81c (diff) | |
download | bcm5719-llvm-0e4e6e5e87a7829cabb9fa6fc1a6cbefe2663d56.tar.gz bcm5719-llvm-0e4e6e5e87a7829cabb9fa6fc1a6cbefe2663d56.zip |
[DepInfo] Use isl++ in Dependences::isValidSchedule. NFC.
Also change StatementToIslMapTy to hold isl::map, because it is used as a
parameter.
llvm-svn: 339484
-rw-r--r-- | polly/include/polly/DependenceInfo.h | 5 | ||||
-rw-r--r-- | polly/lib/Analysis/DependenceInfo.cpp | 51 | ||||
-rw-r--r-- | polly/lib/Exchange/JSONExporter.cpp | 14 |
3 files changed, 29 insertions, 41 deletions
diff --git a/polly/include/polly/DependenceInfo.h b/polly/include/polly/DependenceInfo.h index 64f749fa177..59ae2aaa43b 100644 --- a/polly/include/polly/DependenceInfo.h +++ b/polly/include/polly/DependenceInfo.h @@ -25,6 +25,7 @@ #include "polly/ScopPass.h" #include "isl/ctx.h" +#include "isl/isl-noexceptions.h" struct isl_pw_aff; struct isl_union_map; @@ -62,7 +63,7 @@ struct Dependences { using ReductionDependencesMapTy = DenseMap<MemoryAccess *, isl_map *>; /// Map type to associate statements with schedules. - using StatementToIslMapTy = DenseMap<ScopStmt *, isl_map *>; + using StatementToIslMapTy = DenseMap<ScopStmt *, isl::map>; /// The type of the dependences. /// @@ -135,7 +136,7 @@ struct Dependences { /// /// @return True if the new schedule is valid, false if it reverses /// dependences. - bool isValidSchedule(Scop &S, StatementToIslMapTy *NewSchedules) const; + bool isValidSchedule(Scop &S, const StatementToIslMapTy &NewSchedules) const; /// Print the stored dependence information. void print(llvm::raw_ostream &OS) const; diff --git a/polly/lib/Analysis/DependenceInfo.cpp b/polly/lib/Analysis/DependenceInfo.cpp index b58db9a7f92..cec3fe2e8c1 100644 --- a/polly/lib/Analysis/DependenceInfo.cpp +++ b/polly/lib/Analysis/DependenceInfo.cpp @@ -735,51 +735,46 @@ void Dependences::calculateDependences(Scop &S) { LLVM_DEBUG(dump()); } -bool Dependences::isValidSchedule(Scop &S, - StatementToIslMapTy *NewSchedule) const { +bool Dependences::isValidSchedule( + Scop &S, const StatementToIslMapTy &NewSchedule) const { if (LegalityCheckDisabled) return true; - isl_union_map *Dependences = - (getDependences(TYPE_RAW | TYPE_WAW | TYPE_WAR)).release(); - isl_space *Space = S.getParamSpace().release(); - isl_union_map *Schedule = isl_union_map_empty(Space); + 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_space *ScheduleSpace = nullptr; + isl::space ScheduleSpace; for (ScopStmt &Stmt : S) { - isl_map *StmtScat; + isl::map StmtScat; - if (NewSchedule->find(&Stmt) == NewSchedule->end()) - StmtScat = Stmt.getSchedule().release(); + auto Lookup = NewSchedule.find(&Stmt); + if (Lookup == NewSchedule.end()) + StmtScat = Stmt.getSchedule(); else - StmtScat = isl_map_copy((*NewSchedule)[&Stmt]); - assert(StmtScat && + StmtScat = Lookup->second; + assert(!StmtScat.is_null() && "Schedules that contain extension nodes require special handling."); if (!ScheduleSpace) - ScheduleSpace = isl_space_range(isl_map_get_space(StmtScat)); + ScheduleSpace = StmtScat.get_space().range(); - Schedule = isl_union_map_add_map(Schedule, StmtScat); + Schedule = Schedule.add_map(StmtScat); } - Dependences = - isl_union_map_apply_domain(Dependences, isl_union_map_copy(Schedule)); - Dependences = isl_union_map_apply_range(Dependences, Schedule); - - isl_set *Zero = isl_set_universe(isl_space_copy(ScheduleSpace)); - for (unsigned i = 0; i < isl_set_dim(Zero, isl_dim_set); i++) - Zero = isl_set_fix_si(Zero, isl_dim_set, i, 0); + Dependences = Dependences.apply_domain(Schedule); + Dependences = Dependences.apply_range(Schedule); - isl_union_set *UDeltas = isl_union_map_deltas(Dependences); - isl_set *Deltas = isl_union_set_extract_set(UDeltas, ScheduleSpace); - isl_union_set_free(UDeltas); + isl::set Zero = isl::set::universe(ScheduleSpace); + for (unsigned i = 0; i < Zero.dim(isl::dim::set); i++) + Zero = Zero.fix_si(isl::dim::set, i, 0); - isl_map *NonPositive = isl_set_lex_le_set(Deltas, Zero); - bool IsValid = isl_map_is_empty(NonPositive); - isl_map_free(NonPositive); + isl::union_set UDeltas = Dependences.deltas(); + isl::set Deltas = singleton(UDeltas, ScheduleSpace); - return IsValid; + isl::map NonPositive = Deltas.lex_le_set(Zero); + return NonPositive.is_empty(); } // Check if the current scheduling dimension is parallel. diff --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp index 0a744901e2b..41975396efa 100644 --- a/polly/lib/Exchange/JSONExporter.cpp +++ b/polly/lib/Exchange/JSONExporter.cpp @@ -288,9 +288,6 @@ static bool importSchedule(Scop &S, const json::Object &JScop, // Check if key 'schedule' is present. if (!statements[Index].getAsObject()->get("schedule")) { errs() << "Statement " << Index << " has no 'schedule' key.\n"; - for (auto Element : NewSchedule) { - isl_map_free(Element.second); - } return false; } Optional<StringRef> Schedule = @@ -304,9 +301,6 @@ static bool importSchedule(Scop &S, const json::Object &JScop, if (!Map) { errs() << "The schedule was not parsed successfully (index = " << Index << ").\n"; - for (auto Element : NewSchedule) { - isl_map_free(Element.second); - } return false; } @@ -321,23 +315,21 @@ static bool importSchedule(Scop &S, const json::Object &JScop, Map = isl_map_set_dim_id(Map, isl_dim_param, i, Id); } isl_space_free(Space); - NewSchedule[&Stmt] = Map; + NewSchedule[&Stmt] = isl::manage(Map); Index++; } // Check whether the new schedule is valid or not. - if (!D.isValidSchedule(S, &NewSchedule)) { + if (!D.isValidSchedule(S, NewSchedule)) { errs() << "JScop file contains a schedule that changes the " << "dependences. Use -disable-polly-legality to continue anyways\n"; - for (auto Element : NewSchedule) - isl_map_free(Element.second); return false; } auto ScheduleMap = isl::union_map::empty(S.getParamSpace()); for (ScopStmt &Stmt : S) { if (NewSchedule.find(&Stmt) != NewSchedule.end()) - ScheduleMap = ScheduleMap.add_map(isl::manage(NewSchedule[&Stmt])); + ScheduleMap = ScheduleMap.add_map(NewSchedule[&Stmt]); else ScheduleMap = ScheduleMap.add_map(Stmt.getSchedule()); } |