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

Re: c/4529 (150 lines testcase)


http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4529&database=gcc

Hi, i had the same Problem with the gcc3.0.1 (rpm from Mandrake: 
gcc3.0-3.0.1-1mdk) also
when compiling the 8139too module. I cut the preprocessed file to a 
testcase of 150 lines
(containing no includes). The file compiled with -O1 (as opposed to -O2) 
or when ommitting
-fomit-frame-pointer. The original 8139too.c module also compiled with 
-O3, i believe the
compiler was then able to cut out the critical branch (i removed some 
if-branches which apparently
had nothing to do with the error in the testcase). I think the error has 
something to do with
inlining.

A compile with

gcc -I/usr/src/linux-2.4.10-ac12/include -Wall -Wstrict-prototypes 
-Wno-trigraphs -O2 -fomit-frame-pointer -v -c -o 8139too3.o 8139too3.c

results in:

$ make
gcc -I/usr/src/linux-2.4.10-ac12/include -Wall -Wstrict-prototypes 
-Wno-trigraphs -O2 -fomit-frame-pointer -v -c -o 8139too3.o 8139too3.c
Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.0.1/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --enable-shared --enable-threads=posix 
--disable-checking --enable-long-long --enable-cstdio=stdio 
--enable-clocale=generic --enable-languages=c,c++,f77,objc,java 
--program-suffix=-3.0.1 --enable-objc-gc --host=i586-mandrake-linux-gnu
Thread model: posix
gcc version 3.0.1
 /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.0.1/cc1 -lang-c -v 
-I/usr/src/linux-2.4.10-ac12/include -D__GNUC__=3 -D__GNUC_MINOR__=0 
-D__GNUC_PATCHLEVEL__=1 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ 
-D__linux__ -D__unix -D__linux -Asystem=posix -D__OPTIMIZE__ 
-D__STDC_HOSTED__=1 -Wall -Wstrict-prototypes -Wno-trigraphs -Acpu=i386 
-Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i586__ 
-D__tune_pentium__ 8139too3.c -quiet -dumpbase 8139too3.c -O2 -Wall 
-Wstrict-prototypes -Wno-trigraphs -version -fomit-frame-pointer -o 
/home/ralf/tmp/ccQ5Q1vf.s
GNU CPP version 3.0.1 (cpplib) (i386 Linux/ELF)
GNU C version 3.0.1 (i586-mandrake-linux-gnu)
    compiled by GNU C version 3.0.1.
ignoring nonexistent directory "/usr/i586-mandrake-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/src/linux-2.4.10-ac12/include
 /usr/local/include
 /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.0.1/include
 /usr/include
End of search list.
8139too3.c: In function `netdev_ethtool_ioctl':
8139too3.c:151: Unrecognizable insn:
(insn/i 219 450 447 (parallel[
            (set (reg:SI 6 ebp)
                (asm_operands:SI ("addl %3,%1; sbbl %0,%0; cmpl %1,%4; 
sbbl $0,%0") ("=&r") 0[
                        (reg/v:SI 1 edx [101])
                        (mem:SI (plus:SI (reg/f:SI 6 ebp)
                                (const_int -156 [0xffffff64])) 0)
                        (mem/s:SI (reg/f:SI 0 eax [104]) 3)
                    ]
                    [
                        (asm_input:SI ("1"))
                        (asm_input:SI ("g"))
                        (asm_input:SI ("g"))
                    ]  ("8139too3.c") 76))
            (set (reg/v:SI 1 edx [101])
                (asm_operands:SI ("addl %3,%1; sbbl %0,%0; cmpl %1,%4; 
sbbl $0,%0") ("=r") 1[
                        (reg/v:SI 1 edx [101])
                        (mem:SI (plus:SI (reg/f:SI 6 ebp)
                                (const_int -156 [0xffffff64])) 0)
                        (mem/s:SI (reg/f:SI 0 eax [104]) 3)
                    ]
                    [
                        (asm_input:SI ("1"))
                        (asm_input:SI ("g"))
                        (asm_input:SI ("g"))
                    ]  ("8139too3.c") 76))
            (clobber (reg:QI 19 dirflag))
            (clobber (reg:QI 18 fpsr))
            (clobber (reg:QI 17 flags))
        ] ) -1 (insn_list 214 (insn_list 218 (nil)))
    (nil))
8139too3.c:151: Internal compiler error in reload_cse_simplify_operands, 
at reload1.c:8355
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:https://qa.mandrakesoft.com/> for instructions.
make: *** [8139too3.o] Fehler 1

typedef unsigned int size_t;
typedef unsigned int u32;

void memset_generic(void *, char, unsigned long);

static inline char * strcpy(char * dest,const char *src)
{
  int d0, d1, d2;
__asm__ __volatile__(
	"1:\tlodsb\n\tstosb\n\ttestb %%al,%%al\n\tjne 1b"
        : "=&S" (d0), "=&D" (d1), "=&a" (d2)
        :"0" (src),"1" (dest) 
	: "memory"
	);
 return dest;
}

struct task_struct {
  unsigned long seg;
};
extern struct task_struct * foo_task_struct;

struct ethtool_cmd {
        u32 cmd;
};

struct ethtool_drvinfo {
        u32 cmd;
        char driver[32];
};

struct ethtool_wolinfo {
        u32 cmd;
};

int foo(void *to, const void *from, unsigned long);

static inline unsigned long
__constant_copy_to_user(void *to, const void *from, unsigned long n)
{
  if (
      ({ 
	unsigned long flag,sum; 
	asm(
	    "addl %3,%1; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0" 
	    :"=&r" (flag), "=r" (sum) 
	    :"1" (to),"g" ((int)(n)),"g" (foo_task_struct->seg)); 
	flag; 
      }) == 0  )
    { 
      int __d0, __d1; 
__asm__ __volatile__( 
		     "0: rep; movsl\n" 
		     "1:\n"
                     ".section .fixup,\"ax\"\n" 
		     "2: shl $2,%0\njmp 1b\n" 
		     ".previous\n" 
		     ".section __ex_table,\"a\"\n" 
		     "	.align 4\n" 
		     "	.long 0b,2b\n" 
		     ".previous" 
		     : "=c"(n), "=&S" (__d0), "=&D" (__d1) 
		     : "1"(from), "2"(to), "0"(n/4) 
		     : "memory"
		     ); 
    }
  return n;
}

static inline unsigned long
__constant_copy_from_user(void *to, const void *from, unsigned long n)
{
  if (      
      ({ 
	unsigned long flag,sum; 
	asm("addl %3,%1; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0" 
	    :"=&r" (flag), "=r" (sum) 
	    :"1" (from),"g" ((int)(n)),"g" (foo_task_struct->seg)); 
	flag; 
      }) == 0
      )
    do { 
      int __d0, __d1; 
__asm__ __volatile__( 
		     "0: rep; movsl\n" 
		     "1:\n" 
		     ".section .fixup,\"ax\"\n" 
		     "2: pushl %0\n" 
		     "	 pushl %%eax\n" 
		     "	 xorl %%eax,%%eax\n" 
		     "	 rep; "
		     "   stosl\n" 
		     "	 popl %%eax\n" 
		     "	 popl %0\n" 
		     "	 shl $2,%0\n" 
		     "	 jmp 1b\n" 
		     ".previous\n" 
		     ".section __ex_table,\"a\"\n" 
		     "	.align 4\n" 
		     "	.long 0b,2b\n" 
		     ".previous" 
		     : "=c"(n), "=&S" (__d0), "=&D" (__d1) 
		     : "1"(from), "2"(to), "0"(n/4) 
		     : "memory"); 
    } 
    while (0);
  else
    memset_generic(to,0,n);
  return n;
}

void netdev_get_eset (struct ethtool_cmd *eset);

int netdev_ethtool_ioctl (void *useraddr, u32 ethcmd)
{
  switch (ethcmd) {
  case 0x00000001:
    {
      struct ethtool_cmd eset = { 0x00000001 };
      netdev_get_eset (&eset);
      if (__constant_copy_to_user(useraddr,&eset,sizeof (eset)) )
	return -14;
      return 0;
    }
  case 0x00000003:
    {
      struct ethtool_drvinfo info = { 0x00000003 };
      strcpy (info.driver, "8139too");
      if (__constant_copy_to_user(useraddr,&info,sizeof (info)) )
	return -14;
      return 0;
    }
  case 0x00000005:
    {
      struct ethtool_wolinfo wol = { 0x00000005 };
      if (__constant_copy_to_user(useraddr,&wol,sizeof (wol)) )
	return -14;
      return 0;
    }
  case 0x00000006:
    {
      struct ethtool_wolinfo wol;
      if (__constant_copy_from_user(&wol,useraddr,sizeof (wol)) )
	return -14;
      return 0;
    }
  default:
    break;
  }
  return -95;
}

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