LTO: Check mode availability on offload targets
Ensures that compiler modes used in LTO are actually supported on the offload target device.
This change enhances the LTO input mode table to verify that floating-point and integer modes are supported at runtime on offload targets. Previously, only a general check for mode existence was performed. Now, for ACCEL_COMPILER targets, it calls targetm.scalar_mode_supported_p to confirm runtime availability. This is crucial for modes like _Float16 which may have device-specific or conditional support, preventing errors caused by using unsupported data types on the target hardware. New test cases are added to verify this functionality.
In Details
The lto_input_mode_table function, responsible for processing modes from LTO input, now includes a runtime check for mode availability on offload targets. This addresses issues where modes supported by the host compiler (e.g., _Float16) might not be fully enabled or available on the device (e.g., nvptx with -mexperimental, amdgcn). The change adds a call to targetm.scalar_mode_supported_p within the ACCEL_COMPILER branch to dynamically verify if a mode is supported at runtime before accepting it, issuing an error if not. This complements the existing check for modes that are ent…
- LTO
- Link-Time Optimization. A compilation process where optimization is performed across multiple source files during the linking stage, allowing for more aggressive optimizations.
- offload targets
- Hardware accelerators or co-processors (e.g., GPUs) that a host system can offload computation to. Compilers supporting offloading generate code for both the host and the target device.
- mode
- In GCC, a 'mode' represents a data type and its size, such as 'SI' for signed integer, 'DF' for double-precision float, or 'HF' for half-precision float.
- runtime availability
- Whether a specific feature or data type is supported and functional by the target hardware and its drivers at the time the program is executed.
- ACCEL_COMPILER
- A compiler targeting an accelerator device, distinct from the host compiler.
- targetm.scalar_mode_supported_p
- A target-specific function pointer in GCC used to query whether a given scalar data type (mode) is supported by the target architecture at runtime.