Bug 44030 - [4.6 Regression] error: SSA name in freelist but still referenced
Summary: [4.6 Regression] error: SSA name in freelist but still referenced
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-07 19:53 UTC by John Regehr
Modified: 2010-05-08 13:13 UTC (History)
4 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2010-05-07 21:14:23


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Regehr 2010-05-07 19:53:06 UTC
[regehr@bethe tmp601]$ current-gcc -v
Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r159144-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --with-libelf=/usr/local --enable-lto --prefix=/home/regehr/z/compiler-install/gcc-r159144-install --program-prefix=r159144- --enable-languages=c,c++
Thread model: posix
gcc version 4.6.0 20100507 (experimental) (GCC) 

[regehr@bethe tmp601]$ current-gcc -O2 -c small.c

small.c: In function 'func':
small.c:14:1: error: SSA name in freelist but still referenced
pretmp.6_10
small.c:24:7: note: in statement
g_54.1_5 = pretmp.6_10;

small.c:14:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

[regehr@bethe tmp601]$ cat small.c

typedef int int32_t;
typedef unsigned int uint32_t;
static uint32_t
safe_sub_func_uint32_t_u_u (uint32_t ui1, uint32_t ui2)
{
  return ui1 - ui2;
}

int32_t l_105[7];

int32_t g_4;
int32_t *g_54 = &g_4;
int32_t *
func (int32_t p_73, int32_t * p_74, int32_t p_75, int32_t * *p_76,
      int32_t * *p_77)
{
lbl_110:for (g_4 = 0; g_4; g_4 = 1)
    {
    }
  for (p_75 = -28; p_75; p_75 = safe_sub_func_uint32_t_u_u (p_75, 1))
    {
      if (g_4)
	goto lbl_110;
      *g_54 = 0;
    }
  return &l_105[5];
}
Comment 1 H.J. Lu 2010-05-07 20:52:13 UTC
It is caused by revision 159106:

http://gcc.gnu.org/ml/gcc-cvs/2010-05/msg00156.html
Comment 2 Richard Biener 2010-05-07 20:57:27 UTC
Confirmed.

Found partial redundancy for expression {g_54}@.MEM_13(D) (0003)
Inserted pretmp.6_26 = g_54;
 in predecessor 6
Created phi prephitmp.7_20 = PHI <g_54.1_5(8), pretmp.6_26(6)>
 in block 3
Found partial redundancy for expression {g_54}@.MEM_13(D) (0003)
Inserted pretmp.6_10 = g_54;
 in predecessor 2
Created phi prephitmp.7_15 = PHI <pretmp.6_10(2), prephitmp.7_20(7)>
 in block 6
Replaced redundant PHI node defining prephitmp.7_20 with prephitmp.7_15
Replaced g_54 with prephitmp.7_15 in g_54.1_5 = g_54;
Replaced redundant PHI node defining prephitmp.7_15 with pretmp.6_10
Removing unnecessary insertion:pretmp.6_10 = g_54;
Removing unnecessary insertion:pretmp.6_26 = g_54;

oops.  It looks like the necessity propagation does not work for
the prephitmp.7_15 replacement.

Before eliminate():

lbl_110:
  g_4 = 0;
  pretmp.6_10 = g_54;
  goto <bb 6>;

<bb 8>:

<bb 3>:
  # p_75_22 = PHI <p_75_8(8), -28(6)>
  # prephitmp.7_20 = PHI <g_54.1_5(8), pretmp.6_26(6)>
  g_4.0_4 = g_4;
  if (g_4.0_4 != 0)
    goto <bb 7>;
  else
    goto <bb 4>;

<bb 4>:
  g_54.1_5 = g_54;
  *g_54.1_5 = 0;
  p_75.2_6 = (uint32_t) p_75_22;
  D.1987_17 = p_75.2_6 + 0x0ffffffff;
  p_75_8 = (int32_t) D.1987_17;
  if (p_75_8 != 0)
    goto <bb 8>;
  else
    goto <bb 5>;

<bb 5>:
  return &l_105[5];

<bb 6>:
  # prephitmp.7_15 = PHI <pretmp.6_10(2), prephitmp.7_20(7)>
  pretmp.6_26 = g_54;
  goto <bb 3>;

<bb 7>:
  g_4 = 0;
  goto <bb 6>;


and before remove_dead_inserted_code():

lbl_110:
  g_4 = 0;
  pretmp.6_10 = g_54;
  goto <bb 6>;

<bb 8>:

<bb 3>:
  # p_75_22 = PHI <p_75_8(8), -28(6)>
  g_4.0_4 = g_4;
  if (g_4.0_4 != 0)
    goto <bb 7>;
  else
    goto <bb 4>;

<bb 4>:
  g_54.1_5 = pretmp.6_10;
  *g_54.1_5 = 0;
  p_75.2_6 = (uint32_t) p_75_22;
  D.1987_17 = p_75.2_6 + 0x0ffffffff;
  p_75_8 = (int32_t) D.1987_17;
  if (p_75_8 != 0)
    goto <bb 8>;
  else
    goto <bb 5>;

<bb 5>:
  return &l_105[5];

<bb 6>:
  pretmp.6_26 = g_54;
  goto <bb 3>;

<bb 7>:
  g_4 = 0;
  goto <bb 6>;
Comment 3 Richard Biener 2010-05-07 21:14:23 UTC
I have a patch.
Comment 4 Richard Biener 2010-05-08 13:13:12 UTC
Subject: Bug 44030

Author: rguenth
Date: Sat May  8 13:12:56 2010
New Revision: 159186

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159186
Log:
2010-05-08  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/44030
	* tree-ssa-pre.c (eliminate): Copy NECESSARY flag.  Set
	NECESSARY flag if we propagate from a inserted expression.

	* gcc.c-torture/compile/pr44030.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr44030.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-pre.c

Comment 5 Richard Biener 2010-05-08 13:13:31 UTC
Fixed.