[llvm-branch-commits] [flang] [mlir] [mlir][OpenMP][flang] make private variable allocation implicit in omp.private (PR #124019)

Tom Eccles via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jan 23 04:55:08 PST 2025


================
@@ -34,52 +34,48 @@ def PrivateClauseOp : OpenMP_Op<"private", [IsolatedFromAbove, RecipeInterface]>
   let description = [{
     This operation provides a declaration of how to implement the
     [first]privatization of a variable. The dialect users should provide
-    information about how to create an instance of the type in the alloc region,
-    how to initialize the copy from the original item in the copy region, and if
-    needed, how to deallocate allocated memory in the dealloc region.
+    which type should be allocated for this variable. The allocated (usually by
+    alloca) variable is passed to the initialization region which does everything
+    else (e.g. initialization of Fortran runtime descriptors). Information about
+    how to initialize the copy from the original item should be given in the
+    copy region, and if needed, how to deallocate memory (allocated by the
+    initialization region) in the dealloc region.
----------------
tblah wrote:

Thanks for reviewing the PR. These readability comments are very helpful.

The LLVM lowering is responsible for managing the implicitly allocated memory (it is usually just a stack allocation).

The `dealloc` region undoes what is done in the `init` region. So for example for a `!fir.box<!fir.heap<!fir.array<?xi32>>>`, the box is allocated implicitly on the stack and then the `init` region performs the heap allocation for the array and the dealloc region frees that heap allocation.

I will add an example in the omp.private documentation to make it clearer.

https://github.com/llvm/llvm-project/pull/124019


More information about the llvm-branch-commits mailing list