This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[i386 PATCH] Tree type correctness in ix86_va_start
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 3 Apr 2006 21:07:24 -0600 (MDT)
- Subject: [i386 PATCH] Tree type correctness in ix86_va_start
The following patch fixes another minor tree type mismatch issue
identified by instrumenting the middle-end. In this case, the x86
back-end is constructing temporary MODIFY_EXPR trees where the LHS'
type doesn't match the RHS' type. The problem is that the INTEGER_CSTs
that form the RHS are constructed without types. This is unlikely to
ever be a problem, but it's good GCC coding style to specify consistent
types, especially as in this case the fix is trivial. The obvious
patch below simply specifies the appropriate type to build_int_cst.
This patch has been tested on i686-pc-linux-gnu with a full "make
bootstrap", all default languages including Ada, and regression
tested with a top-level "make -k check" with no new failures.
Ok for mainline?
2006-04-03 Roger Sayle <roger@eyesopen.com>
* config/i386/i386.c (ix86_va_start): Ensure all integer constant
trees are constructed with a suitable tree type.
Index: i386.c
===================================================================
*** i386.c (revision 112626)
--- i386.c (working copy)
*************** ix86_va_start (tree valist, rtx nextarg)
*** 4122,4127 ****
--- 4122,4128 ----
HOST_WIDE_INT words, n_gpr, n_fpr;
tree f_gpr, f_fpr, f_ovf, f_sav;
tree gpr, fpr, ovf, sav, t;
+ tree type;
/* Only 64bit target needs something special. */
if (!TARGET_64BIT)
*************** ix86_va_start (tree valist, rtx nextarg)
*** 4152,4177 ****
if (cfun->va_list_gpr_size)
{
! t = build2 (MODIFY_EXPR, TREE_TYPE (gpr), gpr,
! build_int_cst (NULL_TREE, n_gpr * 8));
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
}
if (cfun->va_list_fpr_size)
{
! t = build2 (MODIFY_EXPR, TREE_TYPE (fpr), fpr,
! build_int_cst (NULL_TREE, n_fpr * 16 + 8*REGPARM_MAX));
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
}
/* Find the overflow area. */
! t = make_tree (TREE_TYPE (ovf), virtual_incoming_args_rtx);
if (words != 0)
! t = build2 (PLUS_EXPR, TREE_TYPE (ovf), t,
! build_int_cst (NULL_TREE, words * UNITS_PER_WORD));
! t = build2 (MODIFY_EXPR, TREE_TYPE (ovf), ovf, t);
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
--- 4153,4181 ----
if (cfun->va_list_gpr_size)
{
! type = TREE_TYPE (gpr);
! t = build2 (MODIFY_EXPR, type, gpr,
! build_int_cst (type, n_gpr * 8));
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
}
if (cfun->va_list_fpr_size)
{
! type = TREE_TYPE (fpr);
! t = build2 (MODIFY_EXPR, type, fpr,
! build_int_cst (type, n_fpr * 16 + 8*REGPARM_MAX));
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
}
/* Find the overflow area. */
! type = TREE_TYPE (ovf);
! t = make_tree (type, virtual_incoming_args_rtx);
if (words != 0)
! t = build2 (PLUS_EXPR, type, t,
! build_int_cst (type, words * UNITS_PER_WORD));
! t = build2 (MODIFY_EXPR, type, ovf, t);
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
*************** ix86_va_start (tree valist, rtx nextarg)
*** 4179,4186 ****
{
/* Find the register save area.
Prologue of the function save it right above stack frame. */
! t = make_tree (TREE_TYPE (sav), frame_pointer_rtx);
! t = build2 (MODIFY_EXPR, TREE_TYPE (sav), sav, t);
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
}
--- 4183,4191 ----
{
/* Find the register save area.
Prologue of the function save it right above stack frame. */
! type = TREE_TYPE (sav);
! t = make_tree (type, frame_pointer_rtx);
! t = build2 (MODIFY_EXPR, type, sav, t);
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
}
Roger
--