diff --git a/polly/include/polly/CodeGen/IslNodeBuilder.h b/polly/include/polly/CodeGen/IslNodeBuilder.h --- a/polly/include/polly/CodeGen/IslNodeBuilder.h +++ b/polly/include/polly/CodeGen/IslNodeBuilder.h @@ -368,9 +368,9 @@ /// that counts the number of times a loop is executed. For each /// original loop this count, expressed in function of the new /// induction variables, is added to the LTS map. - void createSubstitutions(isl::ast_expr Expr, ScopStmt *Stmt, + void createSubstitutions(__isl_take isl_ast_expr *Expr, ScopStmt *Stmt, LoopToScevMapT <S); - void createSubstitutionsVector(isl::ast_expr Expr, ScopStmt *Stmt, + void createSubstitutionsVector(__isl_take isl_ast_expr *Expr, ScopStmt *Stmt, std::vector &VLTS, std::vector &IVS, __isl_take isl_id *IteratorID); diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp --- a/polly/lib/CodeGen/IslNodeBuilder.cpp +++ b/polly/lib/CodeGen/IslNodeBuilder.cpp @@ -408,7 +408,7 @@ isl_map *S = isl_map_from_union_map(Schedule); auto *NewAccesses = createNewAccesses(Stmt, User); - createSubstitutionsVector(isl::manage(Expr), Stmt, VLTS, IVS, IteratorID); + createSubstitutionsVector(Expr, Stmt, VLTS, IVS, IteratorID); VectorBlockGenerator::generate(BlockGen, *Stmt, VLTS, S, NewAccesses); isl_id_to_ast_expr_free(NewAccesses); isl_map_free(S); @@ -927,35 +927,41 @@ return NewAccesses.release(); } -void IslNodeBuilder::createSubstitutions(isl::ast_expr Expr, ScopStmt *Stmt, - LoopToScevMapT <S) { - assert(isl_ast_expr_get_type(Expr.get()) == isl_ast_expr_op && +void IslNodeBuilder::createSubstitutions(__isl_take isl_ast_expr *Expr, + ScopStmt *Stmt, LoopToScevMapT <S) { + assert(isl_ast_expr_get_type(Expr) == isl_ast_expr_op && "Expression of type 'op' expected"); - assert(isl_ast_expr_get_op_type(Expr.get()) == isl_ast_op_call && + assert(isl_ast_expr_get_op_type(Expr) == isl_ast_op_call && "Operation of type 'call' expected"); - for (int i = 0; i < isl_ast_expr_get_op_n_arg(Expr.get()) - 1; ++i) { + for (int i = 0; i < isl_ast_expr_get_op_n_arg(Expr) - 1; ++i) { + isl_ast_expr *SubExpr; Value *V; - V = ExprBuilder.create(isl_ast_expr_copy(Expr.op_arg(i + 1).get())); + SubExpr = isl_ast_expr_get_op_arg(Expr, i + 1); + V = ExprBuilder.create(SubExpr); ScalarEvolution *SE = Stmt->getParent()->getSE(); LTS[Stmt->getLoopForDimension(i)] = SE->getUnknown(V); } + + isl_ast_expr_free(Expr); } void IslNodeBuilder::createSubstitutionsVector( - isl::ast_expr Expr, ScopStmt *Stmt, std::vector &VLTS, - std::vector &IVS, __isl_take isl_id *IteratorID) { + __isl_take isl_ast_expr *Expr, ScopStmt *Stmt, + std::vector &VLTS, std::vector &IVS, + __isl_take isl_id *IteratorID) { int i = 0; Value *OldValue = IDToValue[IteratorID]; for (Value *IV : IVS) { IDToValue[IteratorID] = IV; - createSubstitutions(Expr, Stmt, VLTS[i]); + createSubstitutions(isl_ast_expr_copy(Expr), Stmt, VLTS[i]); i++; } IDToValue[IteratorID] = OldValue; isl_id_free(IteratorID); + isl_ast_expr_free(Expr); } void IslNodeBuilder::generateCopyStmt( @@ -1005,7 +1011,7 @@ generateCopyStmt(Stmt, NewAccesses); isl_ast_expr_free(Expr); } else { - createSubstitutions(isl::manage(Expr), Stmt, LTS); + createSubstitutions(Expr, Stmt, LTS); if (Stmt->isBlockStmt()) BlockGen.copyStmt(*Stmt, LTS, NewAccesses);