isl scheduler: Do not fail when returning an empty band list
authorTobias Grosser <grosser@fim.uni-passau.de>
Tue, 16 Oct 2012 07:29:19 +0000 (07:29 +0000)
committerTobias Grosser <grosser@fim.uni-passau.de>
Tue, 16 Oct 2012 07:29:19 +0000 (07:29 +0000)
The bug was within isl. To fix it, we simply update the isl version that
is used by Polly. We still have some changes within Polly to be able to
write a proper test case.

Reported-by: Sameer Sahasrabuddhe <Sameer.Sahasrabuddhe@amd.com>
llvm-svn: 166021

polly/lib/ScheduleOptimizer.cpp
polly/test/ScheduleOptimizer/2012-10-14-Zero-Bands.ll [new file with mode: 0644]
polly/utils/checkout_cloog.sh

index 3d8e28f..266ec90 100644 (file)
@@ -83,13 +83,21 @@ namespace {
 
   public:
     static char ID;
-    explicit IslScheduleOptimizer() : ScopPass(ID) {}
+    explicit IslScheduleOptimizer() : ScopPass(ID) {
+      LastSchedule = NULL;
+    }
+
+    ~IslScheduleOptimizer() {
+      isl_schedule_free(LastSchedule);
+    }
 
     virtual bool runOnScop(Scop &S);
     void printScop(llvm::raw_ostream &OS) const;
     void getAnalysisUsage(AnalysisUsage &AU) const;
 
   private:
+    isl_schedule *LastSchedule;
+
     static void extendScattering(Scop &S, unsigned NewDimensions);
 
     /// @brief Create a map that describes a n-dimensonal tiling.
@@ -179,6 +187,12 @@ namespace {
     static isl_union_map *getScheduleForBandList(isl_band_list *BandList);
 
     static isl_union_map *getScheduleMap(isl_schedule *Schedule);
+
+    bool doFinalization() {
+      isl_schedule_free(LastSchedule);
+      LastSchedule = NULL;
+      return true;
+    }
   };
 
 }
@@ -437,6 +451,9 @@ isl_union_map *IslScheduleOptimizer::getScheduleMap(isl_schedule *Schedule) {
 bool IslScheduleOptimizer::runOnScop(Scop &S) {
   Dependences *D = &getAnalysis<Dependences>();
 
+  isl_schedule_free(LastSchedule);
+  LastSchedule = NULL;
+
   // Build input data.
   int ValidityKinds = Dependences::TYPE_RAW | Dependences::TYPE_WAR
                       | Dependences::TYPE_WAW;
@@ -452,10 +469,8 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) {
         << " Falling back to optimizing all dependences.\n";
     ProximityKinds = Dependences::TYPE_RAW | Dependences::TYPE_WAR
                      | Dependences::TYPE_WAW;
-
   }
 
-
   isl_union_set *Domain = S.getDomains();
 
   if (!Domain)
@@ -546,7 +561,7 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) {
   }
 
   isl_union_map_free(ScheduleMap);
-  isl_schedule_free(Schedule);
+  LastSchedule = Schedule;
 
   unsigned MaxScatDims = 0;
 
@@ -558,6 +573,22 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) {
 }
 
 void IslScheduleOptimizer::printScop(raw_ostream &OS) const {
+  isl_printer *p;
+  char *ScheduleStr;
+
+  OS << "Calculated schedule:\n";
+
+  if (!LastSchedule) {
+    OS << "n/a\n";
+    return;
+  }
+
+  p = isl_printer_to_str(isl_schedule_get_ctx(LastSchedule));
+  p = isl_printer_print_schedule(p, LastSchedule);
+  ScheduleStr = isl_printer_get_str(p);
+  isl_printer_free(p);
+
+  OS << ScheduleStr << "\n";
 }
 
 void IslScheduleOptimizer::getAnalysisUsage(AnalysisUsage &AU) const {
diff --git a/polly/test/ScheduleOptimizer/2012-10-14-Zero-Bands.ll b/polly/test/ScheduleOptimizer/2012-10-14-Zero-Bands.ll
new file mode 100644 (file)
index 0000000..5859b7e
--- /dev/null
@@ -0,0 +1,27 @@
+; RUN: opt %loadPolly -polly-region-simplify -polly-opt-isl -analyze < %s | FileCheck %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@A = common global [1536 x float] zeroinitializer
+
+define void @read_nres() {
+entry:
+  br label %if.cond
+
+if.cond:
+  br i1 false, label %if.then, label %if.end
+
+if.then:
+  %ptr = getelementptr [1536 x float]* @A, i64 0, i32 23
+  store float undef, float* %ptr
+  br label %if.end
+
+if.end:
+  br label %return
+
+return:
+  ret void
+}
+
+; CHECK: Calculated schedule:
+; CHECK: { Stmt_if_then[] -> [] }
index 31d87af..971c027 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 CLOOG_HASH="57470e76bfd58a0c38c598e816411663193e0f45"
-ISL_HASH="14beb7bfa687199d1a515889fbc2459d5f6d235b"
+ISL_HASH="cc969a737d4f8de258a462c3cb1c063fe2f1c5cf"
 
 PWD=`pwd`