Problem with std_expand_builtin_va_start on targets where sizetype and ptr_type_node don't have the same mode

Andrew Pinski pinskia@gmail.com
Thu Jul 5 22:28:00 GMT 2007


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



More information about the Gcc mailing list