Fix ICE passing empty aggregate in VLS calling convention.
Resolves compiler crash when passing empty aggregates via RISC-V VLS calling convention.
An internal compiler error (ICE) in the RISC-V backend when passing an empty aggregate struct using the riscv_vls_cc calling convention has been fixed. The function riscv_pass_aggregate_in_vr incorrectly attempted to access fields of an empty aggregate, leading to the crash. The fix ensures that NULL_RTX is returned for aggregates with no fields, allowing the generic compiler code to handle them appropriately.
In Details
The riscv_pass_aggregate_in_vr function in config/riscv/riscv.cc handles passing aggregate arguments in vector registers according to the VLS calling convention. It previously returned 0 for an aggregate with no fields, but then accessed fields[0], causing an ICE. This commit changes it to return NULL_RTX for empty aggregates, aligning its behavior with the generic handling of aggregates that do not fit the vector calling convention.
- ICE
- Internal Compiler Error. A condition where the compiler encounters an unexpected state or bug during compilation, causing it to abort.
- VLS calling convention
- A specific calling convention used on RISC-V architectures, likely related to vector operations or specific ABI requirements. The 'VLS' likely denotes a specific variant or feature set.
- aggregate
- A data structure that groups together multiple members, such as a struct or class in C++.
- NULL_RTX
- Represents a null or invalid value within GCC's internal representation (RTX), typically used to indicate the absence of a valid machine-dependent value.