[llvm-branch-commits] [flang] [Flang][OpenMP] Add pass to replace allocas with device shared memory (PR #161863)

Michael Kruse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Oct 6 04:30:08 PDT 2025


================
@@ -128,4 +128,21 @@ def AutomapToTargetDataPass
   let dependentDialects = ["mlir::omp::OpenMPDialect"];
 }
 
+def StackToSharedPass : Pass<"omp-stack-to-shared", "mlir::func::FuncOp"> {
+  let summary = "Replaces stack allocations with shared memory.";
+  let description = [{
+    `fir.alloca` operations defining values in a target region and then used
+    inside of an `omp.parallel` region are replaced by this pass with
+    `omp.alloc_shared_mem` and `omp.free_shared_mem`. This is also done for
----------------
Meinersbur wrote:

```suggestion
    This pass replaces `fir.alloca` that are defined in target regions, but outside of `omp.parallel` regions, with
    `omp.alloc_shared_mem` and `omp.free_shared_mem`. This is also done for
```


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


More information about the llvm-branch-commits mailing list