diff options
author | Jakub Jelinek <jakub@redhat.com> | 2002-03-08 14:45:13 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2002-03-08 14:45:13 +0100 |
commit | 71db7d0315cfa958ceead1b436a130cd5d21002c (patch) | |
tree | ca62fffdce452b4e9d9875e01e4aa2868d4a3388 /gcc/builtins.c | |
parent | 127c1ba59832e7cbca6f86a38a9c6c090f3d0361 (diff) | |
download | gcc-71db7d0315cfa958ceead1b436a130cd5d21002c.zip gcc-71db7d0315cfa958ceead1b436a130cd5d21002c.tar.gz gcc-71db7d0315cfa958ceead1b436a130cd5d21002c.tar.bz2 |
re PR c/3711 (ICE in instantiate_virtual_regs_1, at function.c:3880)
PR c/3711
* builtins.c (std_expand_builtin_va_arg): Do all computations on
trees.
* gcc.c-torture/execute/20020307-2.c: New test.
From-SVN: r50438
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index c4aebd3..806dd0d 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -2986,37 +2986,54 @@ rtx std_expand_builtin_va_arg (valist, type) tree valist, type; { - tree addr_tree, t; - HOST_WIDE_INT align; - HOST_WIDE_INT rounded_size; + tree addr_tree, t, type_size = NULL; + tree align, alignm1; + tree rounded_size; rtx addr; /* Compute the rounded size of the type. */ - align = PARM_BOUNDARY / BITS_PER_UNIT; - rounded_size = (((int_size_in_bytes (type) + align - 1) / align) * align); + align = size_int (PARM_BOUNDARY / BITS_PER_UNIT); + alignm1 = size_int (PARM_BOUNDARY / BITS_PER_UNIT - 1); + if (type == error_mark_node + || (type_size = TYPE_SIZE_UNIT (TYPE_MAIN_VARIANT (type))) == NULL + || TREE_OVERFLOW (type_size)) + rounded_size = size_zero_node; + else + rounded_size = fold (build (MULT_EXPR, sizetype, + fold (build (TRUNC_DIV_EXPR, sizetype, + fold (build (PLUS_EXPR, sizetype, + type_size, alignm1)), + align)), + align)); /* Get AP. */ addr_tree = valist; - if (PAD_VARARGS_DOWN) + if (PAD_VARARGS_DOWN && ! integer_zerop (rounded_size)) { /* Small args are padded downward. */ - - HOST_WIDE_INT adj - = rounded_size > align ? rounded_size : int_size_in_bytes (type); - - addr_tree = build (PLUS_EXPR, TREE_TYPE (addr_tree), addr_tree, - build_int_2 (rounded_size - adj, 0)); + addr_tree = fold (build (PLUS_EXPR, TREE_TYPE (addr_tree), addr_tree, + fold (build (COND_EXPR, sizetype, + fold (build (GT_EXPR, sizetype, + rounded_size, + align)), + size_zero_node, + fold (build (MINUS_EXPR, sizetype, + rounded_size, + type_size)))))); } addr = expand_expr (addr_tree, NULL_RTX, Pmode, EXPAND_NORMAL); addr = copy_to_reg (addr); /* Compute new value for AP. */ - t = build (MODIFY_EXPR, TREE_TYPE (valist), valist, - build (PLUS_EXPR, TREE_TYPE (valist), valist, - build_int_2 (rounded_size, 0))); - TREE_SIDE_EFFECTS (t) = 1; - expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); + if (! integer_zerop (rounded_size)) + { + t = build (MODIFY_EXPR, TREE_TYPE (valist), valist, + build (PLUS_EXPR, TREE_TYPE (valist), valist, + rounded_size)); + TREE_SIDE_EFFECTS (t) = 1; + expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); + } return addr; } |