[polly] r339484 - [DepInfo] Use isl++ in Dependences::isValidSchedule. NFC.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 10 15:33:27 PDT 2018


Author: meinersbur
Date: Fri Aug 10 15:33:27 2018
New Revision: 339484

URL: http://llvm.org/viewvc/llvm-project?rev=339484&view=rev
Log:
[DepInfo] Use isl++ in Dependences::isValidSchedule. NFC.

Also change StatementToIslMapTy to hold isl::map, because it is used as a
parameter.

Modified:
    polly/trunk/include/polly/DependenceInfo.h
    polly/trunk/lib/Analysis/DependenceInfo.cpp
    polly/trunk/lib/Exchange/JSONExporter.cpp

Modified: polly/trunk/include/polly/DependenceInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/DependenceInfo.h?rev=339484&r1=339483&r2=339484&view=diff
==============================================================================
--- polly/trunk/include/polly/DependenceInfo.h (original)
+++ polly/trunk/include/polly/DependenceInfo.h Fri Aug 10 15:33:27 2018
@@ -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;

Modified: polly/trunk/lib/Analysis/DependenceInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/DependenceInfo.cpp?rev=339484&r1=339483&r2=339484&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/DependenceInfo.cpp (original)
+++ polly/trunk/lib/Analysis/DependenceInfo.cpp Fri Aug 10 15:33:27 2018
@@ -735,51 +735,46 @@ void Dependences::calculateDependences(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);
-
-  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_map *NonPositive = isl_set_lex_le_set(Deltas, Zero);
-  bool IsValid = isl_map_is_empty(NonPositive);
-  isl_map_free(NonPositive);
+  Dependences = Dependences.apply_domain(Schedule);
+  Dependences = Dependences.apply_range(Schedule);
 
-  return IsValid;
+  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::union_set UDeltas = Dependences.deltas();
+  isl::set Deltas = singleton(UDeltas, ScheduleSpace);
+
+  isl::map NonPositive = Deltas.lex_le_set(Zero);
+  return NonPositive.is_empty();
 }
 
 // Check if the current scheduling dimension is parallel.

Modified: polly/trunk/lib/Exchange/JSONExporter.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=339484&r1=339483&r2=339484&view=diff
==============================================================================
--- polly/trunk/lib/Exchange/JSONExporter.cpp (original)
+++ polly/trunk/lib/Exchange/JSONExporter.cpp Fri Aug 10 15:33:27 2018
@@ -288,9 +288,6 @@ static bool importSchedule(Scop &S, cons
     // 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, cons
     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, cons
       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());
   }




More information about the llvm-commits mailing list