Files
llvm-project/llvm/lib/Transforms/Utils/CodeExtractor.cpp
Sergio Afonso b5c755144d [OMPIRBuilder] Add support for explicit deallocation points (#154752)
In this patch, some OMPIRBuilder codegen functions and callbacks are
updated to work with arrays of deallocation insertion points. The
purpose of this is to enable the replacement of `alloca`s with other
types of allocations that require explicit deallocations in a way that
makes it possible for `CodeExtractor` instances created during
OMPIRBuilder finalization to also use them.

The OpenMP to LLVM IR MLIR translation pass is updated to properly store
and forward deallocation points together with their matching allocation
point to the OMPIRBuilder.

Currently, only the `DeviceSharedMemCodeExtractor` uses this feature to
get the `CodeExtractor` to use device shared memory for intermediate
allocations when outlining a parallel region inside of a Generic kernel
(code path that is only used by Flang via MLIR, currently). However,
long term this might also be useful to refactor finalization of
variables with destructors, potentially reducing the use of callbacks
and simplifying privatization and reductions.

Instead of a single deallocation point, lists of those are used. This is
to cover cases where there are multiple exit blocks originating from a
single entry. If an allocation needing explicit deallocation is placed
in the entry block of such cases, it would need to be deallocated before
each of the exits.
2026-04-27 13:12:07 +01:00

80 KiB