https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831

--- Comment #36 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note that if we'd want to "preallocate" (or re-use) variables for argument
slots we have to properly arrange them according to the ABI.  Consider
a function taking more than just a single argument [passed on stack] which
we might still able to handle optimally [with greater difficulty].

Jasons C++ example expands from

  D.2368 = {};
  D.2368.i[0] = 1;
  f (D.2368);

if you modify that to

struct A { int i[100]; };
void f(int i, struct A, int j);
int main()
{
  f(0, (struct A){1}, 2);
}

then on i?86 both extra arguments are passed on the stack as well but
RTL expansion sees again

  D.2370 = {};
  D.2370.i[0] = 1;
  f (0, D.2370, 2);

but clearly we cannot just allocate D.2370 in a random place if it is
passed on the stack (on i?86 it's passed by reference).  For example

struct A { int i[2]; };
void f(struct A);
int main()
{
  f((struct A){1});
}

expanded as

  MEM <char[4]> [(struct A *)&D.1960 + 4B] = {};
  D.1960.i[0] = 1;
  f (D.1960);

is passed on the stack though.  So if we want to expose anything on GIMPLE
then we have to make the argument space on the stack distinct from random
stack variables.

Reply via email to