Re: [PATCH v2] x86: Check DECL_INCOMING_RTL for argument passing check

Hongtao Liu <[email protected]> Tue, 4 Aug 2026 15:01:42 +0800
Newsgroups gmane.comp.gcc.patches
Message-ID <CAMZc-bz6j3YaHk+=M=cqnCUNHgp7RV1Mba_Y7ciMJZ+kQzifEA@mail.gmail.com>
On Sun, Aug 2, 2026 at 2:34 PM H.J. Lu <[email protected]> wrote:
>
> On Sat, Aug 1, 2026 at 4:49 PM Uros Bizjak <[email protected]> wrote:
> >
> > On Sat, Aug 1, 2026 at 5:12 AM H.J. Lu <[email protected]> wrote:
> > >
> > > When checking if a register argument is used as local variable, also
> > > return true if non-local variable is the source of the argument-linked
> > > memory store.
> > >
> > > gcc/
> > >
> > > PR target/126529
> > > * config/i386/i386.cc (ix86_spill_register_argument_p): Also
> > > check non-local variable source for the argument-linked memory
> > > store.
> > >
> > > gcc/testsuite/
> > >
> > > PR target/126529
> > > * gcc.target/i386/pr126529.c: New test.
> >
> > This is the third patch in the same area, so it IMO points to a more
> > systematic issue. Please find someone else that is able to thoroughly
> > review the patch (and the core issue that lies behind these problems)
> > from the generic middle-end side of the compiler.
> >
> > Uros.
>
> Here is the v2 patch to check the argument's  DECL_INCOMING_RTL
> instead.

  /* Return true if OP is passed in memory.  */
  return MEM_P (DECL_INCOMING_RTL (var));

DECL_INCOMING_RTL mean param_decl in stack, callee can also take the
parameter as local variable and put it in it's own stack, but looks
like at assign_stack_local have already handled that case, and here in
ix86_find_max_used_stack_alignment it just raise the requirement, not
lower that. So it seems ok.
Better to add more explanation in the comment.
Also to be defensive, avoid NULL for DECL_INCOMING_RTL (var), change it to
  return DECL_INCOMING_RTL (var) && MEM_P (DECL_INCOMING_RTL (var));
?

Others LGTM.
>
> --
> H.J.
> ---
> If an argument's DECL_INCOMING_RTL is a memory operand, it is passed on
> stack by caller.  Change ix86_argument_passed_on_stack_p to return true
> if the argument's DECL_INCOMING_RTL is a memory operand.
>
> gcc/
>
> PR target/126529
> PR target/126450
> PR target/126320
> * config/i386/i386.cc (ix86_spill_register_argument_p): Removed.
> (ix86_argument_passed_on_stack_p): Remove the second argument.
> Return true if the argument's DECL_INCOMING_RTL is a memory
> operand.
> (ix86_update_stack_alignment): Updated.
>
> gcc/testsuite/
>
> PR target/126529
> PR target/126450
> PR target/126320
> * gcc.target/i386/pr126529-1.c: New test.
> * gcc.target/i386/pr126529-2.c: Likewise.
> * gcc.target/i386/pr126529-3.c: Likewise.
> * gcc.target/i386/pr126529-4.c: Likewise.
>
>
> --
> H.J.



-- 
BR,
Hongtao