This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix VTA ICE on Fortran COMMONs (PR debug/43166)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Cc: Alexandre Oliva <aoliva at redhat dot com>
- Date: Thu, 25 Feb 2010 00:22:20 +0100
- Subject: [PATCH] Fix VTA ICE on Fortran COMMONs (PR debug/43166)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The following testcase ICEs, because of a Fortran FE bug, where when a
common needs to grow DECL_MODE isn't adjusted and thus in expand_debug_expr
we see a VAR_DECL with BLKmode type, yet DECL_RTL for it has SImode.
We then try to convert the modes using simplify_gen_subreg, which of course
ICEs. The following patch fixes the Fortran FE to update also DECL_SIZE,
DECL_MODE and other stuff (alignment, DECL_RTL if already set), but IMHO it
doesn't hurt to make expand_debug_expr more robust too.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2010-02-24 Jakub Jelinek <jakub@redhat.com>
PR debug/43166
* cfgexpand.c (expand_debug_expr) <case VAR_DECL>: If mode is
BLKmode, assert op0 is a MEM and just adjust its mode.
* trans-common.c (build_common_decl): Also update DECL_MODE,
and DECL_SIZE when encountering a larger common block and call
layout_decl.
* gfortran.dg/debug/pr43166.f: New test.
--- gcc/cfgexpand.c.jj 2010-02-24 17:12:05.000000000 +0100
+++ gcc/cfgexpand.c 2010-02-24 20:31:51.000000000 +0100
@@ -2316,7 +2316,7 @@ expand_debug_expr (tree exp)
else
op0 = copy_rtx (op0);
- if (GET_MODE (op0) == BLKmode)
+ if (GET_MODE (op0) == BLKmode || mode == BLKmode)
{
gcc_assert (MEM_P (op0));
op0 = adjust_address_nv (op0, mode, 0);
--- gcc/fortran/trans-common.c.jj 2009-11-28 13:13:06.000000000 +0100
+++ gcc/fortran/trans-common.c 2010-02-24 20:04:17.000000000 +0100
@@ -399,8 +399,11 @@ build_common_decl (gfc_common_head *com,
if (strcmp (com->name, BLANK_COMMON_NAME))
gfc_warning ("Named COMMON block '%s' at %L shall be of the "
"same size", com->name, &com->where);
+ DECL_SIZE (decl) = TYPE_SIZE (union_type);
DECL_SIZE_UNIT (decl) = size;
+ DECL_MODE (decl) = TYPE_MODE (union_type);
TREE_TYPE (decl) = union_type;
+ layout_decl (decl, 0);
}
}
--- gcc/testsuite/gfortran.dg/debug/pr43166.f.jj 2010-02-24 20:17:26.000000000 +0100
+++ gcc/testsuite/gfortran.dg/debug/pr43166.f 2010-02-24 20:20:14.000000000 +0100
@@ -0,0 +1,14 @@
+C PR debug/43166
+C { dg-do compile }
+C { dg-options "-O" }
+ SUBROUTINE FOO ()
+ INTEGER V1
+ COMMON // V1
+ END
+ SUBROUTINE BAR ()
+ INTEGER V0,V1,V2,V3
+ COMMON // V1(4),V2(85,4),V3
+ DO V3=1,V1(1)
+ V0=V2(V3,1)
+ END DO
+ END
Jakub