[flang-commits] [flang] [WIP] [flang] Always lower ALLOCATE/DEALLOCATE to runtime calls. (PR #133238)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Thu Apr 3 09:46:41 PDT 2025


clementval wrote:

> > Why? What is the rational? What is the use case? Going through the runtime is not good for simple cases.
> 
> The current pattern makes it rather hard to replace the default `malloc` allocator and plugin a different one.

Everything is already in place in the descriptor and allocation of the allocatables to use a different allocator. The descriptor holds an allocator id that reference a position in the allocator registry. The allocation from the runtime uses this allocator id to fetch the correct allocator/deallocator to perform the allocation and free actions.

https://github.com/llvm/llvm-project/blob/main/flang-rt/include/flang-rt/runtime/allocator-registry.h
https://github.com/llvm/llvm-project/blob/bc6cd825ecea94f015c590c877a1401d3a4a46b8/flang-rt/lib/runtime/descriptor.cpp#L176

Depending on your use case, you can register new allocator and you can override the default allocator of you want. 

There is a `useAllocateRuntime` option to force runtime allocation without changing the current behavior. 

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


More information about the flang-commits mailing list