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_take isl_ast_expr *Expr, ScopStmt *Stmt, + void createSubstitutions(isl::ast_expr Expr, ScopStmt *Stmt, LoopToScevMapT <S); - void createSubstitutionsVector(__isl_take isl_ast_expr *Expr, ScopStmt *Stmt, + void createSubstitutionsVector(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(Expr, Stmt, VLTS, IVS, IteratorID); + createSubstitutionsVector(isl::manage(Expr), Stmt, VLTS, IVS, IteratorID); VectorBlockGenerator::generate(BlockGen, *Stmt, VLTS, S, NewAccesses); isl_id_to_ast_expr_free(NewAccesses); isl_map_free(S); @@ -927,41 +927,34 @@ return NewAccesses.release(); } -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) == isl_ast_op_call && - "Operation of type 'call' expected"); - for (int i = 0; i < isl_ast_expr_get_op_n_arg(Expr) - 1; ++i) { - isl_ast_expr *SubExpr; +void IslNodeBuilder::createSubstitutions(isl::ast_expr Expr, ScopStmt *Stmt, + LoopToScevMapT <S) { + isl::ast_expr_op ExprOpCall = + Expr.as().as(); + + for (int i = 0; i < isl_ast_expr_get_op_n_arg(ExprOpCall.get()) - 1; ++i) { Value *V; - SubExpr = isl_ast_expr_get_op_arg(Expr, i + 1); - V = ExprBuilder.create(SubExpr); + V = ExprBuilder.create(ExprOpCall.op_arg(i + 1).release()); ScalarEvolution *SE = Stmt->getParent()->getSE(); LTS[Stmt->getLoopForDimension(i)] = SE->getUnknown(V); } - - isl_ast_expr_free(Expr); } void IslNodeBuilder::createSubstitutionsVector( - __isl_take isl_ast_expr *Expr, ScopStmt *Stmt, - std::vector &VLTS, std::vector &IVS, - __isl_take isl_id *IteratorID) { + 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(isl_ast_expr_copy(Expr), Stmt, VLTS[i]); + createSubstitutions(Expr, Stmt, VLTS[i]); i++; } IDToValue[IteratorID] = OldValue; isl_id_free(IteratorID); - isl_ast_expr_free(Expr); } void IslNodeBuilder::generateCopyStmt( @@ -1011,7 +1004,7 @@ generateCopyStmt(Stmt, NewAccesses); isl_ast_expr_free(Expr); } else { - createSubstitutions(Expr, Stmt, LTS); + createSubstitutions(isl::manage(Expr), Stmt, LTS); if (Stmt->isBlockStmt()) BlockGen.copyStmt(*Stmt, LTS, NewAccesses);