[Xtensa] fix a vararg bug

Bob Wilson bwilson@tensilica.com
Wed Sep 12 18:22:00 GMT 2007

This fixes yet another bug related to Xtensa's use of the frame  
pointer (FP) register to pass a function argument.  (There is no real  
conflict; the argument is simply copied elsewhere before setting up  
the FP value.)  GCC handles the FP register as a special case and  
doesn't recognize when there is a live value in that register.

The specific problem is that the builtin_saveregs function calls  
move_block_from_reg to store some of the incoming argument registers  
to the stack, and the register allocator picks a7 to hold the  
destination address, despite the fact that a7 is one of the registers  
being stored.  This is supposed to be avoided by storing a7 elsewhere  
as the very first thing in the function, but in the case of  
builtin_saveregs the code to save a7 was placed after the computation  
of the destination address.  The patch fixes that.

Committed on the mainline.  The same problem occurs on the 4.2  
branch, so I will apply the patch there after I test it on the branch.

2007-09-12  Bob Wilson  <bob.wilson@acm.org>

         * config/xtensa/xtensa.c (machine_function): Add  
         (xtensa_copy_incoming_a7): Use start_sequence instead of
         push_to_sequence.  Stash insns in vararg_a7_copy for  
         (xtensa_builtin_saveregs): Place code from vararg_a7_copy at  
the start
         of the saveregs sequence.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-vararg-a7.patch
Type: application/octet-stream
Size: 1835 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070912/2a570546/attachment.obj>

More information about the Gcc-patches mailing list