Fortran loads span of span-addressed dummies on entry.
Fixes incorrect array addressing for span-addressed dummies in outlined regions.
Fortran procedures using assumed-shape dummy arguments addressed through their descriptor’s span now correctly load this span into a local variable on entry. Previously, the span was reloaded from the descriptor at each element reference, causing issues within outlined regions (like OpenMP target regions) where the descriptor was not mapped, leading to dereferencing a host pointer and using garbage data.
In Details
For assumed-shape dummy arrays passed by reference, the span (which includes bounds and data pointer) is accessed via the dummy's descriptor. This commit ensures that the span is loaded into a local variable (GFC_DECL_SPAN) on procedure entry, alongside the bounds, to avoid re-accessing the descriptor within the procedure body, especially in outlined regions. This resolves a bug where the span was reloaded from a potentially inaccessible descriptor on the device.
- span-addressed dummy
- A dummy argument in Fortran that represents an array whose bounds and data pointer are accessed through a descriptor, rather than being passed directly.
- assumed-shape dummy
- A dummy argument in Fortran that is an array whose shape is determined by the actual argument passed to the procedure.
- descriptor
- A data structure containing information about an array, such as its bounds, element size, and data pointer.
- outlined region
- A region of code, such as an OpenMP target region, that is extracted and executed separately, potentially on a different device.
- OpenMP target region
- A region of code designated for execution on a target device, managed by OpenMP directives.