[Patch] Fix gimplification of slices of integer
Richard Guenther
richard.guenther@gmail.com
Mon Aug 24 12:09:00 GMT 2009
On Fri, Aug 21, 2009 at 7:50 PM, Eric Botcazou<ebotcazou@adacore.com> wrote:
> Hi,
>
> the attached testcase exhibits a gimplication problem in a corner case:
> dynamic slices of integer viewed as array. There are 2 variants of the
> problem:
>
> 1. in the first variant, an integer DECL is converted to another integer and
> then VCEd to an array, the address of a slice of which is taken.
> This is problematic because, in gimplify_addr_expr, the gimplification of
> the first conversion yields a temporary, which eventually ends up being
> marked addressable, leading to:
>
> slice7.adb:8:1: error: non-register as LHS of unary operation
> D.2284 = (slice7__convert_putGP404__source) obj.14;
>
> because an addressable DECL is not a gimple register.
>
> There is already a counter-measure for a simpler case in the function:
>
> /* We cannot rely on making the RHS addressable if it is
> a temporary created by gimplification. In this case create a
> new temporary that is initialized by a copy (which will
> become a store after we mark it addressable).
> This mostly happens if the frontend passed us something that
> it could not mark addressable yet, like a fortran
> pass-by-reference parameter (int) floatvar. */
> if (is_gimple_reg (TREE_OPERAND (expr, 0)))
> TREE_OPERAND (expr, 0)
> = get_initialized_tmp_var (TREE_OPERAND (expr, 0), pre_p, post_p);
>
> but it doesn't trigger in this case because the gimple register is not
> the top-level node.
>
> The proposed fix is to enhance the counter-measure to catch the case.
>
> 2. in the second variant, a difference of 2 integers is VCEd to an array,
> the address of a SAVE_EXPR of a slice of which is taken(!).
> Same problem, but this time in gimplify_modify_expr_to_memcpy when the
> RHS is marked addressable:
>
> slice7.adb:8:1: error: non-register as LHS of binary operation
> D.2325 = D.2324 + -1;
>
> The proposed fix is to apply the same counter-measure to this function
> (a patchlet is also needed in Gigi for this second variant).
>
> Tested on i586-suse-linux, OK for mainline?
Ok.
Thanks,
Richard.
>
> 2009-08-21 Eric Botcazou <ebotcazou@adacore.com>
>
> * gimplify.c (prepare_gimple_addressable): New static function.
> (gimplify_modify_expr_to_memcpy): Invoke it on the RHS before marking
> it addressable.
> (gimplify_addr_expr): Invoke it similarly on the operand instead of
> manually fiddling with it.
> ada/
> * gcc-interface/trans.c (call_to_gnu): Tidy.
> (gnat_to_gnu) <N_Slice>: Set TYPE_ARRAY_MAX_SIZE if the slice has
> non-constant size but the array itself has constant size.
>
>
> 2009-08-21 Eric Botcazou <ebotcazou@adacore.com>
>
> * gnat.dg/slice7.adb: New test.
> * gnat.dg/slice7_pkg.ads: New helper.
>
>
> --
> Eric Botcazou
>
More information about the Gcc-patches
mailing list