This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH to avoid copying tail padding (was: GCC 3.2)
- From: Jason Merrill <jason at redhat dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: graham dot stott at btinternet dot com
- Date: Sat, 03 Aug 2002 21:10:33 +0100
- Subject: Re: PATCH to avoid copying tail padding (was: GCC 3.2)
- References: <40360000.1027723811@gandalf.codesourcery.com><200207271635.12319@enzo.bigblue.local><wvlptx6m7pd.fsf@prospero.cambridge.redhat.com><wvly9bsk9gg.fsf@prospero.cambridge.redhat.com><3000000.1028131037@gandalf.codesourcery.com><wvl8z3qjlxc.fsf@prospero.cambridge.redhat.com><wvlfzxxiicg.fsf_-_@prospero.cambridge.redhat.com>
As Graham pointed out, my change to store_constructor caused problems with
Ada CONSTRUCTORs with non-constant expr_size. Fixed thus:
2002-08-03 Jason Merrill <jason@redhat.com>
* explow.c (int_expr_size): New fn.
* expr.c (expand_expr) [CONSTRUCTOR]: Use it.
* expr.h: Declare it.
*** explow.c.~1~ Sat Aug 3 21:16:11 2002
--- explow.c Sat Aug 3 14:12:20 2002
*************** expr_size (exp)
*** 294,299 ****
--- 294,319 ----
return expand_expr (size, NULL_RTX, TYPE_MODE (sizetype), 0);
}
+
+ /* Return a wide integer for the size in bytes of the value of EXP, or -1
+ if the size can vary or is larger than an integer. */
+
+ HOST_WIDE_INT
+ int_expr_size (exp)
+ tree exp;
+ {
+ tree t = (*lang_hooks.expr_size) (exp);
+
+ if (t == 0
+ || TREE_CODE (t) != INTEGER_CST
+ || TREE_OVERFLOW (t)
+ || TREE_INT_CST_HIGH (t) != 0
+ /* If the result would appear negative, it's too big to represent. */
+ || (HOST_WIDE_INT) TREE_INT_CST_LOW (t) < 0)
+ return -1;
+
+ return TREE_INT_CST_LOW (t);
+ }
/* Return a copy of X in which all memory references
and all constants that involve symbol refs
*** expr.c.~1~ Sat Aug 3 21:16:11 2002
--- expr.c Sat Aug 3 14:11:08 2002
*************** expand_expr (exp, target, tmode, modifie
*** 6812,6818 ****
* TYPE_QUAL_CONST))),
0, TREE_ADDRESSABLE (exp), 1);
! store_constructor (exp, target, 0, INTVAL (expr_size (exp)));
return target;
}
--- 6812,6818 ----
* TYPE_QUAL_CONST))),
0, TREE_ADDRESSABLE (exp), 1);
! store_constructor (exp, target, 0, int_expr_size (exp));
return target;
}
*** expr.h.~1~ Sat Aug 3 21:16:11 2002
--- expr.h Sat Aug 3 14:12:18 2002
*************** extern unsigned int case_values_threshol
*** 544,549 ****
--- 544,553 ----
/* Return an rtx for the size in bytes of the value of an expr. */
extern rtx expr_size PARAMS ((tree));
+ /* Return a wide integer for the size in bytes of the value of EXP, or -1
+ if the size can vary or is larger than an integer. */
+ extern HOST_WIDE_INT int_expr_size PARAMS ((tree));
+
extern rtx lookup_static_chain PARAMS ((tree));
/* Convert a stack slot address ADDR valid in function FNDECL