i386: Use classify_argument for variadic vector arguments
Fixes stack argument passing for unnamed 256/512-bit vector arguments in variadic functions on x86.
This commit corrects how unnamed 256-bit and 512-bit vector arguments are passed on the stack in variadic functions on the i386 architecture. Previously, explicit mode checks were insufficient, leading to incorrect argument retrieval by va_arg. By replacing these checks with classify_argument, which correctly determines if an argument should occupy a YMM/ZMM register, the compiler now ensures these arguments are consistently pushed onto the stack, preventing data corruption or crashes.
In Details
PR128640 highlights an issue with unnamed 256/512-bit vector arguments in variadic functions on i386. The existing logic in function_arg_advance_64, function_arg_64, and ix86_gimplify_va_arg used explicit mode checks. However, classify_argument is the definitive source for determining register usage for SSE/SSEUP arguments, including BLKmode aggregates with vector modes. This patch replaces the explicit mode checks with calls to classify_argument to correctly identify when such arguments should be stack-passed, and adds assertions to classify_argument's wrapper to verify its behav…
- variadic function
- A function that can accept an arbitrary number of arguments, indicated by an ellipsis (...) in its declaration.
- va_arg
- A macro used to access arguments passed to a variadic function.
- YMM/ZMM register
- AVX and AVX-512 registers, respectively, used for SIMD operations, typically 256-bit and 512-bit wide.
- BLKmode
- GCC's internal representation mode for generic blocks of memory or structures.
- SSE/SSEUP
- Streaming SIMD Extensions and its subsequent updates, instruction set extensions for performing SIMD operations.