diff --git a/polly/include/polly/CodeGen/IslAst.h b/polly/include/polly/CodeGen/IslAst.h --- a/polly/include/polly/CodeGen/IslAst.h +++ b/polly/include/polly/CodeGen/IslAst.h @@ -78,9 +78,6 @@ /// Construct and initialize the payload. IslAstUserPayload() = default; - /// Cleanup all isl structs on destruction. - ~IslAstUserPayload(); - /// Does the dependence analysis determine that there are no loop-carried /// dependencies? bool IsParallel = false; @@ -101,7 +98,7 @@ isl::pw_aff MinimalDependenceDistance; /// The build environment at the time this node was constructed. - isl_ast_build *Build = nullptr; + isl::ast_build Build; /// Set of accesses which break reduction dependences. MemoryAccessSet BrokenReductions; @@ -164,7 +161,7 @@ static MemoryAccessSet *getBrokenReductions(const isl::ast_node &Node); /// Get the nodes build context or a nullptr if not available. - static __isl_give isl_ast_build *getBuild(__isl_keep isl_ast_node *Node); + static isl::ast_build getBuild(const isl::ast_node &Node); ///} }; diff --git a/polly/lib/CodeGen/IslAst.cpp b/polly/lib/CodeGen/IslAst.cpp --- a/polly/lib/CodeGen/IslAst.cpp +++ b/polly/lib/CodeGen/IslAst.cpp @@ -124,10 +124,6 @@ delete ((IslAstInfo::IslAstUserPayload *)Ptr); } -IslAstInfo::IslAstUserPayload::~IslAstUserPayload() { - isl_ast_build_free(Build); -} - /// Print a string @p str in a single line using @p Printer. static isl_printer *printLine(__isl_take isl_printer *Printer, const std::string &str, @@ -286,8 +282,8 @@ assert(Payload && "Post order visit assumes annotated for nodes"); AstBuildUserInfo *BuildInfo = (AstBuildUserInfo *)User; - assert(!Payload->Build && "Build environment already set"); - Payload->Build = isl_ast_build_copy(Build); + assert(Payload->Build.is_null() && "Build environment already set"); + Payload->Build = isl::manage_copy(Build); Payload->IsInnermost = (Id == BuildInfo->LastForNodeId); Payload->IsInnermostParallel = @@ -333,7 +329,7 @@ isl_id *Id = isl_id_alloc(isl_ast_build_get_ctx(Build), "", Payload); Id = isl_id_set_free_user(Id, freeIslAstUserPayload); - Payload->Build = isl_ast_build_copy(Build); + Payload->Build = isl::manage_copy(Build); return isl_ast_node_set_annotation(Node, Id); } @@ -622,11 +618,7 @@ isl::union_map IslAstInfo::getSchedule(const isl::ast_node &Node) { IslAstUserPayload *Payload = getNodePayload(Node); - if (!Payload) - return {}; - - isl::ast_build Build = isl::manage_copy(Payload->Build); - return Build.get_schedule(); + return Payload ? Payload->Build.get_schedule() : isl::union_map(); } isl::pw_aff @@ -641,9 +633,9 @@ return Payload ? &Payload->BrokenReductions : nullptr; } -isl_ast_build *IslAstInfo::getBuild(__isl_keep isl_ast_node *Node) { - IslAstUserPayload *Payload = getNodePayload(isl::manage_copy(Node)); - return Payload ? Payload->Build : nullptr; +isl::ast_build IslAstInfo::getBuild(const isl::ast_node &Node) { + IslAstUserPayload *Payload = getNodePayload(Node); + return Payload ? Payload->Build : isl::ast_build(); } static std::unique_ptr runIslAst( @@ -706,7 +698,7 @@ else P = isl_printer_print_str(P, "/* write */ "); - isl::ast_build Build = isl::manage_copy(IslAstInfo::getBuild(Node)); + isl::ast_build Build = IslAstInfo::getBuild(isl::manage_copy(Node)); if (MemAcc->isAffine()) { isl_pw_multi_aff *PwmaPtr = MemAcc->applyScheduleToAccessRelation(Build.get_schedule()).release(); 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 @@ -850,12 +850,12 @@ __isl_give isl_id_to_ast_expr * IslNodeBuilder::createNewAccesses(ScopStmt *Stmt, __isl_keep isl_ast_node *Node) { - isl_id_to_ast_expr *NewAccesses = - isl_id_to_ast_expr_alloc(Stmt->getParent()->getIslCtx().get(), 0); + isl::id_to_ast_expr NewAccesses = + isl::id_to_ast_expr::alloc(Stmt->getParent()->getIslCtx(), 0); - auto *Build = IslAstInfo::getBuild(Node); - assert(Build && "Could not obtain isl_ast_build from user node"); - Stmt->setAstBuild(isl::manage_copy(Build)); + isl::ast_build Build = IslAstInfo::getBuild(isl::manage_copy(Node)); + assert(!Build.is_null() && "Could not obtain isl_ast_build from user node"); + Stmt->setAstBuild(Build); for (auto *MA : *Stmt) { if (!MA->hasNewAccessRelation()) { @@ -876,13 +876,12 @@ assert(MA->isAffine() && "Only affine memory accesses can be code generated"); - auto Schedule = isl_ast_build_get_schedule(Build); + isl::union_map Schedule = Build.get_schedule(); #ifndef NDEBUG if (MA->isRead()) { auto Dom = Stmt->getDomain().release(); - auto SchedDom = isl_set_from_union_set( - isl_union_map_domain(isl_union_map_copy(Schedule))); + auto SchedDom = isl_set_from_union_set(Schedule.domain().release()); auto AccDom = isl_map_domain(MA->getAccessRelation().release()); Dom = isl_set_intersect_params(Dom, Stmt->getParent()->getContext().release()); @@ -898,25 +897,20 @@ } #endif - auto PWAccRel = - MA->applyScheduleToAccessRelation(isl::manage(Schedule)).release(); + isl::pw_multi_aff PWAccRel = MA->applyScheduleToAccessRelation(Schedule); // isl cannot generate an index expression for access-nothing accesses. - isl::set AccDomain = - isl::manage(isl_pw_multi_aff_domain(isl_pw_multi_aff_copy(PWAccRel))); + isl::set AccDomain = PWAccRel.domain(); isl::set Context = S.getContext(); AccDomain = AccDomain.intersect_params(Context); - if (AccDomain.is_empty()) { - isl_pw_multi_aff_free(PWAccRel); + if (AccDomain.is_empty()) continue; - } - auto AccessExpr = isl_ast_build_access_from_pw_multi_aff(Build, PWAccRel); - NewAccesses = - isl_id_to_ast_expr_set(NewAccesses, MA->getId().release(), AccessExpr); + isl::ast_expr AccessExpr = Build.access_from(PWAccRel); + NewAccesses = NewAccesses.set(MA->getId(), AccessExpr); } - return NewAccesses; + return NewAccesses.release(); } void IslNodeBuilder::createSubstitutions(__isl_take isl_ast_expr *Expr,