Bug 28544 - [4.2 regression] ICE in add_virtual_operand, at tree-ssa-operands.c:1309
Summary: [4.2 regression] ICE in add_virtual_operand, at tree-ssa-operands.c:1309
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P1 normal
Target Milestone: 4.2.0
Assignee: Daniel Berlin
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2006-07-30 08:17 UTC by Martin Michlmayr
Modified: 2007-03-12 13:42 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.0.3 4.1.1 4.1.2 4.3.0
Known to fail: 4.2.0
Last reconfirmed: 2007-02-01 16:40:06


Attachments
test case (344 bytes, text/plain)
2006-09-02 07:57 UTC, Martin Michlmayr
Details
Different code triggering the same error (107.79 KB, application/x-bzip2)
2006-11-27 07:28 UTC, bero
Details
access_debugging.diff (556 bytes, application/octet-stream)
2006-11-27 08:24 UTC, Daniel Berlin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Michlmayr 2006-07-30 08:17:57 UTC
I get the following gcc 4.2 regression:

11031:tbm@deprecation: ~] /usr/lib/gcc-snapshot/bin/g++ -c -O2 mysql-sp_cache.cc
mysql-sp_cache.cc: In function 'void sp_cache_invalidate()':
mysql-sp_cache.cc:20: internal compiler error: in add_virtual_operand, at tree-ssa-operands.c:1309
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
11032:tbm@deprecation: ~] /usr/lib/gcc-snapshot/bin/g++ -c -O mysql-sp_cache.cc
11033:tbm@deprecation: ~] g++-4.1 -c -O2 mysql-sp_cache.cc
11034:tbm@deprecation: ~] g++-4.0 -c -O2 mysql-sp_cache.cc
11035:tbm@deprecation: ~] cat mysql-sp_cache.cc
extern "C"
{
  extern "C"
  {
    typedef unsigned long int ulong;
  }
  typedef struct
  {
    volatile int counter;
  }
  atomic_t;
  static __inline__ void atomic_inc (atomic_t * v)
  {
    __asm__ __volatile__ ("lock ; "
                          "incl %0":"=m" (v->counter):"m" (v->counter));
  }
}
static ulong volatile Cversion = 0;
void
sp_cache_invalidate ()
{
  atomic_inc ((atomic_t *) & Cversion);
}
Comment 1 Andrew Pinski 2006-07-30 08:23:10 UTC
First I like to say this is violating C++ aliasing rules but that is a different story.

Second this is most likely a dup of bug 28479.
Comment 2 Martin Michlmayr 2006-07-30 08:25:31 UTC
(In reply to comment #1)
> First I like to say this is violating C++ aliasing rules but that is a
> different story.
> 
> Second this is most likely a dup of bug 28479.

Are you sure you got that bug number right?  I'm seeing this ICE not just with current 4.2 but also from many months ago (will try to narrow down a date in a minute).
Comment 3 Martin Michlmayr 2006-07-30 08:29:39 UTC
Reproducible with gcc 4.2.0 way back to 20060325.  I've nothing older around right now.
Comment 4 Andrew Pinski 2006-07-30 08:56:49 UTC
Oh, yes it is unrelated to that PR.  In fact I think the aliasing violating causes the problem.
Comment 5 Andrew Pinski 2006-07-30 09:14:23 UTC
Confirmed (reduced C and C++ testcases:
typedef unsigned long int ulong;
typedef struct
{
  volatile int counter;
}atomic_t;
static ulong volatile Cversion = 0;
void
sp_cache_invalidate ()
{
  atomic_t * v1 = (atomic_t *)& Cversion;
  atomic_t * v = v1;
  __asm__ __volatile__ ("lock ; incl %0":"=m" (v->counter):"m" (v->counter));
}
Comment 6 Andrew Pinski 2006-07-30 09:15:12 UTC
Even without the volatile, it ICEs:
typedef unsigned long int ulong;
typedef struct
{
  int counter;
}atomic_t;
static ulong Cversion = 0;
void
sp_cache_invalidate ()
{
  atomic_t * v1 = (atomic_t *)& Cversion;
  atomic_t * v = v1;
  __asm__ __volatile__ ("lock ; incl %0":"=m" (v->counter):"m" (v->counter));
}
Comment 7 Janis Johnson 2006-08-08 10:24:32 UTC
A regression hunt using an i686-linux cross compiler with the testcase from comment #6 identified the following patch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=111300

    r111300 | dberlin | 2006-02-20 13:38:01 +0000 (Mon, 20 Feb 2006)
Comment 8 Daniel Berlin 2006-08-09 09:08:07 UTC
I can trivially fix this, but the code isn't going to do what you want when i'm done, since it is an aliasing violation :)

The assert in question just happens to be good at catching them.
Comment 9 Martin Michlmayr 2006-09-02 07:57:01 UTC
Here's another testcase.  It fails at -O3.  Is this code problematic too?


(sid)45:tbm@usurper: ~] /usr/lib/gcc-snapshot/bin/g++ -c -O3 p7zip-SHA256.cc
p7zip-SHA256.cc: In member function 'void NCrypto::NSHA256::SHA256::WriteByteBlock()':
p7zip-SHA256.cc:16: internal compiler error: in add_virtual_operand, at tree-ssa-operands.c:1309
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
zsh: exit 1     /usr/lib/gcc-snapshot/bin/g++ -c -O3 p7zip-SHA256.cc
(sid)46:tbm@usurper: ~] /usr/lib/gcc-snapshot/bin/g++ -c -O2 p7zip-SHA256.cc
(sid)47:tbm@usurper: ~]
Comment 10 Martin Michlmayr 2006-09-02 07:57:37 UTC
Created attachment 12174 [details]
test case

Testcase from application "p7zip".
Comment 11 Andrew Pinski 2006-09-02 10:59:51 UTC
(In reply to comment #9)
> Here's another testcase.  It fails at -O3.  Is this code problematic too?
No it is not problematic but it is a different bug.  Can you file it seperately?
Comment 12 Martin Michlmayr 2006-09-02 11:04:14 UTC
(In reply to comment #11)
> (In reply to comment #9)
> > Here's another testcase.  It fails at -O3.  Is this code problematic too?
> No it is not problematic but it is a different bug.  Can you file it
> seperately?

Sure, PR28937
Comment 13 Martin Michlmayr 2006-10-15 03:31:42 UTC
(In reply to comment #8)
> I can trivially fix this, but the code isn't going to do what you want when i'm
> done, since it is an aliasing violation :)
> 
> The assert in question just happens to be good at catching them.

*ping*
Comment 14 bero 2006-11-27 07:28:12 UTC
Created attachment 12700 [details]
Different code triggering the same error

Different code extracted from dirac, triggering the same error (goes away with -fno-strict-aliasing)
Comment 15 Daniel Berlin 2006-11-27 08:24:40 UTC
Subject: Re:  [4.2 regression] ICE in add_virtual_operand, at tree-ssa-operands.c:1309

I assume the attached fixes this?


On 15 Oct 2006 09:01:42 -0000, tbm at cyrius dot com
<gcc-bugzilla@gcc.gnu.org> wrote:
>
>
> ------- Comment #13 from tbm at cyrius dot com  2006-10-15 09:01 -------
> (In reply to comment #8)
> > I can trivially fix this, but the code isn't going to do what you want when i'm
> > done, since it is an aliasing violation :)
> >
> > The assert in question just happens to be good at catching them.
>
> *ping*
>
>
> --
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28544
>
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.
> You are the assignee for the bug, or are watching the assignee.
>
Comment 16 Daniel Berlin 2006-11-27 08:24:40 UTC
Created attachment 12701 [details]
access_debugging.diff
Comment 17 Richard Biener 2007-02-01 11:10:06 UTC
Still fails on the 4.2 branch.
Comment 18 Richard Biener 2007-02-01 11:11:12 UTC
And yes, the attached fixes it.
Comment 19 Jack Howarth 2007-02-04 11:53:25 UTC
Did the patch fixing this on gcc 4.2 branch get posted to the gcc-patches mailing list?
Comment 20 Mark Mitchell 2007-02-19 18:03:51 UTC
Is there a backport of the mainline patch that I could review, or ask another maintainer to review for inclusion in 4.2?

Thanks,

-- Mark
Comment 21 Daniel Berlin 2007-02-19 18:11:55 UTC
(In reply to comment #20)
> Is there a backport of the mainline patch that I could review, or ask another
> maintainer to review for inclusion in 4.2?
> 
> Thanks,
> 
> -- Mark
> 

The attached patch named "access_debugging.diff" should apply and work for 4.2.
Let me know if you would like it there.
Comment 22 Mark Mitchell 2007-03-12 12:57:52 UTC
Danny, please apply the patch to 4.2.0.

Thanks,

-- Mark
Comment 23 Daniel Berlin 2007-03-12 13:39:23 UTC
Subject: Bug 28544

Author: dberlin
Date: Mon Mar 12 19:09:05 2007
New Revision: 122857

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122857
Log:
2007-03-12  Daniel Berlin  <dberlin@dberlin.org>
	
	Fix PR tree-optimization/28544
	* tree-ssa-operands.c (add_virtual_operand):
	Move assert triggering on aliasing violations into
	debugging define



Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/tree-ssa-operands.c

Comment 24 Daniel Berlin 2007-03-12 13:42:11 UTC
Fixed