On Wed, Apr 03, 2024 at 01:18:54PM +0800, Kewen.Lin wrote:
> > I'd prefer not to remove DECL_ARGUMENTS chains, they are valid arguments 
> > that just some
> > invalid code doesn't pass.  By removing them you basically always create an
> > invalid case, this time in the other direction, valid caller passes more
> > arguments than the callee (invalidly) expects.
> 
> Thanks for the comments, do you mean it can affect the arguments validation 
> when there
> is explicit function declaration with interface?  Then can we strip them when 
> we are
> going to expand them (like checking currently_expanding_function_start)?

I'd prefer not stripping them at all; they are clearly marked as perhaps not
passed in buggy programs (the DECL_HIDDEN_STRING_LENGTH argument) and
removing them implies the decl is a throw away, that after expansion
nothing will actually look at it anymore.  I believe that is the case of
function bodies, we expand them into RTL and throw away the GIMPLE, and
after final clear the bodies, but it is not the case of the FUNCTION_DECL
or its DECL_ARGUMENTs etc.  E.g. GIMPLE optimizations or expansion of
callers could be looking at those as well.

> since from the
> perspective of resulted assembly, with this workaround, the callee can:
>   1) pass the hidden args in unexpected GPR like r11, ... at -O0;
>   2) get rid of such hidden args as they are unused at -O2;
> This proposal aims to make the assembly at -O0 not to pass with r11... (same 
> as -O2),
> comparing to the assembly at O2, the mismatch isn't actually changed.

The aim for the workaround was just avoid assuming there is a argument save
area in the caller stack when it is sometimes missing.
If you are looking for optimizations where nothing actually passes the
unneeded arguments and nothing expects them to be passed, then it is a task
for IPA optimizations and should be done solely if IPA determines that all
callers can be adjusted together with the callee; I think IPA already does
that in that case for years, regardless if it is DECL_HIDDEN_STRING_LENGTH
PARM_DECL or not.

        Jakub

Reply via email to