i*86 structure assignment bug with global register vars

Fergus Henderson fjh@cs.mu.oz.au
Sun Oct 22 12:21:00 GMT 2000

gcc 2.95.2 on i*86 systems has a bug that shows up if you try to use
structure assignment and global register variables in the same
program.  It reports the error message "fixed or forbidden register
... was spilled ... This may be due to a compiler bug or to
impossible asm statements or clauses.".

The pattern that matches structure assignment should be
written so as to be conditional on whether esi is fixed.

$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
gcc version 2.95.2 20000220 (Debian GNU/Linux)
$ uname -a
Linux ender 2.2.16 #5 Mon Jul 31 16:03:33 EST 2000 i686 unknown
$ cat bug.c
	register int reg __asm__("esi");
	struct s {
		int a;
		int b;
		long c;
		long d;
		void* e;
	} x, y;
	void foo() {
		x = y;
$ gcc -c bug.c
bug.c: In function `foo':
bug.c:11: fixed or forbidden register 4 (si) was spilled for class SIREG.
bug.c:11: This may be due to a compiler bug or to impossible asm
bug.c:11: statements or clauses.
bug.c:11: This is the instruction:
(insn 11 10 13 (parallel[ 
            (set (mem/s:BLK (reg:SI 5 %edi) 0)
                (mem/s:BLK (reg:SI 0 %eax) 0))
            (use (const_int 20 [0x14]))
            (use (const_int 4 [0x4]))
            (clobber (scratch:SI))
            (clobber (reg:SI 5 %edi))
            (clobber (reg:SI 0 %eax))
        ] ) 393 {movstrsi+1} (nil)
    (expr_list:REG_UNUSED (reg:SI 5 %edi)
        (expr_list:REG_UNUSED (reg:SI 0 %eax)

Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: < http://www.cs.mu.oz.au/~fjh >  |     -- the last words of T. S. Garp.

More information about the Gcc-bugs mailing list