diff options
author | Tobias Grosser <tobias@grosser.es> | 2013-07-29 01:58:07 +0000 |
---|---|---|
committer | Tobias Grosser <tobias@grosser.es> | 2013-07-29 01:58:07 +0000 |
commit | 880c52f56a0c461149ac61b5c2e64dcc2b04f4e2 (patch) | |
tree | 3174391b535ca4d2c8e6b80e52a240e34a3a0ba5 | |
parent | c91dd312a44ee2c521caebb60c4ea0cf4a6cc418 (diff) | |
download | bcm5719-llvm-880c52f56a0c461149ac61b5c2e64dcc2b04f4e2.tar.gz bcm5719-llvm-880c52f56a0c461149ac61b5c2e64dcc2b04f4e2.zip |
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.
llvm-svn: 187338
-rw-r--r-- | polly/lib/CodeGen/CodeGeneration.cpp | 15 | ||||
-rw-r--r-- | polly/test/Cloog/CodeGen/simple_vec_two_stmts.ll | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/polly/lib/CodeGen/CodeGeneration.cpp b/polly/lib/CodeGen/CodeGeneration.cpp index 950a06a7053..ec7b11197b8 100644 --- a/polly/lib/CodeGen/CodeGeneration.cpp +++ b/polly/lib/CodeGen/CodeGeneration.cpp @@ -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::codegenSubstitutions(const clast_stmt *Assignment, // 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(const clast_for *F) { 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(const clast_for *F) { } 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) { diff --git a/polly/test/Cloog/CodeGen/simple_vec_two_stmts.ll b/polly/test/Cloog/CodeGen/simple_vec_two_stmts.ll index adf506a2d7a..dbbd6201dd8 100644 --- a/polly/test/Cloog/CodeGen/simple_vec_two_stmts.ll +++ b/polly/test/Cloog/CodeGen/simple_vec_two_stmts.ll @@ -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" |