> -----Original Message-----
> From: H.J. Lu <[email protected]>
> Sent: Saturday, August 8, 2026 6:57 AM
> To: Hongtao Liu <[email protected]>
> Cc: GCC Patches <[email protected]>; Uros Bizjak
> <[email protected]>; Liu, Hongtao <[email protected]>
> Subject: [GCC 16, PATCH] x86: Check DECL_INCOMING_RTL for argument
> passing check
> 
> On Tue, Aug 4, 2026 at 3:02 PM H.J. Lu <[email protected]> wrote:
> >
> > On Tue, Aug 4, 2026 at 2:40 PM Hongtao Liu <[email protected]> wrote:
> > >
> > > 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));
> > > ?
> >
> > Here is the patch I am checking in.  I copied DECL_INCOMING_RTL
> > comments from tree.h:
> >
> > static bool
> > ix86_argument_passed_on_stack_p (const_rtx op) {
> >   tree mem_expr = MEM_EXPR (op);
> >   if (!mem_expr)
> >     return false;
> >
> >   tree var = get_base_address (mem_expr);
> >   if (TREE_CODE (var) != PARM_DECL)
> >     return false;
> >
> >   /* For PARM_DECL, DECL_INCOMING_RTL holds an RTL for the stack slot
> >      or register where the data was actually passed.  Return true if
> >      OP is passed in memory.  */
> >   return DECL_INCOMING_RTL (var) && MEM_P (DECL_INCOMING_RTL
> (var)); }
> >
> > > Others LGTM.
> 
> OK for backport to GCC 16?

Ok.
> 
> Thanks.
> 
> --
> H.J.

Reply via email to