[PATCH] Robustify expand_debug_expr (PR debug/43557)
Richard Guenther
rguenther@suse.de
Wed Mar 31 09:10:00 GMT 2010
On Tue, 30 Mar 2010, Jakub Jelinek wrote:
> Hi!
>
> While this looks arguably to be a FE bug in --combine
> handling, I'd say expand_debug_expr should not be the place
> to enforce stuff as the only place in the compiler, thus
> it won't hurt to make it more robust.
> The problem is that the g variable has DECL_RTL set
> to (mem:SI (symbol_ref "g")), but then its type got merged
> with the incomplete type from another TU and the result is incomplete type,
> therefore TYPE_MODE is VOIDmode.
>
> This patch just doesn't try to adjust non-VOIDmode MEMs to VOIDmode.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Ok.
Thanks,
Richard.
> 2010-03-30 Jakub Jelinek <jakub@redhat.com>
>
> PR debug/43557
> * cfgexpand.c (expand_debug_expr): Handle VOIDmode mode like
> BLKmode.
>
> * gcc.dg/pr43557-1.c: New test.
> * gcc.dg/pr43557-2.c: New file.
>
> --- gcc/cfgexpand.c.jj 2010-03-25 00:26:24.000000000 +0100
> +++ gcc/cfgexpand.c 2010-03-30 14:01:12.000000000 +0200
> @@ -2358,7 +2358,8 @@ expand_debug_expr (tree exp)
> /* If op0 is not BLKmode, but BLKmode is, adjust_mode
> below would ICE. While it is likely a FE bug,
> try to be robust here. See PR43166. */
> - || mode == BLKmode)
> + || mode == BLKmode
> + || (mode == VOIDmode && GET_MODE (op0) != VOIDmode))
> {
> gcc_assert (MEM_P (op0));
> op0 = adjust_address_nv (op0, mode, 0);
> --- gcc/testsuite/gcc.dg/pr43557-1.c.jj 2010-03-30 17:06:34.000000000 +0200
> +++ gcc/testsuite/gcc.dg/pr43557-1.c 2010-03-30 17:09:12.000000000 +0200
> @@ -0,0 +1,16 @@
> +/* PR debug/43557 */
> +/* { dg-do compile } */
> +/* { dg-options "--combine -g -O2" } */
> +/* { dg-additional-sources "pr43557-2.c" } */
> +
> +struct S
> +{
> + int v;
> +} g;
> +
> +void
> +f1 (void)
> +{
> + struct S *s = &g;
> + s->v = 0;
> +}
> --- gcc/testsuite/gcc.dg/pr43557-2.c.jj 2010-03-30 17:06:53.000000000 +0200
> +++ gcc/testsuite/gcc.dg/pr43557-2.c 2010-03-30 17:09:05.000000000 +0200
> @@ -0,0 +1,10 @@
> +/* PR debug/43557 */
> +/* { dg-do compile } */
> +
> +extern struct S g;
> +
> +void
> +f2 (void)
> +{
> + &g;
> +}
>
>
> Jakub
>
>
--
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex
More information about the Gcc-patches
mailing list