Re: [lto]: merge from trunk

Top Page

Reply to this message
Author: Bill Maddox
Date:  
To: Kenneth Zadeck
CC: Diego Novillo, Ollie Wild, Hubicha, Jan, gcc-patches, Kai Tietz
Subject: Re: [lto]: merge from trunk
On Wed, Jul 9, 2008 at 4:05 PM, Kenneth Zadeck <zadeck@???> wrote:

> seems to assert in a number of tests. I assume that this is related to no
> quite getting everything in the va type correct. This needs to be looked
> into further.


I attempted to build the branch, and found that it failed due to 1)
the use of an uninitialized variable
in input_binfo (see my remarks on Rafael's last patch) and 2) zillions
of warnings, treated as errors,
about implicit casts and casting away of qualifiers presumably due to
the -Wcast-qual and -Wc++-compat
flags. My configuration is very vanilla, with default compiler
options. It's not clear why I have seen
these problems and Kenny did not, unless my host compiler interprets
these options differently.
In any case, here is a patch for all these issues that compiles and
appears to work -- no change log or
regression test run yet. I suppose it could be argued that we should
be using these warnings and make
our code clean, but was it our intent to throw the switch now?

--Bill
Index: gcc/lto-function-out.c
===================================================================
--- gcc/lto-function-out.c    (revision 137683)
+++ gcc/lto-function-out.c    (working copy)
@@ -132,7 +132,7 @@ static void
string_slot_free (void *p)
{
struct string_slot *slot = (struct string_slot *)p;
- free ((void *)slot->s);
+ free (CONST_CAST (void *, (const void *) slot->s));
free (slot);
}

@@ -159,20 +159,21 @@ clear_line_info (struct output_block *ob
struct output_block *
create_output_block (enum lto_section_type section_type)
{
- struct output_block *ob = xcalloc (1, sizeof (struct output_block));
+ struct output_block *ob
+ = (struct output_block *) xcalloc (1, sizeof (struct output_block));

ob->section_type = section_type;
ob->decl_state = lto_get_out_decl_state ();
- ob->main_stream = xcalloc (1, sizeof (struct lto_output_stream));
- ob->string_stream = xcalloc (1, sizeof (struct lto_output_stream));
+ ob->main_stream = (struct lto_output_stream *) xcalloc (1, sizeof (struct lto_output_stream));
+ ob->string_stream = (struct lto_output_stream *) xcalloc (1, sizeof (struct lto_output_stream));

if (section_type == LTO_section_function_body)
{
- ob->local_decl_index_stream = xcalloc (1, sizeof (struct lto_output_stream));
- ob->local_decl_stream = xcalloc (1, sizeof (struct lto_output_stream));
- ob->named_label_stream = xcalloc (1, sizeof (struct lto_output_stream));
- ob->ssa_names_stream = xcalloc (1, sizeof (struct lto_output_stream));
- ob->cfg_stream = xcalloc (1, sizeof (struct lto_output_stream));
+ ob->local_decl_index_stream = (struct lto_output_stream *) xcalloc (1, sizeof (struct lto_output_stream));
+ ob->local_decl_stream = (struct lto_output_stream *) xcalloc (1, sizeof (struct lto_output_stream));
+ ob->named_label_stream = (struct lto_output_stream *) xcalloc (1, sizeof (struct lto_output_stream));
+ ob->ssa_names_stream = (struct lto_output_stream *) xcalloc (1, sizeof (struct lto_output_stream));
+ ob->cfg_stream = (struct lto_output_stream *) xcalloc (1, sizeof (struct lto_output_stream));
}
#ifdef LTO_STREAM_DEBUGGING
lto_debug_context.out = lto_debug_out_fun;
@@ -272,9 +273,9 @@ output_string (struct output_block *ob,
struct lto_output_stream *string_stream = ob->string_stream;
unsigned int start = string_stream->total_size;
struct string_slot *new_slot
-    = xmalloc (sizeof (struct string_slot));
+    = (struct string_slot *) xmalloc (sizeof (struct string_slot));
unsigned int i;
- char *new_string = xmalloc (len);
+ char *new_string = (char *) xmalloc (len);

memcpy (new_string, string, len);
new_slot->s = new_string;
@@ -665,7 +666,8 @@ output_label_ref (struct output_block *o
slot = htab_find_slot (ob->label_hash_table, &d_slot, INSERT);
if (*slot == NULL)
{
- struct lto_decl_slot *new_slot = xmalloc (sizeof (struct lto_decl_slot));
+ struct lto_decl_slot *new_slot
+    = (struct lto_decl_slot *) xmalloc (sizeof (struct lto_decl_slot));

/* Named labels are given positive integers and unnamed labels are
     given negative indexes. */
@@ -2023,7 +2025,8 @@ produce_asm (struct output_block *ob, tr
header.debug_main_size = -1;
#endif

- header_stream = xcalloc (1, sizeof (struct lto_output_stream));
+ header_stream = ((struct lto_output_stream *)
+         xcalloc (1, sizeof (struct lto_output_stream)));
lto_output_data_stream (header_stream, &header, sizeof header);
lto_write_stream (header_stream);
free (header_stream);
@@ -2093,7 +2096,6 @@ lto_static_init (void)
#if REDUNDANT_TYPE_SYSTEM
/* These forms never need types. */
sbitmap_ones (lto_types_needed_for);
- RESET_BIT (lto_types_needed_for, TREE_BINFO);
RESET_BIT (lto_types_needed_for, ASM_EXPR);
RESET_BIT (lto_types_needed_for, CASE_LABEL_EXPR);
RESET_BIT (lto_types_needed_for, FIELD_DECL);
@@ -2816,7 +2818,6 @@ output_binfo (struct output_block *ob, t
output_uleb128 (ob, num_base_accesses);
output_uleb128 (ob, num_base_binfos);

- /* need flags */
output_tree (ob, binfo->common.type);

output_tree (ob, binfo->binfo.offset);
@@ -2982,7 +2983,7 @@ output_tree (struct output_block *ob, tr
}

global_index = ob->next_main_index++;
- new_slot = xmalloc (sizeof (struct lto_decl_slot));
+ new_slot = (struct lto_decl_slot *) xmalloc (sizeof (struct lto_decl_slot));
new_slot->t = expr;
new_slot->slot_num = global_index;
*slot = new_slot;
Index: gcc/lto-function-in.c
===================================================================
--- gcc/lto-function-in.c    (revision 137683)
+++ gcc/lto-function-in.c    (working copy)
@@ -242,7 +242,8 @@ input_type_ref_1 (struct data_in *data_i
struct lto_input_block lib;

#ifdef LTO_STREAM_DEBUGGING
- struct lto_input_block *current = lto_debug_context.current_data;
+ struct lto_input_block *current
+     = (struct lto_input_block *)lto_debug_context.current_data;
struct lto_input_block debug;
int current_indent = lto_debug_context.indent;

@@ -399,9 +400,9 @@ canon_file_name (const char *string)
if (*slot == NULL)
{
size_t len = strlen (string);
- char * saved_string = xmalloc (len + 1);
- struct string_slot *new_slot
-    = xmalloc (sizeof (struct string_slot));
+ char * saved_string = (char *) xmalloc (len + 1);
+ struct string_slot *new_slot =
+    (struct string_slot *) xmalloc (sizeof (struct string_slot));

strcpy (saved_string, string);
new_slot->s = saved_string;
@@ -657,7 +658,8 @@ input_expr_operand (struct lto_input_blo
struct lto_input_block lib;

#ifdef LTO_STREAM_DEBUGGING
- struct lto_input_block *current = lto_debug_context.current_data;
+ struct lto_input_block *current
+        = (struct lto_input_block *) lto_debug_context.current_data;
struct lto_input_block debug;
int current_indent = lto_debug_context.indent;

@@ -712,7 +714,8 @@ input_expr_operand (struct lto_input_blo
struct lto_input_block lib;

#ifdef LTO_STREAM_DEBUGGING
- struct lto_input_block *current = lto_debug_context.current_data;
+ struct lto_input_block *current
+        = (struct lto_input_block *) lto_debug_context.current_data;
struct lto_input_block debug;
int current_indent = lto_debug_context.indent;

@@ -770,7 +773,8 @@ input_expr_operand (struct lto_input_blo
     struct lto_input_block lib;

#ifdef LTO_STREAM_DEBUGGING
-     struct lto_input_block *current = lto_debug_context.current_data;
+     struct lto_input_block *current
+        = (struct lto_input_block *) lto_debug_context.current_data;
     struct lto_input_block debug;
     int current_indent = lto_debug_context.indent;

@@ -1187,7 +1191,7 @@ input_labels (struct lto_input_block *ib
code, the unnamed labels have a negative index. Their position
in the array can be found by subtracting that index from the
number of named labels. */
- data_in->labels = xcalloc (named_count + unnamed_count, sizeof (tree));
+ data_in->labels = (tree *) xcalloc (named_count + unnamed_count, sizeof (tree));
for (i = 0; i < named_count; i++)
{
unsigned int name_index = lto_input_uleb128 (ib);
@@ -1211,9 +1215,9 @@ input_local_vars_index (struct lto_input
            unsigned int count)
{
unsigned int i;
- data_in->local_decls_index = xcalloc (count, sizeof (unsigned int));
+ data_in->local_decls_index = (int *) xcalloc (count, sizeof (unsigned int));
#ifdef LTO_STREAM_DEBUGGING
- data_in->local_decls_index_d = xcalloc (count, sizeof (unsigned int));
+ data_in->local_decls_index_d = (int *) xcalloc (count, sizeof (unsigned int));
#endif

for (i = 0; i < count; i++)
@@ -1259,7 +1263,8 @@ input_local_tree (struct lto_input_block
struct lto_input_block lib;

#ifdef LTO_STREAM_DEBUGGING
- struct lto_input_block *current = lto_debug_context.current_data;
+ struct lto_input_block *current
+     = (struct lto_input_block *) lto_debug_context.current_data;
struct lto_input_block debug;
int current_indent = lto_debug_context.indent;

@@ -1641,8 +1646,8 @@ input_local_vars (struct lto_input_block
int i;
unsigned int tag;

- data_in->local_decl_indexes = xcalloc (count, sizeof (int));
- data_in->local_decls = xcalloc (count, sizeof (tree*));
+ data_in->local_decl_indexes = (int *) xcalloc (count, sizeof (int));
+ data_in->local_decls = (tree *) xcalloc (count, sizeof (tree*));

memset (data_in->local_decl_indexes, -1, count * sizeof (int));

@@ -1981,7 +1986,7 @@ input_function (tree fn_decl, struct dat

/* Fix up the call stmts that are mentioned in the cgraph_edges. */
renumber_gimple_stmt_uids ();
- stmts = xcalloc (gimple_stmt_max_uid(fn), sizeof (tree));
+ stmts = (tree *) xcalloc (gimple_stmt_max_uid(fn), sizeof (tree));
FOR_ALL_BB (bb)
{
block_stmt_iterator bsi;
@@ -2834,12 +2839,15 @@ input_binfo (struct lto_input_block *ib,
size_t num_base_binfos;
lto_flags_type flags;

+ flags = input_tree_flags (ib, TREE_BINFO, true);
+
num_base_accesses = lto_input_uleb128 (ib);
num_base_binfos = lto_input_uleb128 (ib);

binfo = make_tree_binfo (num_base_binfos);

/* no line info */
+ gcc_assert (!input_line_info (ib, data_in, flags));
process_tree_flags (binfo, flags);

global_vector_enter (data_in, binfo);
@@ -2972,7 +2980,9 @@ input_tree_operand (struct lto_input_blo

gcc_assert (code);

- if (TREE_CODE_CLASS (code) != tcc_type && TREE_CODE_CLASS (code) != tcc_declaration)
+ if (TREE_CODE_CLASS (code) != tcc_type
+ && TREE_CODE_CLASS (code) != tcc_declaration
+ && code != TREE_BINFO)
{
if (TEST_BIT (lto_types_needed_for, code))
type = input_type_tree (data_in, ib);
Index: gcc/lto-section-out.c
===================================================================
--- gcc/lto-section-out.c    (revision 137683)
+++ gcc/lto-section-out.c    (working copy)
@@ -130,7 +130,6 @@ lto_eq_type_slot_node (const void *p1, c
}


-/* ### */
/* Returns a hash code for P. */

hashval_t
@@ -141,7 +140,6 @@ lto_hash_global_slot_node (const void *p
}


-/* ### */
/* Returns nonzero if P1 and P2 are equal. */

int
@@ -325,7 +323,7 @@ lto_output_data_stream (struct lto_outpu
obs->current_pointer += copy;
obs->total_size += copy;
obs->left_in_block -= copy;
- data = (char *)data + copy;
+ data = (const char *) data + copy;
len -= copy;
}
}
@@ -465,7 +463,8 @@ lto_output_decl_index (struct lto_output
slot = htab_find_slot (table, &d_slot, INSERT);
if (*slot == NULL)
{
- struct lto_decl_slot *new_slot = xmalloc (sizeof (struct lto_decl_slot));
+ struct lto_decl_slot *new_slot
+    = (struct lto_decl_slot *) xmalloc (sizeof (struct lto_decl_slot));
int index = (*next_index)++;

new_slot->t = name;
@@ -593,12 +592,14 @@ lto_output_type_ref_index (struct lto_ou
struct lto_simple_output_block *
lto_create_simple_output_block (enum lto_section_type section_type)
{
- struct lto_simple_output_block *ob
- = xcalloc (1, sizeof (struct lto_simple_output_block));
+ struct lto_simple_output_block *ob
+ = ((struct lto_simple_output_block *)
+ xcalloc (1, sizeof (struct lto_simple_output_block)));

ob->section_type = section_type;
ob->decl_state = lto_get_out_decl_state ();
- ob->main_stream = xcalloc (1, sizeof (struct lto_output_stream));
+ ob->main_stream = ((struct lto_output_stream *)
+         xcalloc (1, sizeof (struct lto_output_stream)));

#ifdef LTO_STREAM_DEBUGGING
lto_debug_context.out = lto_debug_out_fun;
@@ -640,7 +641,8 @@ lto_destroy_simple_output_block (struct
header.debug_main_size = -1;
#endif

- header_stream = xcalloc (1, sizeof (struct lto_output_stream));
+ header_stream = ((struct lto_output_stream *)
+         xcalloc (1, sizeof (struct lto_output_stream)));
lto_output_data_stream (header_stream, &header, sizeof header);
lto_write_stream (header_stream);
free (header_stream);
@@ -673,7 +675,8 @@ lto_get_out_decl_state (void)

if (!out_state)
{
- out_state = xcalloc (1, sizeof (struct lto_out_decl_state));
+ out_state = ((struct lto_out_decl_state *)
+         xcalloc (1, sizeof (struct lto_out_decl_state)));

out_state->field_decl_hash_table
    = htab_create (37, lto_hash_decl_slot_node, lto_eq_decl_slot_node,
@@ -714,7 +717,8 @@ preload_common_node (struct output_block
/* If well-known trees are not unique, we don't create duplicate entries. */
if (*slot == NULL)
{
- struct lto_decl_slot *new_slot = xmalloc (sizeof (struct lto_decl_slot));
+ struct lto_decl_slot *new_slot
+    = (struct lto_decl_slot *) xmalloc (sizeof (struct lto_decl_slot));
unsigned index = ob->next_main_index++;
new_slot->t = t;
new_slot->slot_num = index;
@@ -800,7 +804,8 @@ write_global_references (struct output_b
int index;
struct lto_output_stream *ref_stream;

- ref_stream = xcalloc (1, sizeof (struct lto_output_stream));
+ ref_stream = ((struct lto_output_stream *)
+        xcalloc (1, sizeof (struct lto_output_stream)));
for (index = 0; VEC_iterate(tree, v, index, t); index++)
{
void **slot;
@@ -891,7 +896,8 @@ produce_asm_for_decls (void)
header.debug_main_size = ob->debug_main_stream->total_size;
#endif

- header_stream = xcalloc (1, sizeof (struct lto_output_stream));
+ header_stream = ((struct lto_output_stream *)
+         xcalloc (1, sizeof (struct lto_output_stream)));
lto_output_data_stream (header_stream, &header, sizeof header);
lto_write_stream (header_stream);
free (header_stream);
Index: gcc/lto-section-out.h
===================================================================
--- gcc/lto-section-out.h    (revision 137683)
+++ gcc/lto-section-out.h    (working copy)
@@ -54,7 +54,7 @@ struct lto_output_stream
#ifdef LTO_STREAM_DEBUGGING
#define LTO_SET_DEBUGGING_STREAM(STREAM,CONTEXT)    \
do { \
- ob-> STREAM = xcalloc (1, sizeof (struct lto_output_stream)); \
+ ob-> STREAM = (struct lto_output_stream *) xcalloc (1, sizeof (struct lto_output_stream)); \
lto_debug_context. CONTEXT = ob-> STREAM; \
lto_debug_context.current_data = ob-> STREAM; \
lto_debug_context.stream_name = #CONTEXT; \