Bug 43690 - [4.4 Regression] Internal compiler error detected by avr-gcc.
Summary: [4.4 Regression] Internal compiler error detected by avr-gcc.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: unknown
: P2 normal
Target Milestone: 4.4.7
Assignee: Jakub Jelinek
URL:
Keywords: diagnostic, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2010-04-08 15:01 UTC by Philippe Hoogvorst
Modified: 2011-07-12 05:55 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.6, 4.5.2, 4.6.0
Known to fail: 4.1.2, 4.3.4, 4.4.4, 4.5.0
Last reconfirmed: 2010-04-08 15:11:43


Attachments
gcc46-pr43690.patch (668 bytes, patch)
2010-04-12 09:44 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Hoogvorst 2010-04-08 15:01:38 UTC
========================================================================================
> avr-gcc -v
Using built-in specs.
Target: avr
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodi--mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enabystem-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking--build=i486-linux-gnu --host=i486-linux-gnu --target=avr
Thread model: single
gcc version 4.3.4 (GCC) 
========================================================================================
Minimal source code causing the bug, removing any token makes the compiler work OK. No header is to be included into this code to see the bug.
-----------
void doit( )
{
    char *pk=0 ;
    for(;;)
    {
        asm ( "nop" : :"m"(pk++) );
        asm ( "nop" : :"m"(pk++) );
    }
}
========================================================================================
> avr-gcc -Wall -mmcu=atmega128 -O3  -c -o /dev/null  /tmp/present-wddl-both-encrypt.c
/tmp/present-wddl-both-encrypt.c: In function ‘doit’:
/tmp/present-wddl-both-encrypt.c:2: internal compiler error: in copy_reference_ops_from_ref, at tree-ssa-sccvn.c:577
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
========================================================================================
Note that removing "-Wall" does not remove the bug but that removing "-O3" makes the compiler work OK.

Best regards.
Comment 1 Richard Biener 2010-04-08 15:11:43 UTC
Well, we have not properly gimplified the invalid function:

doit ()
{
  char * pk;
  char * pk.1;
  char * pk.0;

<bb 2>:
  pk = 0B;

<bb 3>:
  __asm__ __volatile__("nop"::"m" pk);
  pk = pk + 1;
  pk.0 = pk;
  __asm__ __volatile__("nop"::"m" pk.0);
  pk.1 = pk.0 + 1;
  pk = pk.1;
  goto <bb 3>;


pk is addressable, so pk + 1 needs to load from pk first.

3.4.x prints

t.i: In function `doit':
t.i:6: warning: use of memory input without lvalue in asm operand 0 is deprecated
t.i:7: warning: use of memory input without lvalue in asm operand 0 is deprecated
t.i:6: error: impossible constraint in `asm'
t.i:7: error: impossible constraint in `asm'

so we ICE on the invalid asm.

We also fail to diagnose this with newer compilers (but the gimple verifier
triggers with checking enabled).
Comment 2 Jakub Jelinek 2010-04-12 09:44:31 UTC
Created attachment 20362 [details]
gcc46-pr43690.patch

This is very ugly.  Either we should reject all these during gimplification
("m" (x+1) is also rejected during gimplification), or for POST{IN,DE}CREMENT_EXPR we could mark its operand as addressable in the FEs (but that wouldn't solve PRE{IN,DE}CREMENT_EXPR which would ICE anyway).  Or FEs would need to reject this.
Comment 3 Richard Biener 2010-05-22 18:14:00 UTC
GCC 4.3.5 is being released, adjusting target milestone.
Comment 4 Jakub Jelinek 2010-11-05 11:11:56 UTC
Author: jakub
Date: Fri Nov  5 11:11:50 2010
New Revision: 166354

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166354
Log:
	PR middle-end/43690
	* gimplify.c (gimplify_asm_expr): If a "m" input is a
	{pre,post}{in,de}crement, fail.

	* c-c++-common/pr43690.c: New test.

Added:
    trunk/gcc/testsuite/c-c++-common/pr43690.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimplify.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Jakub Jelinek 2010-11-05 11:31:49 UTC
Fixed on the trunk.
Comment 6 Jakub Jelinek 2010-11-11 20:36:54 UTC
Author: jakub
Date: Thu Nov 11 20:36:49 2010
New Revision: 166617

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166617
Log:
	Backport from mainline
	2010-11-05  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/43690
	* gimplify.c (gimplify_asm_expr): If a "m" input is a
	{pre,post}{in,de}crement, fail.

	* c-c++-common/pr43690.c: New test.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/c-c++-common/pr43690.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/gimplify.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
Comment 7 Jakub Jelinek 2010-11-12 11:30:29 UTC
Author: jakub
Date: Fri Nov 12 11:30:27 2010
New Revision: 166650

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166650
Log:
	Backport from mainline
	2010-11-05  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/43690
	* gimplify.c (gimplify_asm_expr): If a "m" input is a
	{pre,post}{in,de}crement, fail.

	* c-c++-common/pr43690.c: New test.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/c-c++-common/pr43690.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
Comment 8 Richard Biener 2011-06-27 12:13:08 UTC
4.3 branch is being closed, moving to 4.4.7 target.
Comment 9 Eric Weddington 2011-07-12 02:58:20 UTC
Patches were committed some time ago. Does this bug need to be marked as RESOLVED FIXED?
Comment 10 Jakub Jelinek 2011-07-12 05:55:26 UTC
Fixed.