This is the mail archive of the gcc-patches@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]

[PATCH,RFC] Do not assign stack slots to ssa names


Hi,

When processing stack vars partitions for alias export patch, I have
noticed that sometimes we get SSA_NAMEs being allocated on stack, e.g.
V2SF vectors.  Richard suggested the attached patch to fix it.  The
patch is bootstrapped and tested (Ada enabled) on x86-64.  The only
failing test is stack protector test ssp-2.c, in which an array and a
loop counter get allocated on stack in a different order and thus
instead of overflowing the array the test overflows the loop counter and
hangs.  So I've also fixed the test.

Michael, what do you think of the patch?
Andrey


2009-06-10  Richard Guenther  <rguenther@suse.de>
	    Andrey Belevantsev  <abel@ispras.ru>

	* cfgexpand.c (expand_one_var): Do not call add_stack_var when original
variable is an SSA name.

	* testsuite/gcc.dg/ssp-2.c (overflow): Make i global.


Index: gcc/testsuite/gcc.dg/ssp-2.c
===================================================================
*** gcc/testsuite/gcc.dg/ssp-2.c        (revision 148346)
--- gcc/testsuite/gcc.dg/ssp-2.c        (working copy)
*************** __stack_chk_fail (void)
*** 11,20 ****
    exit (0); /* pass */
  }

  void
  overflow()
  {
-   int i = 0;
    char foo[30];

    /* Overflow buffer.  */
--- 11,21 ----
    exit (0); /* pass */
  }

+ static int i;
+
  void
  overflow()
  {
    char foo[30];

    /* Overflow buffer.  */
Index: gcc/cfgexpand.c
===================================================================
*** gcc/cfgexpand.c     (revision 148346)
--- gcc/cfgexpand.c     (working copy)
*************** expand_one_var (tree var, bool toplevel,
*** 1212,1218 ****
        if (really_expand)
          expand_one_register_var (origvar);
      }
!   else if (defer_stack_allocation (var, toplevel))
      add_stack_var (origvar);
    else
      {
--- 1212,1219 ----
        if (really_expand)
          expand_one_register_var (origvar);
      }
!   else if (defer_stack_allocation (var, toplevel)
!          && TREE_CODE (origvar) != SSA_NAME)
      add_stack_var (origvar);
    else
      {





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