On 10/1/26 06:43, Uros Bizjak wrote:
On Thu, Oct 1, 2026 at 12:46 AM Oleg Tolmatcev <[email protected]> wrote:

For an MS ABI va_list, ix86_gimplify_va_arg calls
std_gimplify_va_arg_expr, which asks the pass_by_reference hook whether
the argument was passed by reference.  Without cumulative args, the hook
assumes the default ABI, SysV on Linux, so va_arg reads an argument
passed by reference as if it were passed by value.

Split the ABI-specific decision out of ix86_pass_by_reference.  For an
indirect MS ABI argument, follow ia64_gimplify_va_arg: use the standard
va_arg helper to read its pointer and then dereference it.  Use the
explicit SysV ABI for a SysV va_list so the opposite target-default
mismatch is handled as well.

gcc/ChangeLog:

         * config/i386/i386.cc (ix86_pass_by_reference_abi): New function,
         split out of ...
         (ix86_pass_by_reference): ... this.
         (ix86_gimplify_va_arg): Derive argument indirection from the ABI of
         the va_list type.  Read indirect MS ABI arguments as pointers.

gcc/testsuite/ChangeLog:

         * gcc.target/i386/va-arg-abi-attribute.c: New test.

OK.

For future contributions, please state how you tested the patch, see
[1]. Also, if you don't have write access, please point out lack of
write access in your initial submission, as also advised in [1].

[1] https://gcc.gnu.org/contribute.html#patches

Thanks,
Uros.

Can these be pushed or are there any further review? I also don't see the v2 second patch anywhere.

Reply via email to