This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [patch,mips] avoid invalid register for JALR


On Wed, 14 May 2014, Sandra Loosemore wrote:

> > > When I was trying to benchmark another patch (which I'll be sending
> > > along shortly) with CSiBE for -mabi=64, I ran into an assembler error
> > > like this:
> > > 
> > > /tmp/ccJv2faG.s: Assembler messages:
> > > /tmp/ccJv2faG.s:1605: Error: a destination register must be supplied
> > > `jalr $31'
> > 
> > JALR patterns should have an explicit clobber of $31, which I thought
> > was also supposed to stop $31 from being used as the call address.
> 
> Hmmmmm.  Yes, that ought to work, in theory....
> 
> > Do you have a testcase?
> 
> I can reproduce the error in a current mipsisa64-elfoabi build, with my patch
> to delete ADJUST_REG_ALLOC_ORDER applied.  It triggers on this file from
> CSiBE:
> 
> mipsisa64-elfoabi-gcc -c -mabi=64 -O2 -fno-common -w
> csibe/src/./ttt-0.10.1.preproc/src/connect4.i

 I wonder if there's something fishy going on here.  I checked output 
produced with -dP and the offending instruction is emitted like this:

 #(call_insn 172 124 161 (parallel [
 #            (call (mem:SI (reg:DI 31 $31) [0 c4_setup S4 A32])
 #                (const_int 0 [0]))
 #            (clobber (reg:SI 31 $31))
 #        ]) c4_new.i:79 594 {call_internal}
 #     (expr_list:REG_DEAD (reg:DI 31 $31)
 #        (expr_list:REG_DEAD (reg:DI 7 $7)
 #            (expr_list:REG_DEAD (reg:DI 6 $6)
 #                (expr_list:REG_DEAD (reg:DI 5 $5)
 #                    (expr_list:REG_DEAD (reg:DI 4 $4)
 #                        (nil))))))
 #    (expr_list:DI (use (reg:DI 4 $4))
 #        (expr_list:SI (use (reg:DI 5 $5))
 #            (expr_list:SI (use (reg:DI 6 $6))
 #                (expr_list:SI (use (reg:DI 7 $7))
 #                    (nil))))))
	jalr	$31	 # 172	call_internal/1	[length = 4]

so clearly the clobber is ignored, or perhaps rather considered a late 
clobber instead of an early clobber that's indeed required here.

 I have reduced your case a bit and attached the result to this e-mail.  
With this code I can reproduce the problem using the following command:

$ mips-sde-elf-gcc -S -dP -mabi=64 -O2 -fno-common -w -o c4_new.s c4_new.i

and current trunk with the patch you recently posted as archived at:

https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01016.html

applied.  With the patch reverted the issue goes away ($17 is used for the 
jump), so clearly the register allocation order override made in 
mips_order_regs_for_local_alloc is currently covering an underlying bug.

  Maciej

Attachment: c4_new.i
Description: Text document


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