]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/38410 (g++.dg/eh/crossjump1.C (internal compiler error))
authorJason Merrill <jason@redhat.com>
Tue, 9 Dec 2008 06:04:50 +0000 (01:04 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 9 Dec 2008 06:04:50 +0000 (01:04 -0500)
        PR c++/38410
        * gimplify.c (gimplify_init_constructor): Don't write out a static
        copy of the CONSTRUCTOR for TREE_ADDRESSABLE types or small sparse
        initializers.

From-SVN: r142580

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ctor1.c [new file with mode: 0644]

index c43bbde608b9b59ed96c0be205d24f0a35d69619..a8b338f59daaa6d7045f079551c9154794db3918 100644 (file)
@@ -1,3 +1,10 @@
+2008-12-09  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38410
+       * gimplify.c (gimplify_init_constructor): Don't write out a static
+       copy of the CONSTRUCTOR for TREE_ADDRESSABLE types or small sparse
+       initializers.
+
 2008-12-09 Tobias Grosser  <grosser@fim.uni-passau.de>
 
        PR middle-end/38084
index 2fea882811f9481f2e5ab5d90d31985de0b04fec..01b2fbef6b7ea865e64941b256335ad36b51c650 100644 (file)
@@ -3502,7 +3502,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
        struct gimplify_init_ctor_preeval_data preeval_data;
        HOST_WIDE_INT num_type_elements, num_ctor_elements;
        HOST_WIDE_INT num_nonzero_elements;
-       bool cleared, valid_const_initializer;
+       bool cleared, valid_const_initializer, sparse;
 
        /* Aggregate types must lower constructors to initialization of
           individual elements.  The exception is that a CONSTRUCTOR node
@@ -3558,6 +3558,9 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 
        num_type_elements = count_type_elements (type, true);
 
+       /* Are there significantly more zeros than non-zeros?  */
+       sparse = (num_nonzero_elements <= num_type_elements/4);
+
        /* If count_type_elements could not determine number of type elements
           for a constant-sized object, assume clearing is needed.
           Don't do this for variable-sized objects, as store_constructor
@@ -3567,7 +3570,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
        /* If there are "lots" of zeros, then block clear the object first.  */
        else if (num_type_elements - num_nonzero_elements
                 > CLEAR_RATIO (optimize_function_for_speed_p (cfun))
-                && num_nonzero_elements < num_type_elements/4)
+                && sparse)
          cleared = true;
        /* ??? This bit ought not be needed.  For any element not present
           in the initializer, we should simply set them to zero.  Except
@@ -3582,8 +3585,10 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
           be dropped to memory, and then memcpy'd out.  Don't do this
           for sparse arrays, though, as it's more efficient to follow
           the standard CONSTRUCTOR behavior of memset followed by
-          individual element initialization.  */
-       if (valid_const_initializer && !cleared)
+          individual element initialization.  Also don't try to do
+          bitwise copies of TREE_ADDRESSABLE types.  */
+       if (valid_const_initializer && !(cleared || sparse)
+           && !TREE_ADDRESSABLE (type))
          {
            HOST_WIDE_INT size = int_size_in_bytes (type);
            unsigned int align;
index 57a14fcdfab57c5e7e7ab2ad2760a4f55298fc54..07c5eb0c8efda1373b6a29ae5a0254988a8ecad3 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-08  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38410
+       * gcc.dg/ctor1.c: New test.
+
 2008-12-08  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/mips/fix-r10000-6.c: Add dg-message to look for
diff --git a/gcc/testsuite/gcc.dg/ctor1.c b/gcc/testsuite/gcc.dg/ctor1.c
new file mode 100644 (file)
index 0000000..6c1cd72
--- /dev/null
@@ -0,0 +1,10 @@
+/* Related to PR c++/38410.
+   We shouldn't write out a static variable for an all-zero aggregate
+   initializer.  The variable named C.0 was created by
+   gimplify_init_constructor. */
+/* { dg-final { scan-assembler-not "C\\.0" } } */
+
+int main()
+{
+  int a[] = { 0,0 };
+}