This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix forwprop type-checking ICE with pointer/integer conversions


On Fri, May 15, 2009 at 12:12 PM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> This patch fixes a type-checking "invalid types in nop conversion" ICE
> on code involving converting a pointer type to a wider integer type;
> forwprop decided it could use a NOP_EXPR for this conversion, but the
> type checking then rejected the result; fixed by making
> forward_propagate_addr_expr_1 recurse as it already would if the
> address did not satisfy is_gimple_min_invariant. ?The problem was
> originally observed building glibc for MIPS n32 (where such
> conversions arise whenever a pointer (32-bit) is passed in a register
> (64-bit) to a system call); the test included with this patch should
> illustrate it more generally at -O2 on 32-bit platforms.
>
> Bootstrapped with no regressions on x86_64-unknown-linux-gnu and
> i686-pc-linux-gnu; I've also verified it fixes the glibc build ICE on
> MIPS. ?OK to commit?

Ok.

Thanks,
Richard.

> 2009-05-14 ?Joseph Myers ?<joseph@codesourcery.com>
>
> ? ? ? ?* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Also
> ? ? ? ?recurse on an invariant address if a conversion from a pointer
> ? ? ? ?type to a wider integer type is involved.
>
> testsuite:
> 2009-05-14 ?Joseph Myers ?<joseph@codesourcery.com>
>
> ? ? ? ?* gcc.c-torture/compile/ptr-conv-1.c: New test.
>
> Index: testsuite/gcc.c-torture/compile/ptr-conv-1.c
> ===================================================================
> --- testsuite/gcc.c-torture/compile/ptr-conv-1.c ? ? ? ?(revision 0)
> +++ testsuite/gcc.c-torture/compile/ptr-conv-1.c ? ? ? ?(revision 0)
> @@ -0,0 +1,11 @@
> +/* The intermediate conversion to __PTRDIFF_TYPE__ could be lost,
> + ? resulting in an "invalid types in nop conversion" ICE. ?*/
> +long long a;
> +void
> +f (void)
> +{
> + ?int c = 1;
> + ?volatile int *p = &c;
> + ?a = (long long) (__PTRDIFF_TYPE__) p;
> + ?*p;
> +}
> Index: tree-ssa-forwprop.c
> ===================================================================
> --- tree-ssa-forwprop.c (revision 147537)
> +++ tree-ssa-forwprop.c (working copy)
> @@ -739,7 +739,11 @@ forward_propagate_addr_expr_1 (tree name
> ? ? ? ? address which we cannot do in a single statement. ?*/
> ? ? ? if (!single_use_p
> ? ? ? ? ?|| (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (def_rhs))
> - ? ? ? ? ? ? && !is_gimple_min_invariant (def_rhs)))
> + ? ? ? ? ? ? && (!is_gimple_min_invariant (def_rhs)
> + ? ? ? ? ? ? ? ? || (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
> + ? ? ? ? ? ? ? ? ? ? && POINTER_TYPE_P (TREE_TYPE (def_rhs))
> + ? ? ? ? ? ? ? ? ? ? && (TYPE_PRECISION (TREE_TYPE (lhs))
> + ? ? ? ? ? ? ? ? ? ? ? ? > TYPE_PRECISION (TREE_TYPE (def_rhs)))))))
> ? ? ? ?return forward_propagate_addr_expr (lhs, def_rhs);
>
> ? ? ? gimple_assign_set_rhs1 (use_stmt, unshare_expr (def_rhs));
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]