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]

Re: c/2898: Illegal function return in ARM code when compiling with -mthumb-interwork -O2


> >Doh! Wait a moment, we only want to avoid this sequence if really 
> >returning -- popping to lr should be safe with a load even for the cases 
> >concerned (though we should never be tail-calling out of an interrupt 
> >function...).
> 
> I think this additional patch will improve matters.  It seems to DTRT with the 
> testcase from 2898: we now get:
> 
> f:
>         @ Function supports interworking.
>         @ args = 0, pretend = 0, frame = 0
>         @ frame_needed = 0, current_function_anonymous_args = 0
>         str     lr, [sp, #-4]!
>         mov     r3, r0
>         ldrb    r2, [r3, #0]    @ zero_extendqisi2
>         ldrb    ip, [r1, #0]
>         cmp     r2, #0
>         movne   r3, lr
>         strb    ip, [r3, #0]
>         ldr     lr, [sp], #4
>         bx      lr
> .Lfe1:
> 
> p.
> 
> 2001-05-26  Philip Blundell  <philb@gnu.org>
> 
> 	* config/arm/arm.c (output_return_instruction): Use LDR in more
> 	situations where this is allowed.

I think this is basically OK, but it's a bit hard to tell with "diff -u" 
format...
 
> +	return_reg = reg_names [PC_REGNUM];
                             ^^^
No space before array index

> +	return_reg = reg_names [LR_REGNUM];

And again.

> +	  if ((live_regs_mask & (1 << LR_REGNUM)) == 0)
> +	    {
> +	      /* If we are not restoring the LR register then we will
> +		 have added one too many commas to the list above.
> +		 Replace it with a closing brace.  */
> +	      instr [strlen (instr) - 2] =  '}';
> +	    }

I realise this is what the old code did, but it's a truly horrible hack, 
particularly since it leaves a trailing space.  Any chance the code could 
be reworked to avoid the need for this?  BTW, repeated use of strcat is 
horribly inefficient.

R.



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