[PATCH] minor patch to fix a bug

Hariharan hariharans@picochip.com
Fri Feb 15 17:28:00 GMT 2008


Hi,
I found a bug while testing latest gcc sources in the picochip port. It 
was small enough that i thought i could fix it myself.

In expr.c, function emit_push_insn, with strict_alignment, if "align" 
was not as strong as what is needed for the mode, we now try move the 
value to a properly aligned temp (gathered using assign_temp). When this 
change was made, calls to emit_push_insn from calls.c have been changed 
to properly emit "align". But, there is still a place in calls.c, in 
function emit_library_call_value_1, lines ~3720, where we have a call to 
emit_push_insn with PARM_BOUNDARY as the alignment. Note that we pass a 
NULL_TREE as well. In usual targets, PARM_BOUNDARY(generally 4 bytes) 
would probably suffice for parameters passed on stack. Ours is a bit 
unusual in that we only *require* 2 byte alignment, but we enforce 
STRICT_ALIGNMENT.

In my opinion, the call to emit_push_insn should get the proper 
alignment for the parameter and then use that for the parameter "align", 
instead of the current PARM_BOUNDARY.

I see that Ian raised this issue when the original change was made. 
http://gcc.gnu.org/ml/gcc-patches/2007-02/msg00716.html

I am submitting a patch with the change. I have tested it on our port 
(which is quite unusual in its own respects) and i686-pc-linux-gnu 
bootstrap and tested it.

Regards
Hari

Index: gcc/calls.c
===================================================================
--- gcc/calls.c (revision 132323)
+++ gcc/calls.c (working copy)
@@ -3660,6 +3660,7 @@
       rtx val = argvec[argnum].value;
       rtx reg = argvec[argnum].reg;
       int partial = argvec[argnum].partial;
+      unsigned int parm_align = argvec[argnum].locate.boundary;
       int lower_bound = 0, upper_bound = 0, i;

       if (! (reg != 0 && partial == 0))
@@ -3721,7 +3722,7 @@
                }
            }

-         emit_push_insn (val, mode, NULL_TREE, NULL_RTX, PARM_BOUNDARY,
+         emit_push_insn (val, mode, NULL_TREE, NULL_RTX, parm_align,
                          partial, reg, 0, argblock,
                          GEN_INT (argvec[argnum].locate.offset.constant),
                          reg_parm_stack_space,



More information about the Gcc-patches mailing list