[flang-commits] [flang] [llvm] [mlir] [Flang] Add lowering support for depobj in depend clause (PR #124523)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Fri Jan 31 10:22:01 PST 2025
tblah wrote:
> The `DepAlloca` data will required for the task creation, so I think it should be available during the runtime (Mostly, Asynchronous). Regarding the `StackSave` and `Restore` usage, I think it must be a mistake and might not required. But, I have a doubt, how does the memory deallocation happen here?
When a function is called, data are allocated on the stack (by adjusting the stack pointer), then as the function executes there might be later allocas which further adjust the stack pointer (allocating more memory). Your stack restore un-does one of these later adjustments. Otherwise, when the function returns the stack pointer is restored to its value before the function was called. So after the function return, all stack data are unallocated, and accessing them in any way is undefined behavior.
Task *creation* occurs synchronously. The function creating the task will not return until after the task has been created and so if data are only used during task creation, it is safe for those to be stack-allocated.
Task *execution* occurs asynchronously. It could happen any time between the creation of the task and the next synchronization event (e.g. `taskwait`). Therefore it is not safe for a task to refer to stack allocated data because the function containing that stack frame might have returned by the time the task uses the data.
https://github.com/llvm/llvm-project/pull/124523
More information about the flang-commits
mailing list