Use isl::manage_copy to simplify calls to isl::manage(isl_.._copy())
authorTobias Grosser <tobias@grosser.es>
Tue, 20 Feb 2018 07:26:58 +0000 (07:26 +0000)
committerTobias Grosser <tobias@grosser.es>
Tue, 20 Feb 2018 07:26:58 +0000 (07:26 +0000)
As part of this cleanup a couple of unnecessary isl::manage(obj.copy()) pattern
are eliminated as well.

We checked for all potential cleanups by scanning for:

  "grep -R isl::manage\( lib/ | grep copy"

llvm-svn: 325558

polly/lib/Analysis/ScopInfo.cpp
polly/lib/CodeGen/BlockGenerators.cpp
polly/lib/CodeGen/IslAst.cpp
polly/lib/CodeGen/IslNodeBuilder.cpp
polly/lib/CodeGen/PPCGCodeGeneration.cpp
polly/lib/Support/ISLTools.cpp
polly/lib/Support/SCEVAffinator.cpp
polly/lib/Transform/DeLICM.cpp
polly/lib/Transform/ScheduleOptimizer.cpp

index c8d3f6b..9c0a037 100644 (file)
@@ -3484,7 +3484,7 @@ void Scop::foldSizeConstantsToRight() {
     for (auto &Access : AccessFunctions)
       if (Access->getScopArrayInfo() == Array)
         Access->setAccessRelation(Access->getAccessRelation().apply_range(
-            isl::manage(isl_map_copy(Transform))));
+            isl::manage_copy(Transform)));
 
     isl_map_free(Transform);
 
index 29c29ff..4632765 100644 (file)
@@ -1040,11 +1040,11 @@ void VectorBlockGenerator::generateLoad(
   extractScalarValues(Load, VectorMap, ScalarMaps);
 
   Value *NewLoad;
-  if (Access.isStrideZero(isl::manage(isl_map_copy(Schedule))))
+  if (Access.isStrideZero(isl::manage_copy(Schedule)))
     NewLoad = generateStrideZeroLoad(Stmt, Load, ScalarMaps[0], NewAccesses);
-  else if (Access.isStrideOne(isl::manage(isl_map_copy(Schedule))))
+  else if (Access.isStrideOne(isl::manage_copy(Schedule)))
     NewLoad = generateStrideOneLoad(Stmt, Load, ScalarMaps, NewAccesses);
-  else if (Access.isStrideX(isl::manage(isl_map_copy(Schedule)), -1))
+  else if (Access.isStrideX(isl::manage_copy(Schedule), -1))
     NewLoad = generateStrideOneLoad(Stmt, Load, ScalarMaps, NewAccesses, true);
   else
     NewLoad = generateUnknownStrideLoad(Stmt, Load, ScalarMaps, NewAccesses);
@@ -1095,7 +1095,7 @@ void VectorBlockGenerator::copyStore(
   // the data location.
   extractScalarValues(Store, VectorMap, ScalarMaps);
 
-  if (Access.isStrideOne(isl::manage(isl_map_copy(Schedule)))) {
+  if (Access.isStrideOne(isl::manage_copy(Schedule))) {
     Type *VectorPtrType = getVectorPtrTy(Pointer, getVectorWidth());
     Value *NewPointer = generateLocationAccessed(Stmt, Store, ScalarMaps[0],
                                                  VLTS[0], NewAccesses);
index dddfbab..442411b 100644 (file)
@@ -439,14 +439,12 @@ IslAst::buildRunCondition(Scop &S, __isl_keep isl_ast_build *Build) {
       for (auto RWAccIt1 = RWAccIt0 + 1; RWAccIt1 != RWAccEnd; ++RWAccIt1)
         RunCondition = isl_ast_expr_and(
             RunCondition,
-            buildCondition(S, isl::manage(isl_ast_build_copy(Build)), RWAccIt0,
-                           RWAccIt1)
+            buildCondition(S, isl::manage_copy(Build), RWAccIt0, RWAccIt1)
                 .release());
       for (const Scop::MinMaxAccessTy &ROAccIt : MinMaxReadOnly)
         RunCondition = isl_ast_expr_and(
             RunCondition,
-            buildCondition(S, isl::manage(isl_ast_build_copy(Build)), RWAccIt0,
-                           &ROAccIt)
+            buildCondition(S, isl::manage_copy(Build), RWAccIt0, &ROAccIt)
                 .release());
     }
   }
@@ -683,7 +681,7 @@ static __isl_give isl_printer *cbPrintUser(__isl_take isl_printer *P,
                                            __isl_take isl_ast_print_options *O,
                                            __isl_keep isl_ast_node *Node,
                                            void *User) {
-  isl::ast_node AstNode = isl::manage(isl_ast_node_copy(Node));
+  isl::ast_node AstNode = isl::manage_copy(Node);
   isl::ast_expr NodeExpr = AstNode.user_get_expr();
   isl::ast_expr CallExpr = NodeExpr.get_op_arg(0);
   isl::id CallExprId = CallExpr.get_id();
@@ -703,8 +701,7 @@ static __isl_give isl_printer *cbPrintUser(__isl_take isl_printer *P,
     else
       P = isl_printer_print_str(P, "/* write */  ");
 
-    isl::ast_build Build =
-        isl::manage(isl_ast_build_copy(IslAstInfo::getBuild(Node)));
+    isl::ast_build Build = isl::manage_copy(IslAstInfo::getBuild(Node));
     if (MemAcc->isAffine()) {
       isl_pw_multi_aff *PwmaPtr =
           MemAcc->applyScheduleToAccessRelation(Build.get_schedule()).release();
index f89fa5e..7b315fe 100644 (file)
@@ -540,8 +540,7 @@ void IslNodeBuilder::createForSequential(__isl_take isl_ast_node *For,
   Value *IV;
   CmpInst::Predicate Predicate;
 
-  bool LoopVectorizerDisabled =
-      IsLoopVectorizerDisabled(isl::manage(isl_ast_node_copy(For)));
+  bool LoopVectorizerDisabled = IsLoopVectorizerDisabled(isl::manage_copy(For));
 
   Body = isl_ast_node_for_get_body(For);
 
@@ -853,7 +852,7 @@ IslNodeBuilder::createNewAccesses(ScopStmt *Stmt,
 
   auto *Build = IslAstInfo::getBuild(Node);
   assert(Build && "Could not obtain isl_ast_build from user node");
-  Stmt->setAstBuild(isl::manage(isl_ast_build_copy(Build)));
+  Stmt->setAstBuild(isl::manage_copy(Build));
 
   for (auto *MA : *Stmt) {
     if (!MA->hasNewAccessRelation()) {
@@ -1596,7 +1595,7 @@ Value *IslNodeBuilder::createRTC(isl_ast_expr *Condition) {
   // bits. These are -- in case wrapping intrinsics are used -- translated to
   // runtime library calls that are not available on all systems (e.g., Android)
   // and consequently will result in linker errors.
-  if (ExprBuilder.hasLargeInts(isl::manage(isl_ast_expr_copy(Condition)))) {
+  if (ExprBuilder.hasLargeInts(isl::manage_copy(Condition))) {
     isl_ast_expr_free(Condition);
     return Builder.getFalse();
   }
index d665214..5bf31e6 100644 (file)
@@ -287,7 +287,7 @@ static __isl_give isl_id_to_ast_expr *pollyBuildAstExprForStmt(
   if (!Stmt || !Build_C)
     return NULL;
 
-  isl::ast_build Build = isl::manage(isl_ast_build_copy(Build_C));
+  isl::ast_build Build = isl::manage_copy(Build_C);
   isl::ctx Ctx = Build.get_ctx();
   isl::id_to_ast_expr RefToExpr = isl::id_to_ast_expr::alloc(Ctx, 0);
 
@@ -1103,8 +1103,7 @@ Value *GPUNodeBuilder::getArraySize(gpu_array_info *Array) {
   Value *ArraySize = ConstantInt::get(Builder.getInt64Ty(), Array->size);
 
   if (!gpu_array_is_scalar(Array)) {
-    isl::multi_pw_aff ArrayBound =
-        isl::manage(isl_multi_pw_aff_copy(Array->bound));
+    isl::multi_pw_aff ArrayBound = isl::manage_copy(Array->bound);
 
     isl::pw_aff OffsetDimZero = ArrayBound.get_pw_aff(0);
     isl::ast_expr Res = Build.expr_from(OffsetDimZero);
@@ -1129,7 +1128,7 @@ Value *GPUNodeBuilder::getArrayOffset(gpu_array_info *Array) {
 
   isl::ast_build Build = isl::ast_build::from_context(S.getContext());
 
-  isl::set Min = isl::manage(isl_set_copy(Array->extent)).lexmin();
+  isl::set Min = isl::manage_copy(Array->extent).lexmin();
 
   isl::set ZeroSet = isl::set::universe(Min.get_space());
 
@@ -1576,8 +1575,7 @@ std::tuple<Value *, Value *> GPUNodeBuilder::getGridSizes(ppcg_kernel *Kernel) {
   std::vector<Value *> Sizes;
   isl::ast_build Context = isl::ast_build::from_context(S.getContext());
 
-  isl::multi_pw_aff GridSizePwAffs =
-      isl::manage(isl_multi_pw_aff_copy(Kernel->grid_size));
+  isl::multi_pw_aff GridSizePwAffs = isl::manage_copy(Kernel->grid_size);
   for (long i = 0; i < Kernel->n_grid; i++) {
     isl::pw_aff Size = GridSizePwAffs.get_pw_aff(i);
     isl::ast_expr GridSize = Context.expr_from(Size);
@@ -2012,8 +2010,7 @@ GPUNodeBuilder::createKernelFunctionDecl(ppcg_kernel *Kernel,
     Arg->setName(Kernel->array[i].array->name);
 
     isl_id *Id = isl_space_get_tuple_id(Prog->array[i].space, isl_dim_set);
-    const ScopArrayInfo *SAI =
-        ScopArrayInfo::getFromId(isl::manage(isl_id_copy(Id)));
+    const ScopArrayInfo *SAI = ScopArrayInfo::getFromId(isl::manage_copy(Id));
     Type *EleTy = SAI->getElementType();
     Value *Val = &*Arg;
     SmallVector<const SCEV *, 4> Sizes;
@@ -2144,8 +2141,7 @@ void GPUNodeBuilder::prepareKernelArguments(ppcg_kernel *Kernel, Function *FN) {
       continue;
 
     isl_id *Id = isl_space_get_tuple_id(Prog->array[i].space, isl_dim_set);
-    const ScopArrayInfo *SAI =
-        ScopArrayInfo::getFromId(isl::manage(isl_id_copy(Id)));
+    const ScopArrayInfo *SAI = ScopArrayInfo::getFromId(isl::manage_copy(Id));
     isl_id_free(Id);
 
     if (SAI->getNumberOfDimensions() > 0) {
@@ -2178,8 +2174,7 @@ void GPUNodeBuilder::finalizeKernelArguments(ppcg_kernel *Kernel) {
       continue;
 
     isl_id *Id = isl_space_get_tuple_id(Prog->array[i].space, isl_dim_set);
-    const ScopArrayInfo *SAI =
-        ScopArrayInfo::getFromId(isl::manage(isl_id_copy(Id)));
+    const ScopArrayInfo *SAI = ScopArrayInfo::getFromId(isl::manage_copy(Id));
     isl_id_free(Id);
 
     if (SAI->getNumberOfDimensions() > 0) {
index ea1b30f..41f9d46 100644 (file)
@@ -843,19 +843,19 @@ LLVM_DUMP_METHOD void polly::dumpPw(const isl::union_map &UMap) {
 }
 
 LLVM_DUMP_METHOD void polly::dumpPw(__isl_keep isl_set *Set) {
-  dumpPw(isl::manage(isl_set_copy(Set)));
+  dumpPw(isl::manage_copy(Set));
 }
 
 LLVM_DUMP_METHOD void polly::dumpPw(__isl_keep isl_map *Map) {
-  dumpPw(isl::manage(isl_map_copy(Map)));
+  dumpPw(isl::manage_copy(Map));
 }
 
 LLVM_DUMP_METHOD void polly::dumpPw(__isl_keep isl_union_set *USet) {
-  dumpPw(isl::manage(isl_union_set_copy(USet)));
+  dumpPw(isl::manage_copy(USet));
 }
 
 LLVM_DUMP_METHOD void polly::dumpPw(__isl_keep isl_union_map *UMap) {
-  dumpPw(isl::manage(isl_union_map_copy(UMap)));
+  dumpPw(isl::manage_copy(UMap));
 }
 
 LLVM_DUMP_METHOD void polly::dumpExpanded(const isl::set &Set) {
@@ -875,18 +875,18 @@ LLVM_DUMP_METHOD void polly::dumpExpanded(const isl::union_map &UMap) {
 }
 
 LLVM_DUMP_METHOD void polly::dumpExpanded(__isl_keep isl_set *Set) {
-  dumpExpanded(isl::manage(isl_set_copy(Set)));
+  dumpExpanded(isl::manage_copy(Set));
 }
 
 LLVM_DUMP_METHOD void polly::dumpExpanded(__isl_keep isl_map *Map) {
-  dumpExpanded(isl::manage(isl_map_copy(Map)));
+  dumpExpanded(isl::manage_copy(Map));
 }
 
 LLVM_DUMP_METHOD void polly::dumpExpanded(__isl_keep isl_union_set *USet) {
-  dumpExpanded(isl::manage(isl_union_set_copy(USet)));
+  dumpExpanded(isl::manage_copy(USet));
 }
 
 LLVM_DUMP_METHOD void polly::dumpExpanded(__isl_keep isl_union_map *UMap) {
-  dumpExpanded(isl::manage(isl_union_map_copy(UMap)));
+  dumpExpanded(isl::manage_copy(UMap));
 }
 #endif
index 5be900d..14603e1 100644 (file)
@@ -282,8 +282,7 @@ PWACtx SCEVAffinator::visitTruncateExpr(const SCEVTruncateExpr *Expr) {
   auto *SmallerDom =
       isl_pw_aff_lt_set(OpPWAC.first.copy(), isl_pw_aff_neg(ExpPWA));
   auto *OutOfBoundsDom = isl_set_union(SmallerDom, GreaterDom);
-  OpPWAC.second =
-      OpPWAC.second.unite(isl::manage(isl_set_copy(OutOfBoundsDom)));
+  OpPWAC.second = OpPWAC.second.unite(isl::manage_copy(OutOfBoundsDom));
 
   if (!BB) {
     assert(isl_set_dim(OutOfBoundsDom, isl_dim_set) == 0 &&
index 9709f42..5463eb0 100644 (file)
@@ -484,8 +484,7 @@ public:
 
     // Does Proposed write at the same time as Existing already does (order of
     // writes is undefined)? Writing the same value is permitted.
-    auto ExistingWrittenDomain =
-        isl::manage(isl_union_map_domain(Existing.Written.copy()));
+    auto ExistingWrittenDomain = Existing.Written.domain();
     auto BothWritten =
         Existing.Written.domain().intersect(Proposed.Written.domain());
     auto ExistingKnownWritten = filterKnownValInst(Existing.Written);
index fa7e392..7929a3d 100644 (file)
@@ -1101,7 +1101,7 @@ optimizeDataLayoutMatrMulPattern(isl::schedule_node Node, isl::map MapOldIndVar,
   // matrix B, the second operand of the matrix multiplication.
   Node = Node.parent().parent().parent().parent().parent().parent();
   Node = isl::manage(isl_schedule_node_band_split(Node.release(), 2)).child(0);
-  auto AccRel = getMatMulAccRel(isl::manage(MapOldIndVar.copy()), 3, 7);
+  auto AccRel = getMatMulAccRel(MapOldIndVar, 3, 7);
   unsigned FirstDimSize = MacroParams.Nc / MicroParams.Nr;
   unsigned SecondDimSize = MacroParams.Kc;
   unsigned ThirdDimSize = MicroParams.Nr;
@@ -1122,15 +1122,15 @@ optimizeDataLayoutMatrMulPattern(isl::schedule_node Node, isl::map MapOldIndVar,
   auto DomainId = Domain.get_tuple_id();
   auto *NewStmt = Stmt->getParent()->addScopStmt(
       OldAcc, MMI.B->getLatestAccessRelation(), Domain);
-  ExtMap = ExtMap.set_tuple_id(isl::dim::out, isl::manage(DomainId.copy()));
-  ExtMap = ExtMap.intersect_range(isl::manage(Domain.copy()));
+  ExtMap = ExtMap.set_tuple_id(isl::dim::out, DomainId);
+  ExtMap = ExtMap.intersect_range(Domain);
   ExtMap = ExtMap.set_tuple_id(isl::dim::out, NewStmt->getDomainId());
   Node = createExtensionNode(Node, ExtMap);
 
   // Create a copy statement that corresponds to the memory access
   // to the matrix A, the first operand of the matrix multiplication.
   Node = Node.child(0);
-  AccRel = getMatMulAccRel(isl::manage(MapOldIndVar.copy()), 4, 6);
+  AccRel = getMatMulAccRel(MapOldIndVar, 4, 6);
   FirstDimSize = MacroParams.Mc / MicroParams.Mr;
   ThirdDimSize = MicroParams.Mr;
   SAI = Stmt->getParent()->createScopArrayInfo(
@@ -1260,7 +1260,7 @@ getBandNodeWithOriginDimOrder(isl::schedule_node Node) {
   auto Domain = Node.get_universe_domain();
   assert(isl_union_set_n_set(Domain.keep()) == 1);
   if (Node.get_schedule_depth() != 0 ||
-      (isl::set(isl::manage(Domain.copy())).dim(isl::dim::set) !=
+      (isl::set(Domain).dim(isl::dim::set) !=
        isl_schedule_node_band_n_member(Node.keep())))
     return Node;
   Node = isl::manage(isl_schedule_node_delete(Node.take()));
@@ -1329,7 +1329,7 @@ bool ScheduleTreeOptimizer::isMatrMultPattern(isl::schedule_node Node,
 __isl_give isl_schedule_node *
 ScheduleTreeOptimizer::optimizeBand(__isl_take isl_schedule_node *Node,
                                     void *User) {
-  if (!isTileableBandNode(isl::manage(isl_schedule_node_copy(Node))))
+  if (!isTileableBandNode(isl::manage_copy(Node)))
     return Node;
 
   const OptimizerAdditionalInfoTy *OAI =
@@ -1337,8 +1337,7 @@ ScheduleTreeOptimizer::optimizeBand(__isl_take isl_schedule_node *Node,
 
   MatMulInfoTy MMI;
   if (PMBasedOpts && User &&
-      isMatrMultPattern(isl::manage(isl_schedule_node_copy(Node)), OAI->D,
-                        MMI)) {
+      isMatrMultPattern(isl::manage_copy(Node), OAI->D, MMI)) {
     DEBUG(dbgs() << "The matrix multiplication pattern was detected\n");
     MatMulOpts++;
     return optimizeMatMulPattern(isl::manage(Node), OAI->TTI, MMI).release();
@@ -1434,7 +1433,7 @@ static void walkScheduleTreeForStatistics(isl::schedule Schedule, int Version) {
   isl_schedule_node_foreach_descendant_top_down(
       Root.get(),
       [](__isl_keep isl_schedule_node *nodeptr, void *user) -> isl_bool {
-        isl::schedule_node Node = isl::manage(isl_schedule_node_copy(nodeptr));
+        isl::schedule_node Node = isl::manage_copy(nodeptr);
         int Version = *static_cast<int *>(user);
 
         switch (isl_schedule_node_get_type(Node.get())) {