diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-08-28 11:44:57 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2007-08-28 11:44:57 +0200 |
commit | a7d0852d3f7d3e0a596f53efb2d75cf522ffb43f (patch) | |
tree | 4157d365858a0a5f25d896c2f084ec1c1692a791 | |
parent | 6a76d2166ce933df0b010f83004cb10f5dde4fb3 (diff) | |
download | gcc-a7d0852d3f7d3e0a596f53efb2d75cf522ffb43f.zip gcc-a7d0852d3f7d3e0a596f53efb2d75cf522ffb43f.tar.gz gcc-a7d0852d3f7d3e0a596f53efb2d75cf522ffb43f.tar.bz2 |
re PR debug/32914 (ICE in rtl_for_decl_init with -g option)
PR debug/32914
* dwarf2out.c (rtl_for_decl_init): If vector decl has CONSTRUCTOR
initializer, use build_vector_from_ctor if possible to create
VECTOR_CST out of it. If vector initializer is not VECTOR_CST
even after this, return NULL.
* d++.dg/debug/const3.C: New test.
* d++.dg/debug/const4.C: New test.
* d++.dg/debug/dwarf2/const1.C: New test.
* d++.dg/debug/dwarf2/const2.C: New test.
* d++.dg/debug/dwarf2/const2b.C: New test.
From-SVN: r127854
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 37 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/debug/const3.C | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/debug/const4.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/debug/dwarf2/const1.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/debug/dwarf2/const2.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/debug/dwarf2/const2b.C | 6 |
8 files changed, 77 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a7e84cf..9f7fe58 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2007-08-28 Jakub Jelinek <jakub@redhat.com> + + PR debug/32914 + * dwarf2out.c (rtl_for_decl_init): If vector decl has CONSTRUCTOR + initializer, use build_vector_from_ctor if possible to create + VECTOR_CST out of it. If vector initializer is not VECTOR_CST + even after this, return NULL. + 2007-08-28 Gabriel Dos Reis <gdr@integrable-solutions.net> * c-pretty-print.c (pp_c_constant): Handle COMPLEX_CST. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 0463f1f..e1b332f 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -10403,6 +10403,43 @@ rtl_for_decl_init (tree init, tree type) else if (initializer_constant_valid_p (init, type) && ! walk_tree (&init, reference_to_unused, NULL, NULL)) { + /* Convert vector CONSTRUCTOR initializers to VECTOR_CST if + possible. */ + if (TREE_CODE (type) == VECTOR_TYPE) + switch (TREE_CODE (init)) + { + case VECTOR_CST: + break; + case CONSTRUCTOR: + if (TREE_CONSTANT (init)) + { + VEC(constructor_elt,gc) *elts = CONSTRUCTOR_ELTS (init); + bool constant_p = true; + tree value; + unsigned HOST_WIDE_INT ix; + + /* Even when ctor is constant, it might contain non-*_CST + elements (e.g. { 1.0/0.0 - 1.0/0.0, 0.0 }) and those don't + belong into VECTOR_CST nodes. */ + FOR_EACH_CONSTRUCTOR_VALUE (elts, ix, value) + if (!CONSTANT_CLASS_P (value)) + { + constant_p = false; + break; + } + + if (constant_p) + { + init = build_vector_from_ctor (type, elts); + break; + } + } + /* FALLTHRU */ + + default: + return NULL; + } + rtl = expand_expr (init, NULL_RTX, VOIDmode, EXPAND_INITIALIZER); /* If expand_expr returns a MEM, it wasn't immediate. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 690128f..49b1b9f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2007-08-28 Jakub Jelinek <jakub@redhat.com> + + PR debug/32914 + * d++.dg/debug/const3.C: New test. + * d++.dg/debug/const4.C: New test. + * d++.dg/debug/dwarf2/const1.C: New test. + * d++.dg/debug/dwarf2/const2.C: New test. + * d++.dg/debug/dwarf2/const2b.C: New test. + 2007-08-28 Mircea Namolaru <namolaru@il.ibm.com> Vladimir Yanovsky <yanov@il.ibm.com> Revital Eres <eres@il.ibm.com> diff --git a/gcc/testsuite/g++.dg/debug/const3.C b/gcc/testsuite/g++.dg/debug/const3.C new file mode 100644 index 0000000..375c548 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/const3.C @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +typedef float FloatVect __attribute__((__vector_size__(16))); +const FloatVect Foo = { 250000000.0, 0.0, 0.0, 0.0 }; diff --git a/gcc/testsuite/g++.dg/debug/const4.C b/gcc/testsuite/g++.dg/debug/const4.C new file mode 100644 index 0000000..ec8133d --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/const4.C @@ -0,0 +1,2 @@ +/* { dg-do compile } */ +const __complex__ int x = 2i; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/const1.C b/gcc/testsuite/g++.dg/debug/dwarf2/const1.C new file mode 100644 index 0000000..be23c10 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/const1.C @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-O -gdwarf-2 -dA" } */ +/* { dg-final { scan-assembler "DW_AT_const_value" } } */ + +extern void x (); +void (* const f) () = x; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/const2.C b/gcc/testsuite/g++.dg/debug/dwarf2/const2.C new file mode 100644 index 0000000..27f4c26 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/const2.C @@ -0,0 +1,6 @@ +/* { dg-do compile { target powerpc_altivec_ok } } */ +/* { dg-options "-O -gdwarf-2 -dA -maltivec" } */ +/* { dg-final { scan-assembler "DW_AT_const_value" } } */ + +typedef float FloatVect __attribute__((__vector_size__(16))); +const FloatVect Foo = { 250000000.0, 0.0, 0.0, 0.0 }; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/const2b.C b/gcc/testsuite/g++.dg/debug/dwarf2/const2b.C new file mode 100644 index 0000000..593e080 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/const2b.C @@ -0,0 +1,6 @@ +/* { dg-do compile { target i386*-*-* } } */ +/* { dg-options "-O -gdwarf-2 -dA -msse" } */ +/* { dg-final { scan-assembler "DW_AT_const_value" } } */ + +typedef float FloatVect __attribute__((__vector_size__(16))); +const FloatVect Foo = { 250000000.0, 0.0, 0.0, 0.0 }; |