[PATCH] D102130: [polly] In IslNodeBuilder::createForVector() use isl::noexception bindings [NFC]

Saheed Bolarinwa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 9 03:54:02 PDT 2021


refactormyself created this revision.
refactormyself added a reviewer: Meinersbur.
Herald added a reviewer: bollu.
refactormyself requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The C++ bindings in isl_noexception provide better pointer management.
This allows the use of convenient memory management tools in C++.

- Replace the isl C entities with isl_noexception bindings
- Refactor calls to this function

No functional changes were made.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102130

Files:
  polly/include/polly/CodeGen/IslNodeBuilder.h
  polly/lib/CodeGen/IslNodeBuilder.cpp


Index: polly/lib/CodeGen/IslNodeBuilder.cpp
===================================================================
--- polly/lib/CodeGen/IslNodeBuilder.cpp
+++ polly/lib/CodeGen/IslNodeBuilder.cpp
@@ -415,7 +415,7 @@
     bool Vector = PollyVectorizerChoice == VECTORIZER_POLLY;
     int VectorWidth = getNumberOfIterations(isl::manage_copy(Child));
     if (Vector && 1 < VectorWidth && VectorWidth <= 16)
-      createForVector(Child, VectorWidth);
+      createForVector(isl::manage(Child), VectorWidth);
     else
       createForSequential(isl::manage(Child), true);
     isl_id_free(Id);
@@ -449,12 +449,11 @@
   isl_id_free(Id);
 }
 
-void IslNodeBuilder::createForVector(__isl_take isl_ast_node *For,
-                                     int VectorWidth) {
-  isl_ast_node *Body = isl_ast_node_for_get_body(For);
-  isl_ast_expr *Init = isl_ast_node_for_get_init(For);
-  isl_ast_expr *Inc = isl_ast_node_for_get_inc(For);
-  isl_ast_expr *Iterator = isl_ast_node_for_get_iterator(For);
+void IslNodeBuilder::createForVector(isl::ast_node For, int VectorWidth) {
+  isl_ast_node *Body = isl_ast_node_for_get_body(For.get());
+  isl_ast_expr *Init = isl_ast_node_for_get_init(For.get());
+  isl_ast_expr *Inc = isl_ast_node_for_get_inc(For.get());
+  isl_ast_expr *Iterator = isl_ast_node_for_get_iterator(For.get());
   isl_id *IteratorID = isl_ast_expr_get_id(Iterator);
 
   Value *ValueLB = ExprBuilder.create(Init);
@@ -475,7 +474,7 @@
   for (int i = 1; i < VectorWidth; i++)
     IVS[i] = Builder.CreateAdd(IVS[i - 1], ValueInc, "p_vector_iv");
 
-  isl::union_map Schedule = getScheduleForAstNode(isl::manage_copy(For));
+  isl::union_map Schedule = getScheduleForAstNode(For);
   assert(!Schedule.is_null() &&
          "For statement annotation does not contain its schedule");
 
@@ -504,7 +503,6 @@
   IDToValue.erase(IDToValue.find(IteratorID));
   isl_id_free(IteratorID);
 
-  isl_ast_node_free(For);
   isl_ast_expr_free(Iterator);
 
   VectorLoops++;
@@ -784,7 +782,7 @@
       !IslAstInfo::isReductionParallel(isl::manage_copy(For))) {
     int VectorWidth = getNumberOfIterations(isl::manage_copy(For));
     if (1 < VectorWidth && VectorWidth <= 16 && !hasPartialAccesses(For)) {
-      createForVector(For, VectorWidth);
+      createForVector(isl::manage(For), VectorWidth);
       return;
     }
   }
Index: polly/include/polly/CodeGen/IslNodeBuilder.h
===================================================================
--- polly/include/polly/CodeGen/IslNodeBuilder.h
+++ polly/include/polly/CodeGen/IslNodeBuilder.h
@@ -316,7 +316,7 @@
   /// @returns False, iff a problem occurred and the load was not preloaded.
   bool preloadInvariantEquivClass(InvariantEquivClassTy &IAClass);
 
-  void createForVector(__isl_take isl_ast_node *For, int VectorWidth);
+  void createForVector(isl::ast_node For, int VectorWidth);
   void createForSequential(isl::ast_node For, bool MarkParallel);
 
   /// Create LLVM-IR that executes a for node thread parallel.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102130.343906.patch
Type: text/x-patch
Size: 2980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210509/293f12d5/attachment.bin>


More information about the llvm-commits mailing list