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] correct parameter alignment for library calls in calls.c


Hi Ian,
Can you please review the patch below? It is related to the issue that you raised before. Please see http://gcc.gnu.org/ml/gcc-patches/2007-02/msg00716.html


Regards
Hari

Hariharan wrote:
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,




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