Commit fc64b448 by Andrew Pinski Committed by Andrew Pinski

re PR other/48981 (bootstrap-lto -O3 produces miscompiled, broken gcc)

2011-05-27  Andrew Pinski  <pinskia@gmail.com>

	PR middle-end/48981
	* gengtype.c (vec_prefix_type): New function.
	(note_def_vec): Use vec_prefix_type and change the length
	attribute to be based on the prefix.
	* vec.c: Include coretypes.h before vec.h.
	(struct vec_prefix): Remove.
	(vec_gc_p_reserve): Change the offsetof to sizeof.
	(vec_gc_p_reserve_exact): Likewise.
	(vec_heap_p_reserve): Likewise.
	(vec_heap_p_reserve_exact): Likewise.
	(vec_stack_o_reserve_1): Copy from +1 instead of from vec.
	(vec_stack_p_reserve): Change the offsetof to sizeof.
	(vec_stack_p_reserve_exact): Likewise.
	* vec.h (struct vec_prefix): New struct definition.
	(VEC_T(T,B)): Use vec_prefix instead of having num/alloc fields.
	(VEC_T_GTY(T,B)): Likewise.
	(DEF_VEC_FUNC_P(T)): Use prefix field.
	(DEF_VEC_NONALLOC_FUNCS_O(T,A)): Likewise.
	(DEF_VEC_NONALLOC_FUNCS_I(T,A)): Likewise.

From-SVN: r174359
parent 226855f0
2011-05-27 Andrew Pinski <pinskia@gmail.com>
PR middle-end/48981
* gengtype.c (vec_prefix_type): New function.
(note_def_vec): Use vec_prefix_type and change the length
attribute to be based on the prefix.
* vec.c: Include coretypes.h before vec.h.
(struct vec_prefix): Remove.
(vec_gc_p_reserve): Change the offsetof to sizeof.
(vec_gc_p_reserve_exact): Likewise.
(vec_heap_p_reserve): Likewise.
(vec_heap_p_reserve_exact): Likewise.
(vec_stack_o_reserve_1): Copy from +1 instead of from vec.
(vec_stack_p_reserve): Change the offsetof to sizeof.
(vec_stack_p_reserve_exact): Likewise.
* vec.h (struct vec_prefix): New struct definition.
(VEC_T(T,B)): Use vec_prefix instead of having num/alloc fields.
(VEC_T_GTY(T,B)): Likewise.
(DEF_VEC_FUNC_P(T)): Use prefix field.
(DEF_VEC_NONALLOC_FUNCS_O(T,A)): Likewise.
(DEF_VEC_NONALLOC_FUNCS_I(T,A)): Likewise.
2011-05-27 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR tree-optimization/46728
......
......@@ -4130,14 +4130,36 @@ write_roots (pair_p variables, bool emit_pch)
finish_root_table (flp, "pch_rs", "LAST_GGC_ROOT_TAB", "ggc_root_tab",
"gt_pch_scalar_rtab");
}
/* Record the definition of the vec_prefix structure, as defined in vec.h:
struct vec_prefix GTY(()) {
unsigned num;
unsigned alloc;
}; */
static type_p
vec_prefix_type (void)
{
static type_p prefix_type = NULL;
if (prefix_type == NULL)
{
pair_p fields;
static struct fileloc pos = { NULL, 0 };
type_p len_ty = create_scalar_type ("unsigned");
pos.file = input_file_by_name (__FILE__); pos.line = __LINE__;
fields = create_field_at (0, len_ty, "alloc", 0, &pos);
fields = create_field_at (fields, len_ty, "num", 0, &pos);
prefix_type = new_structure ("vec_prefix", 0, &pos, fields, 0);
prefix_type->u.s.bitmap = -1;
}
return prefix_type;
}
/* Record the definition of a generic VEC structure, as if we had expanded
the macros in vec.h:
typedef struct VEC_<type>_base GTY(()) {
unsigned num;
unsigned alloc;
<type> GTY((length ("%h.num"))) vec[1];
struct vec_prefix prefix;
<type> GTY((length ("%h.prefix.num"))) vec[1];
} VEC_<type>_base
where the GTY(()) tags are only present if is_scalar is _false_. */
......@@ -4148,7 +4170,6 @@ note_def_vec (const char *type_name, bool is_scalar, struct fileloc *pos)
pair_p fields;
type_p t;
options_p o;
type_p len_ty = create_scalar_type ("unsigned");
const char *name = concat ("VEC_", type_name, "_base", (char *) 0);
if (is_scalar)
......@@ -4159,12 +4180,11 @@ note_def_vec (const char *type_name, bool is_scalar, struct fileloc *pos)
else
{
t = resolve_typedef (type_name, pos);
o = create_string_option (0, "length", "%h.num");
o = create_string_option (0, "length", "%h.prefix.num");
}
/* We assemble the field list in reverse order. */
fields = create_field_at (0, create_array (t, "1"), "vec", o, pos);
fields = create_field_at (fields, len_ty, "alloc", 0, pos);
fields = create_field_at (fields, len_ty, "num", 0, pos);
fields = create_field_at (fields, vec_prefix_type (), "prefix", 0, pos);
do_typedef (name, new_structure (name, 0, pos, fields, 0), pos);
}
......
......@@ -28,20 +28,12 @@ along with GCC; see the file COPYING3. If not see
#endif
#include "system.h"
#include "coretypes.h"
#include "ggc.h"
#include "vec.h"
#include "coretypes.h"
#include "diagnostic-core.h"
#include "hashtab.h"
struct vec_prefix
{
unsigned num;
unsigned alloc;
void *vec[1];
};
#ifdef GATHER_STATISTICS
/* Store information about each particular vector. */
......@@ -254,7 +246,7 @@ void *
vec_gc_p_reserve (void *vec, int reserve MEM_STAT_DECL)
{
return vec_gc_o_reserve_1 (vec, reserve,
offsetof (struct vec_prefix, vec),
sizeof (struct vec_prefix),
sizeof (void *), false
PASS_MEM_STAT);
}
......@@ -268,7 +260,7 @@ void *
vec_gc_p_reserve_exact (void *vec, int reserve MEM_STAT_DECL)
{
return vec_gc_o_reserve_1 (vec, reserve,
offsetof (struct vec_prefix, vec),
sizeof (struct vec_prefix),
sizeof (void *), true
PASS_MEM_STAT);
}
......@@ -337,7 +329,7 @@ void *
vec_heap_p_reserve (void *vec, int reserve MEM_STAT_DECL)
{
return vec_heap_o_reserve_1 (vec, reserve,
offsetof (struct vec_prefix, vec),
sizeof (struct vec_prefix),
sizeof (void *), false
PASS_MEM_STAT);
}
......@@ -348,7 +340,7 @@ void *
vec_heap_p_reserve_exact (void *vec, int reserve MEM_STAT_DECL)
{
return vec_heap_o_reserve_1 (vec, reserve,
offsetof (struct vec_prefix, vec),
sizeof (struct vec_prefix),
sizeof (void *), true
PASS_MEM_STAT);
}
......@@ -443,8 +435,8 @@ vec_stack_o_reserve_1 (void *vec, int reserve, size_t vec_offset,
if (newvec && vec)
{
((struct vec_prefix *) newvec)->num = ((struct vec_prefix *) vec)->num;
memcpy (((struct vec_prefix *) newvec)->vec,
((struct vec_prefix *) vec)->vec,
memcpy (((struct vec_prefix *) newvec)+1,
((struct vec_prefix *) vec)+1,
((struct vec_prefix *) vec)->num * elt_size);
}
return newvec;
......@@ -456,7 +448,7 @@ void *
vec_stack_p_reserve (void *vec, int reserve MEM_STAT_DECL)
{
return vec_stack_o_reserve_1 (vec, reserve,
offsetof (struct vec_prefix, vec),
sizeof (struct vec_prefix),
sizeof (void *), false
PASS_MEM_STAT);
}
......@@ -467,7 +459,7 @@ void *
vec_stack_p_reserve_exact (void *vec, int reserve MEM_STAT_DECL)
{
return vec_stack_o_reserve_1 (vec, reserve,
offsetof (struct vec_prefix, vec),
sizeof (struct vec_prefix),
sizeof (void *), true
PASS_MEM_STAT);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment