[polly] r187338 - CodeGeneration: Fix double free in vector for

Tobias Grosser tobias at grosser.es
Sun Jul 28 18:58:07 PDT 2013


Author: grosser
Date: Sun Jul 28 20:58:07 2013
New Revision: 187338

URL: http://llvm.org/viewvc/llvm-project?rev=187338&view=rev
Log:
CodeGeneration: Fix double free in vector for

We now use __isl_take to annotate the uses of the isl_set where we got the
memory management wrong.

Thanks to Rafael! His pipefail work hardened our test environment and exposed
this bug nicely.

Modified:
    polly/trunk/lib/CodeGen/CodeGeneration.cpp
    polly/trunk/test/Cloog/CodeGen/simple_vec_two_stmts.ll

Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=187338&r1=187337&r2=187338&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Sun Jul 28 20:58:07 2013
@@ -275,7 +275,8 @@ private:
                             std::vector<LoopToScevMapT> *VLTS = 0);
 
   void codegen(const clast_user_stmt *u, std::vector<Value *> *IVS = NULL,
-               const char *iterator = NULL, isl_set *scatteringDomain = 0);
+               const char *iterator = NULL,
+               __isl_take isl_set *scatteringDomain = 0);
 
   void codegen(const clast_block *b);
 
@@ -417,19 +418,21 @@ void ClastStmtCodeGen::codegenSubstituti
 // PartialSchedule, where the PartialSchedule contains all the dimensions that
 // have been code generated up to this point.
 static __isl_give isl_map *extractPartialSchedule(ScopStmt *Statement,
-                                                  isl_set *Domain) {
+                                                  __isl_take isl_set *Domain) {
   isl_map *Schedule = Statement->getScattering();
   int ScheduledDimensions = isl_set_dim(Domain, isl_dim_set);
   int UnscheduledDimensions =
       isl_map_dim(Schedule, isl_dim_out) - ScheduledDimensions;
 
+  isl_set_free(Domain);
+
   return isl_map_project_out(Schedule, isl_dim_out, ScheduledDimensions,
                              UnscheduledDimensions);
 }
 
 void ClastStmtCodeGen::codegen(const clast_user_stmt *u,
                                std::vector<Value *> *IVS, const char *iterator,
-                               isl_set *Domain) {
+                               __isl_take isl_set *Domain) {
   ScopStmt *Statement = (ScopStmt *)u->statement->usr;
 
   if (u->substitutions)
@@ -819,7 +822,7 @@ void ClastStmtCodeGen::codegenForVector(
   for (int i = 1; i < VectorWidth; i++)
     IVS[i] = Builder.CreateAdd(IVS[i - 1], StrideValue, "p_vector_iv");
 
-  isl_set *Domain = isl_set_from_cloog_domain(F->domain);
+  isl_set *Domain = isl_set_copy(isl_set_from_cloog_domain(F->domain));
 
   // Add loop iv to symbols.
   ClastVars[F->iterator] = LB;
@@ -838,12 +841,12 @@ void ClastStmtCodeGen::codegenForVector(
 }
 
 bool ClastStmtCodeGen::isParallelFor(const clast_for *f) {
-  isl_set *Domain = isl_set_from_cloog_domain(f->domain);
+  isl_set *Domain = isl_set_copy(isl_set_from_cloog_domain(f->domain));
   assert(Domain && "Cannot access domain of loop");
 
   Dependences &D = P->getAnalysis<Dependences>();
 
-  return D.isParallelDimension(isl_set_copy(Domain), isl_set_n_dim(Domain));
+  return D.isParallelDimension(Domain, isl_set_n_dim(Domain));
 }
 
 void ClastStmtCodeGen::codegen(const clast_for *f) {

Modified: polly/trunk/test/Cloog/CodeGen/simple_vec_two_stmts.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Cloog/CodeGen/simple_vec_two_stmts.ll?rev=187338&r1=187337&r2=187338&view=diff
==============================================================================
--- polly/trunk/test/Cloog/CodeGen/simple_vec_two_stmts.ll (original)
+++ polly/trunk/test/Cloog/CodeGen/simple_vec_two_stmts.ll Sun Jul 28 20:58:07 2013
@@ -1,4 +1,4 @@
-; RUN: not --crash opt %loadPolly %defaultOpts -polly-codegen %vector-opt -dce -S < %s | FileCheck %s
+; RUN: opt %loadPolly %defaultOpts -polly-codegen %vector-opt -dce -S < %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"
 target triple = "x86_64-unknown-linux-gnu"
 





More information about the llvm-commits mailing list