re PR c/52977 (internal compiler error: Segmentation fault with `-x c-header' or `-x cxx-header' option)

2012-04-16  Richard Guenther  <rguenther@suse.de>

	PR middle-end/52977
	* tree.h (VECTOR_CST_NELTS): Adjust.
	(struct tree_vector): Add explicit length field.
	(make_vector_stat): Declare.
	(make_vector): Define.
	* tree.c (make_vector_stat): New function.
	(build_vector_stat): Use it.
	* tree-streamer-in.c (streamer_alloc_tree): Likewise.

From-SVN: r186494
This commit is contained in:
Richard Guenther 2012-04-16 13:21:30 +00:00 committed by Richard Biener
parent fba621209f
commit ac9a074c72
4 changed files with 37 additions and 16 deletions

View File

@ -1,3 +1,14 @@
2012-04-16 Richard Guenther <rguenther@suse.de>
PR middle-end/52977
* tree.h (VECTOR_CST_NELTS): Adjust.
(struct tree_vector): Add explicit length field.
(make_vector_stat): Declare.
(make_vector): Define.
* tree.c (make_vector_stat): New function.
(build_vector_stat): Use it.
* tree-streamer-in.c (streamer_alloc_tree): Likewise.
2012-04-16 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR tree-optimization/52976

View File

@ -476,10 +476,7 @@ streamer_alloc_tree (struct lto_input_block *ib, struct data_in *data_in,
else if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
{
HOST_WIDE_INT len = streamer_read_hwi (ib);
result = ggc_alloc_zone_cleared_tree_node ((len - 1) * sizeof (tree)
+ sizeof (struct tree_vector),
&tree_zone);
TREE_SET_CODE (result, VECTOR_CST);
result = make_vector (len);
}
else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
{

View File

@ -1315,6 +1315,25 @@ cst_and_fits_in_hwi (const_tree x)
|| TREE_INT_CST_HIGH (x) == -1);
}
/* Build a newly constructed TREE_VEC node of length LEN. */
tree
make_vector_stat (unsigned len MEM_STAT_DECL)
{
tree t;
unsigned length = (len - 1) * sizeof (tree) + sizeof (struct tree_vector);
record_node_allocation_statistics (VECTOR_CST, length);
t = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
TREE_SET_CODE (t, VECTOR_CST);
TREE_CONSTANT (t) = 1;
VECTOR_CST_NELTS (t) = len;
return t;
}
/* Return a new VECTOR_CST node whose type is TYPE and whose values
are in a list pointed to by VALS. */
@ -1323,16 +1342,7 @@ build_vector_stat (tree type, tree *vals MEM_STAT_DECL)
{
int over = 0;
unsigned cnt = 0;
tree v;
int length = ((TYPE_VECTOR_SUBPARTS (type) - 1) * sizeof (tree)
+ sizeof (struct tree_vector));
record_node_allocation_statistics (VECTOR_CST, length);
v = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
TREE_SET_CODE (v, VECTOR_CST);
TREE_CONSTANT (v) = 1;
tree v = make_vector (TYPE_VECTOR_SUBPARTS (type));
TREE_TYPE (v) = type;
/* Iterate through elements and check for overflow. */

View File

@ -1534,13 +1534,14 @@ struct GTY(()) tree_complex {
};
/* In a VECTOR_CST node. */
#define VECTOR_CST_NELTS(NODE) (TYPE_VECTOR_SUBPARTS (TREE_TYPE (NODE)))
#define VECTOR_CST_NELTS(NODE) (VECTOR_CST_CHECK (NODE)->vector.length)
#define VECTOR_CST_ELTS(NODE) (VECTOR_CST_CHECK (NODE)->vector.elts)
#define VECTOR_CST_ELT(NODE,IDX) (VECTOR_CST_CHECK (NODE)->vector.elts[IDX])
struct GTY(()) tree_vector {
struct tree_typed typed;
tree GTY ((length ("TYPE_VECTOR_SUBPARTS (TREE_TYPE ((tree)&%h))"))) elts[1];
unsigned length;
tree GTY ((length ("%h.length"))) elts[1];
};
#include "symtab.h"
@ -4341,6 +4342,8 @@ build_int_cstu (tree type, unsigned HOST_WIDE_INT cst)
extern tree build_int_cst (tree, HOST_WIDE_INT);
extern tree build_int_cst_type (tree, HOST_WIDE_INT);
extern tree build_int_cst_wide (tree, unsigned HOST_WIDE_INT, HOST_WIDE_INT);
extern tree make_vector_stat (unsigned MEM_STAT_DECL);
#define make_vector(n) make_vector_stat (n MEM_STAT_INFO)
extern tree build_vector_stat (tree, tree * MEM_STAT_DECL);
#define build_vector(t,v) build_vector_stat (t, v MEM_STAT_INFO)
extern tree build_vector_from_ctor (tree, VEC(constructor_elt,gc) *);