This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with std_expand_builtin_va_start on targets where sizetype and ptr_type_node don't have the same mode
- From: "Andrew Pinski" <pinskia at gmail dot com>
- To: "Zack Weinberg" <zackw at panix dot com>
- Cc: "GCC Development" <gcc at gcc dot gnu dot org>, "DJ Delorie" <dj at redhat dot com>
- Date: Thu, 5 Jul 2007 15:28:06 -0700
- Subject: Re: Problem with std_expand_builtin_va_start on targets where sizetype and ptr_type_node don't have the same mode
- References: <eb97335b0707051439m1a916d0eid9dd1b675cc683ac@mail.gmail.com>
On 7/5/07, Zack Weinberg <zackw@panix.com> wrote:
I'm trying to help DJ with converting m32c to define_constraint, and
I'm running into an unrelated problem. Specifically, the unmodified
compiler targeting m32c-elf, in -mcpu=m32cm mode, crashes on any use
of __builtin_va_start, even this:
This is the patch which I came up with:
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c (revision 126338)
+++ gcc/builtins.c (working copy)
@@ -4650,7 +4650,18 @@
std_expand_builtin_va_start (tree valist, rtx nextarg)
{
tree t;
- t = make_tree (sizetype, nextarg);
+ /* Use the correct type/mode for make_tree, can't use a pointer type as
+ PLUS_EXPR is not appliable to pointers. type_for_mode might return
+ a type with a different mode (SI vs PSI) so we might need to convert
+ to the different mode. */
+ tree type = lang_hooks.types.type_for_mode (TYPE_MODE (ptr_type_node), true);
+ if (TYPE_MODE (type) != GET_MODE (nextarg))
+ {
+ rtx reg = gen_reg_rtx (TYPE_MODE (type));
+ convert_move (reg, nextarg, false);
+ nextarg = reg;
+ }
+ t = make_tree (type, nextarg);
t = fold_convert (ptr_type_node, t);
t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist, t);
I posted this to a bug report, specifically about this target too, I
forgot which one. I was hoping someone would test it for me because I
have not got a sim experience to be able to test.
-- Pinski