This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix SRA crash
- From: Devang Patel <dpatel at apple dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 29 Mar 2005 11:08:38 -0800
- Subject: [PATCH] Fix SRA crash
decide_block_copy () does not disable scalarization of sub-elements
when it encounters an element that is marked as cannot_scalarize.
This triggers assert later on when generate_copy_inout () receives an
element that is not instantiated and at the same time use_block_copy
is not set. I ran into this while building large project here at
Apple with GCC-4.0.
* tree-sra.c (decide_block_copy): Disable scalarization of
sub-elements.
* g++.dg/tree-sra/ss-sra-3.C: New test.
Bootstrapped and tested on powerpc-darwin.
OK for mainline ?
OK for GCC 4.0 ?
Thanks,
-
Devang
Index: tree-sra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-sra.c,v
retrieving revision 2.54
diff -Idpatel.pbxuser -c -3 -p -r2.54 tree-sra.c
*** tree-sra.c 9 Mar 2005 11:35:34 -0000 2.54
--- tree-sra.c 29 Mar 2005 18:59:55 -0000
*************** decide_block_copy (struct sra_elt *elt)
*** 1299,1304 ****
--- 1299,1310 ----
fputc ('\n', dump_file);
}
+ /* Disable scalarization of sub-elements */
+ for (c = elt->children; c; c = c->sibling)
+ {
+ c->cannot_scalarize = 1;
+ decide_block_copy (c);
+ }
return false;
}
Index: testsuite/g++.dg/tree-ssa/ssa-sra-3.C
===================================================================
RCS file: testsuite/g++.dg/tree-ssa/ssa-sra-3.C
diff -N testsuite/g++.dg/tree-ssa/ssa-sra-3.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/tree-ssa/ssa-sra-3.C 29 Mar 2005 18:59:58
-0000
***************
*** 0 ****
--- 1,85 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O2" } */
+ /* Test to check use_block_copy bit propagation in sra element
hierarchy. */
+
+ typedef unsigned char UINT8 ;
+ typedef unsigned int UINT ;
+ class C4
+ {
+ public:
+ int xy[2];
+ };
+
+ class C3
+ {
+ public:
+ inline void
+ Reset()
+ {
+ C4 const mvMax = {0x7fff, 0x7fff};
+
+ m42(0,mvMax);
+ m42(1,mvMax);
+ m43(0);
+ };
+
+ inline void m42 (UINT i, C4 mv)
+ {
+ mMv[i] = mv;
+ };
+
+
+
+ inline void m43(UINT j)
+ {
+ m44 (j);
+ d41 = j + 1;
+ };
+
+ private:
+
+ C4 mMv[2];
+ UINT8 d41;
+ inline void m44 (UINT j) const {};
+ };
+
+ class C2
+ {
+ private:
+ bool valid;
+ };
+
+ class C1
+ {
+ public:
+ void m1(C3 *c);
+
+ private:
+ const C2 * d1[2];
+ void m2(C3 *m);
+ };
+
+ void C1::m1 (C3 *r)
+ {
+ C3 x;
+ m2(&x);
+ }
+ void C1::m2(C3 *x)
+ {
+ C3 m3;
+ int i;
+ m3.Reset ();
+ for(i=0; i<2; i++)
+ {
+ const C2 * r = d1[i];
+ if (r!=__null)
+ {
+ C4 const c400 = {0,0};
+ m3.m42 (i, c400);
+
+ }
+ }
+ }
+
+
+