Bug 47427 - [4.6 Regression] ICE in process_constraint, at tree-ssa-structalias.c:2901
Summary: [4.6 Regression] ICE in process_constraint, at tree-ssa-structalias.c:2901
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: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-24 04:10 UTC by John Regehr
Modified: 2011-02-02 17:46 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: 2011-01-24 05:29:08


Attachments
gcc46-pr47427.patch (1.10 KB, patch)
2011-01-24 14:02 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Regehr 2011-01-24 04:10:57 UTC
[regehr@gamow tmp443]$ current-gcc -c -O3 small.c

small.c: In function 'foo':
small.c:20:6: internal compiler error: in process_constraint, at tree-ssa-structalias.c:2901
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

[regehr@gamow tmp443]$ current-gcc -v

Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r169143-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-r169143-install --program-prefix=r169143- --enable-languages=c,c++
Thread model: posix
gcc version 4.6.0 20110123 (experimental) (GCC) 

[regehr@gamow tmp443]$ cat small.c


long g_128;
int *g;

int func_73 (unsigned char p_74, const int p_75)
{
 lbl_159:for (; g_128; g = (int *)g_128)
    for (g = 0; g_128; g_128++)
      {
	int l_144 = 1;
	if (g_128)
	  {
	    if (l_144)
	      goto lbl_159;
	    return p_75;
	  }
      }
  return p_74;
}

void foo (void)
{
  if (func_73 (0, 1))
    func_73 (1, 0);
}
Comment 1 H.J. Lu 2011-01-24 05:29:08 UTC
It is cause by revision 165641:

http://gcc.gnu.org/ml/gcc-cvs/2010-10/msg00826.html
Comment 2 Jakub Jelinek 2011-01-24 12:50:47 UTC
I think this is pretty much the same issue as PR47428, except in this case it is not a PHI in which such a replacement is made, but for y_9 = 0; given that y is argument declared const the inliner replaces it with 1 = 0;.
So perhaps the PR47428 patch isn't the right fix.

The reason why y_9 is on the LHS of a set is copyrename.  I guess a fix could be either not doing copyrename if an SSA_NAME of a TREE_READONLY var would be on the LHS of an assignment or result of a PHI, or drop the TREE_READONLY from the parameter in such a case (but that would result in us dropping such info in debug info), or avoid the optimization
  /* If the parameter is never assigned to, has no SSA_NAMEs created,
     we would not need to create a new variable here at all, if it
     weren't for debug info.  Still, we can just use the argument
     value.  */
  if (TREE_READONLY (p)
      ...
in setup_one_parameter.

Richard/Honza, what do you think?
Comment 3 rguenther@suse.de 2011-01-24 12:59:58 UTC
On Mon, 24 Jan 2011, jakub at gcc dot gnu.org wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47427
> 
> Jakub Jelinek <jakub at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |hubicka at gcc dot gnu.org,
>                    |                            |jakub at gcc dot gnu.org
> 
> --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-24 12:50:47 UTC ---
> I think this is pretty much the same issue as PR47428, except in this case it
> is not a PHI in which such a replacement is made, but for y_9 = 0; given that y
> is argument declared const the inliner replaces it with 1 = 0;.
> So perhaps the PR47428 patch isn't the right fix.

copyrename shouldn't do this (coalesce to TREE_READONLY vars - it also
doesn't seem to not coalesce to TREE_THIS_VOLATILE vars, though those
shouldn't be in SSA form).

> The reason why y_9 is on the LHS of a set is copyrename.  I guess a fix could
> be either not doing copyrename if an SSA_NAME of a TREE_READONLY var would be
> on the LHS of an assignment or result of a PHI, or drop the TREE_READONLY from
> the parameter in such a case (but that would result in us dropping such info in
> debug info), or avoid the optimization
>   /* If the parameter is never assigned to, has no SSA_NAMEs created,
>      we would not need to create a new variable here at all, if it
>      weren't for debug info.  Still, we can just use the argument
>      value.  */
>   if (TREE_READONLY (p)
>       ...
> in setup_one_parameter.
> 
> Richard/Honza, what do you think?

Fix copyrename.

Richard.
Comment 4 Jakub Jelinek 2011-01-24 14:02:05 UTC
Created attachment 23099 [details]
gcc46-pr47427.patch

Untested fix.
Comment 5 Jakub Jelinek 2011-01-25 12:01:57 UTC
Author: jakub
Date: Tue Jan 25 12:01:54 2011
New Revision: 169226

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169226
Log:
	PR tree-optimization/47427
	PR tree-optimization/47428
	* tree-ssa-copyrename.c (copy_rename_partition_coalesce): Don't
	coalesce if the new root var would be TREE_READONLY.

	* gcc.c-torture/compile/pr47427.c: New test.
	* gcc.c-torture/compile/pr47428.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr47427.c
    trunk/gcc/testsuite/gcc.c-torture/compile/pr47428.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-copyrename.c
Comment 6 Jakub Jelinek 2011-01-25 12:46:19 UTC
Fixed.
Comment 7 Diego Novillo 2011-02-02 17:46:08 UTC
Author: dnovillo
Date: Wed Feb  2 17:46:04 2011
New Revision: 169577

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169577
Log:
	PR tree-optimization/47427
	PR tree-optimization/47428
	* tree-ssa-copyrename.c (copy_rename_partition_coalesce): Don't
	coalesce if the new root var would be TREE_READONLY.

	* gcc.c-torture/compile/pr47427.c: New test.
	* gcc.c-torture/compile/pr47428.c: New test.

Added:
    branches/google/integration/gcc/testsuite/gcc.c-torture/compile/pr47427.c
    branches/google/integration/gcc/testsuite/gcc.c-torture/compile/pr47428.c
Modified:
    branches/google/integration/gcc/ChangeLog
    branches/google/integration/gcc/testsuite/ChangeLog
    branches/google/integration/gcc/tree-ssa-copyrename.c