RISC-V: Always record largest type for conv-dynamic [PR128841].
RISC-V compiler ensures a default type is recorded for 'conv-dynamic' even if unusable, preventing crashes.
This commit fixes a bug in the RISC-V vector compiler related to the -mrvv-max-lmul=conv-dynamic option. Previously, if all available types were deemed unusable for this dynamic LMUL (vector length multiplier) setting, the compiler would simply return without recording any type. This could lead to a NULL pointer dereference when later accessing the ‘largest_type’. The fix ensures that a char type is always recorded as a fallback, preventing the crash and allowing compilation to proceed.
In Details
In riscv-vector-costs.cc, the costs::record_type_sizes function for -mrvv-max-lmul=conv-dynamic previously returned early if type was unusable. This could lead to largest_type being NULL if all types were unusable. The fix guarantees that a char type is always recorded as largest_type in such cases, providing a non-NULL fallback even if LMUL cannot be dynamically increased.
- RISC-V
- A modular and extensible open-standard Instruction Set Architecture (ISA) based on Reduced Instruction Set Computing principles.
- conv-dynamic
- A RISC-V vector compilation option that allows the vector length multiplier (LMUL) to be determined dynamically at runtime, potentially optimizing for different vector lengths.
- LMUL
- The Vector Length Multiplier in RISC-V vector processing. It scales the vector register size, allowing a single vector register to hold multiple basic vector elements.
- largest_type
- In the context of RISC-V vector compilation, this likely refers to the largest data type that can be accommodated by the vector registers under certain constraints or configurations.
- PR128841
- A problem report (bug tracker ID) indicating a specific issue that has been fixed.