[llvm-branch-commits] [flang] [llvm] [mlir] [Flang][MLIR][OpenMP] Add explicit shared memory (de-)allocation ops (PR #161862)
Sergio Afonso via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Feb 23 05:50:20 PST 2026
================
@@ -4347,6 +4347,17 @@ LogicalResult AllocateDirOp::verify() {
return success();
}
+//===----------------------------------------------------------------------===//
+// FreeSharedMemOp
+//===----------------------------------------------------------------------===//
+
+LogicalResult FreeSharedMemOp::verify() {
+ return getHeapref().getDefiningOp<AllocSharedMemOp>()
+ ? success()
+ : emitOpError() << "'heapref' operand must be defined by an "
+ "'omp.alloc_shared_memory' op";
----------------
skatrak wrote:
The reasoning was that alloc and free op pairs are supposed to exist in the same region because they are being produced as a replacement of allocas. In that case, it's not possible to have an op in between converting the allocated value into a block argument.
However, I can see that this is a bit of an arbitrary limitation based on the current uses of these ops and could break not only with block arguments but also with typecast style operations in the mix. I made some changes to the free operation so that it now holds all the information it needs to be lowered, rather than querying it from the associated allocation.
https://github.com/llvm/llvm-project/pull/161862
More information about the llvm-branch-commits
mailing list