This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, pretty-ipa] Fix an ice when creating a fancy decl for one element arrays in intra-SRA
- From: Martin Jambor <mjambor at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Jan Hubicka <hubicka at ucw dot cz>
- Date: Tue, 17 Mar 2009 19:50:03 +0100
- Subject: [PATCH, pretty-ipa] Fix an ice when creating a fancy decl for one element arrays in intra-SRA
Hi,
as it is, my new intraprocedural intra-SRA ICEs on Tramp3D when
creating a fancy declaration name for an ARRAY_REF because it expects
the index to be a constant. However, when the array has only one
element that is not necessarily the case. The patch below handles
this case by bailing out gracefully.
I am about to bootstrap and test it and unless someone objects or
there are any failures, I will commit it tomorrow.
Thanks,
Martin
2009-03-17 Martin Jambor <mjambor@suse.cz>
* ipa-sra.c (make_fancy_name_1): Bail out if array_ref index is not an
integer constant.
Index: isra/gcc/ipa-sra.c
===================================================================
--- isra.orig/gcc/ipa-sra.c
+++ isra/gcc/ipa-sra.c
@@ -1903,6 +1903,7 @@ static void
make_fancy_name_1 (tree expr)
{
char buffer[32];
+ tree index;
if (DECL_P (expr))
{
@@ -1921,8 +1922,12 @@ make_fancy_name_1 (tree expr)
case ARRAY_REF:
make_fancy_name_1 (TREE_OPERAND (expr, 0));
obstack_1grow (&name_obstack, '$');
- sprintf (buffer, HOST_WIDE_INT_PRINT_DEC,
- TREE_INT_CST_LOW (TREE_OPERAND (expr, 1)));
+ /* Arrays with only one element may not have a constant as their
+ index. */
+ index = TREE_OPERAND (expr, 1);
+ if (TREE_CODE (index) != INTEGER_CST)
+ break;
+ sprintf (buffer, HOST_WIDE_INT_PRINT_DEC, TREE_INT_CST_LOW (index));
obstack_grow (&name_obstack, buffer, strlen (buffer));
break;