This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

stack height reduction in tree-SSA


Hi,

  Sharing stack space for objects with disjoint
lifetimes is a well known problem with GCC (especially
for the kernel people). Consider the code

  if (i)
    {
      char a[100];
      use (a);
    }
  else
    {
      char b[100];
      use (b);
    }

Apparantly, 'a' and 'b' can share same stack slot. I feel
that this problem could have been fixed in tree-SSA, but
exactly opposite is done. During 'lower' pass, record_vars
saves the variable declarations in a link list, which are
later expanded to RTL during RTL generation pass in expand_vars.
Below is the dump of 'lower' pass for the above test case.

foo (i)
{
  char b[100];
  char a[100];

  if (i != 0) goto <D1052>; else goto <D1053>;
  <D1052>:;
  use (&a);
  goto <D1054>;
  <D1053>:;
  use (&b);
  <D1054>:;
  return;
}

Is it that good to forget the scope of variable and allocate each
one a new stack slot? I'm unable to get any reasons why the stack
slots can't be shared. Please make me aware of the issues involved.

Thanks and Regards,
Rakesh Kumar


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]