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

Question about reload ICE while compiling MIPS linux



The following test case causes an ICE on MIPS:

	int func (int len, int v)
	{
	  int a;
	  len = 1;
	  if (v)
	    goto end;
	  asm ("" : "+r" (len) : "r" (&a));
	 end:
	  return len;
	}

(seen while trying to compile linux/kernel/sched.c).  The important thing
here is that "a" is the first local variable, so its address is initially
given by (reg 1).  gcse.c:try_replace_reg adds a REG_EQUAL note to the asm
instruction:

(insn 22 42 23 (set (reg/v:SI 82)
        (asm_operands:SI ("") ("=r") 0[ 
                (reg/f:SI 1 at)
                (reg/v:SI 82)
            ] 
            [ 
                (asm_input:SI ("r"))
                (asm_input:SI ("0"))
            ]  ("/local/test/asm.c") 7)) -1 (nil)
    (expr_list:REG_EQUAL (asm_operands:SI ("") ("=r") 0[ 
                (reg/f:SI 1 at)
                (reg/v:SI 82)
            ] 
            [ 
                (asm_input:SI ("r"))
                (asm_input:SI ("0"))
            ]  ("/local/test/asm.c") 7)
        (nil)))

When (reg 1) is eliminated in the asm instruction, eliminate_regs is called
for each note.  But eliminate_regs doesn't expect to see the asm_operands
and aborts.

In this particular case, eliminate_regs' default handling would do the
right thing: (reg 1) would get replaced with the stack pointer in the
above example, and with a temporary register in the kernel code.  But the
asm handling was deliberately removed from eliminate_regs:

    <http://gcc.gnu.org/ml/gcc-patches/1999-10n/msg00483.html>

and this message asks whether asm_operands should be disallowed in
REG_EQUAL notes:

    <http://gcc.gnu.org/ml/gcc-patches/2000-12/msg00041.html>

Any suggestions how best to fix things?  Purely for reference, I've included
a patch that uses the default eliminate_regs handling for ASM_OPERANDS.  It
works for this case, but I don't know whether it's safe in general.

Richard

Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.278
diff -u -p -d -r1.278 reload1.c
--- reload1.c	2001/07/19 19:46:29	1.278
+++ reload1.c	2001/07/26 12:03:50
@@ -2579,7 +2579,6 @@ eliminate_regs (x, mem_mode, insn)
       return x;
 
     case CLOBBER:
-    case ASM_OPERANDS:
     case SET:
       abort ();
 


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