From: Kaveh R. Ghazi Date: Thu, 26 Jun 2008 00:25:08 +0000 (+0000) Subject: dwarf2out.c (new_cfi, [...]): Fix -Wc++-compat and/or -Wcast-qual warnings. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1b4572a81dd40921680e70eef7469f0c80bc20e0;p=gcc.git dwarf2out.c (new_cfi, [...]): Fix -Wc++-compat and/or -Wcast-qual warnings. * dwarf2out.c (new_cfi, queue_reg_save, dwarf2out_begin_prologue, dwarf2out_frame_init, new_loc_descr, new_die, lookup_decl_die, lookup_decl_loc, add_var_loc_to_decl, compute_section_prefix, assign_symbol_names, htab_cu_hash, htab_cu_eq, htab_cu_del, build_abbrev_table, new_loc_list, output_comp_unit, add_arange, add_ranges_num, add_ranges_by_labels, file_info_cmp, file_name_acquire, output_file_names, add_const_value_attribute, premark_used_types_helper, file_table_eq, file_table_hash, lookup_filename, dwarf2out_var_location, dwarf2out_source_line, dwarf2out_init, file_table_relative_p): Fix -Wc++-compat and/or -Wcast-qual warnings. * ebitmap.c (ebitmap_array_grow, ebitmap_array_init, ebitmap_alloc, ebitmap_ior, ebitmap_and_compl): Likewise. * emit-rtl.c (get_mem_attrs, get_reg_attrs, gen_rtvec, gen_reg_rtx, start_sequence, init_emit): Likewise. * et-forest.c (et_new_occ, et_new_tree): Likewise. * except.c (init_eh_for_function, gen_eh_region, remove_unreachable_regions, add_ehl_entry, duplicate_eh_regions_1, arh_to_landing_pad, arh_to_label, add_action_record, add_call_site, switch_to_exception_section): Likewise. * expmed.c (synth_mult): Likewise. * expr.c (gen_group_rtx, emit_group_load, emit_group_store, store_expr): Likewise. * final.c (shorten_branches, final_scan_insn, debug_queue_symbol): Likewise. * function.c (assign_stack_temp_for_type, allocate_struct_function, match_asm_constraints_1): Likewise. * gcov-io.c (gcov_allocate): Likewise. * gcse.c (GNEW, GCNEW, GNEWVEC, GCNEWVEC, GRESIZEVEC, GNEWVAR, GCNEWVAR, GRESIZEVAR, GOBNEW, GOBNEWVAR): New. (gcse_main, alloc_gcse_mem, alloc_gcse_mem, alloc_reg_set_mem, record_one_set, insert_expr_in_table, insert_set_in_table, dump_hash_table, compute_hash_table_work, alloc_hash_table, pre_ldst_expr_hash, pre_ldst_expr_eq, find_rtx_in_ldst, reg_set_info, reg_clear_last_set): Fix -Wc++-compat and/or -Wcast-qual warnings. From-SVN: r137136 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a65715f1c93..d6d59206044 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,42 @@ +2008-06-25 Kaveh R. Ghazi + + * dwarf2out.c (new_cfi, queue_reg_save, dwarf2out_begin_prologue, + dwarf2out_frame_init, new_loc_descr, new_die, lookup_decl_die, + lookup_decl_loc, add_var_loc_to_decl, compute_section_prefix, + assign_symbol_names, htab_cu_hash, htab_cu_eq, htab_cu_del, + build_abbrev_table, new_loc_list, output_comp_unit, add_arange, + add_ranges_num, add_ranges_by_labels, file_info_cmp, + file_name_acquire, output_file_names, add_const_value_attribute, + premark_used_types_helper, file_table_eq, file_table_hash, + lookup_filename, dwarf2out_var_location, dwarf2out_source_line, + dwarf2out_init, file_table_relative_p): Fix -Wc++-compat and/or + -Wcast-qual warnings. + * ebitmap.c (ebitmap_array_grow, ebitmap_array_init, + ebitmap_alloc, ebitmap_ior, ebitmap_and_compl): Likewise. + * emit-rtl.c (get_mem_attrs, get_reg_attrs, gen_rtvec, + gen_reg_rtx, start_sequence, init_emit): Likewise. + * et-forest.c (et_new_occ, et_new_tree): Likewise. + * except.c (init_eh_for_function, gen_eh_region, + remove_unreachable_regions, add_ehl_entry, duplicate_eh_regions_1, + arh_to_landing_pad, arh_to_label, add_action_record, + add_call_site, switch_to_exception_section): Likewise. + * expmed.c (synth_mult): Likewise. + * expr.c (gen_group_rtx, emit_group_load, emit_group_store, + store_expr): Likewise. + * final.c (shorten_branches, final_scan_insn, debug_queue_symbol): + Likewise. + * function.c (assign_stack_temp_for_type, + allocate_struct_function, match_asm_constraints_1): Likewise. + * gcov-io.c (gcov_allocate): Likewise. + * gcse.c (GNEW, GCNEW, GNEWVEC, GCNEWVEC, GRESIZEVEC, GNEWVAR, + GCNEWVAR, GRESIZEVAR, GOBNEW, GOBNEWVAR): New. + (gcse_main, alloc_gcse_mem, alloc_gcse_mem, alloc_reg_set_mem, + record_one_set, insert_expr_in_table, insert_set_in_table, + dump_hash_table, compute_hash_table_work, alloc_hash_table, + pre_ldst_expr_hash, pre_ldst_expr_eq, find_rtx_in_ldst, + reg_set_info, reg_clear_last_set): Fix -Wc++-compat and/or + -Wcast-qual warnings. + 2008-06-25 Kaveh R. Ghazi * cse.c (approx_reg_cost_1, cse_insn): Fix -Wc++-compat and/or diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index ba17c3f5c2d..f3d917e2679 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -606,7 +606,7 @@ dwarf_cfi_name (unsigned int cfi_opc) static inline dw_cfi_ref new_cfi (void) { - dw_cfi_ref cfi = ggc_alloc (sizeof (dw_cfi_node)); + dw_cfi_ref cfi = GGC_NEW (dw_cfi_node); cfi->dw_cfi_next = NULL; cfi->dw_cfi_oprnd1.dw_cfi_reg_num = 0; @@ -1251,7 +1251,7 @@ queue_reg_save (const char *label, rtx reg, rtx sreg, HOST_WIDE_INT offset) if (q == NULL) { - q = ggc_alloc (sizeof (*q)); + q = GGC_NEW (struct queued_reg_save); q->next = queued_reg_saves; queued_reg_saves = q; } @@ -2643,8 +2643,7 @@ dwarf2out_begin_prologue (unsigned int line ATTRIBUTE_UNUSED, if (fde_table_in_use == fde_table_allocated) { fde_table_allocated += FDE_TABLE_INCREMENT; - fde_table = ggc_realloc (fde_table, - fde_table_allocated * sizeof (dw_fde_node)); + fde_table = GGC_RESIZEVEC (dw_fde_node, fde_table, fde_table_allocated); memset (fde_table + fde_table_in_use, 0, FDE_TABLE_INCREMENT * sizeof (dw_fde_node)); } @@ -2704,7 +2703,7 @@ void dwarf2out_frame_init (void) { /* Allocate the initial hunk of the fde_table. */ - fde_table = ggc_alloc_cleared (FDE_TABLE_INCREMENT * sizeof (dw_fde_node)); + fde_table = GGC_CNEWVEC (dw_fde_node, FDE_TABLE_INCREMENT); fde_table_allocated = FDE_TABLE_INCREMENT; fde_table_in_use = 0; @@ -3228,7 +3227,7 @@ static inline dw_loc_descr_ref new_loc_descr (enum dwarf_location_atom op, unsigned HOST_WIDE_INT oprnd1, unsigned HOST_WIDE_INT oprnd2) { - dw_loc_descr_ref descr = ggc_alloc_cleared (sizeof (dw_loc_descr_node)); + dw_loc_descr_ref descr = GGC_CNEW (dw_loc_descr_node); descr->dw_loc_opc = op; descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const; @@ -5747,7 +5746,7 @@ splice_child_die (dw_die_ref parent, dw_die_ref child) static inline dw_die_ref new_die (enum dwarf_tag tag_value, dw_die_ref parent_die, tree t) { - dw_die_ref die = ggc_alloc_cleared (sizeof (die_node)); + dw_die_ref die = GGC_CNEW (die_node); die->die_tag = tag_value; @@ -5757,7 +5756,7 @@ new_die (enum dwarf_tag tag_value, dw_die_ref parent_die, tree t) { limbo_die_node *limbo_node; - limbo_node = ggc_alloc_cleared (sizeof (limbo_die_node)); + limbo_node = GGC_CNEW (limbo_die_node); limbo_node->die = die; limbo_node->created_for = t; limbo_node->next = limbo_die_list; @@ -5804,7 +5803,7 @@ decl_die_table_eq (const void *x, const void *y) static inline dw_die_ref lookup_decl_die (tree decl) { - return htab_find_with_hash (decl_die_table, decl, DECL_UID (decl)); + return (dw_die_ref) htab_find_with_hash (decl_die_table, decl, DECL_UID (decl)); } /* Returns a hash value for X (which really is a var_loc_list). */ @@ -5829,7 +5828,8 @@ decl_loc_table_eq (const void *x, const void *y) static inline var_loc_list * lookup_decl_loc (const_tree decl) { - return htab_find_with_hash (decl_loc_table, decl, DECL_UID (decl)); + return (var_loc_list *) + htab_find_with_hash (decl_loc_table, decl, DECL_UID (decl)); } /* Equate a DIE to a particular declaration. */ @@ -5857,12 +5857,12 @@ add_var_loc_to_decl (tree decl, struct var_loc_node *loc) slot = htab_find_slot_with_hash (decl_loc_table, decl, decl_id, INSERT); if (*slot == NULL) { - temp = ggc_alloc_cleared (sizeof (var_loc_list)); + temp = GGC_CNEW (var_loc_list); temp->decl_id = decl_id; *slot = temp; } else - temp = *slot; + temp = (var_loc_list *) *slot; if (temp->last) { @@ -6354,7 +6354,7 @@ compute_section_prefix (dw_die_ref unit_die) { const char *die_name = get_AT_string (unit_die, DW_AT_name); const char *base = die_name ? lbasename (die_name) : "anonymous"; - char *name = alloca (strlen (base) + 64); + char *name = XALLOCAVEC (char, strlen (base) + 64); char *p; int i, mark; unsigned char checksum[16]; @@ -6476,7 +6476,7 @@ assign_symbol_names (dw_die_ref die) { if (comdat_symbol_id) { - char *p = alloca (strlen (comdat_symbol_id) + 64); + char *p = XALLOCAVEC (char, strlen (comdat_symbol_id) + 64); sprintf (p, "%s.%s.%x", DIE_LABEL_PREFIX, comdat_symbol_id, comdat_symbol_number++); @@ -6500,7 +6500,8 @@ struct cu_hash_table_entry static hashval_t htab_cu_hash (const void *of) { - const struct cu_hash_table_entry *entry = of; + const struct cu_hash_table_entry *const entry = + (const struct cu_hash_table_entry *) of; return htab_hash_string (entry->cu->die_symbol); } @@ -6508,8 +6509,9 @@ htab_cu_hash (const void *of) static int htab_cu_eq (const void *of1, const void *of2) { - const struct cu_hash_table_entry *entry1 = of1; - const struct die_struct *entry2 = of2; + const struct cu_hash_table_entry *const entry1 = + (const struct cu_hash_table_entry *) of1; + const struct die_struct *const entry2 = (const struct die_struct *) of2; return !strcmp (entry1->cu->die_symbol, entry2->die_symbol); } @@ -6517,7 +6519,8 @@ htab_cu_eq (const void *of1, const void *of2) static void htab_cu_del (void *what) { - struct cu_hash_table_entry *next, *entry = what; + struct cu_hash_table_entry *next, + *entry = (struct cu_hash_table_entry *) what; while (entry) { @@ -6737,8 +6740,8 @@ build_abbrev_table (dw_die_ref die) if (abbrev_die_table_in_use >= abbrev_die_table_allocated) { n_alloc = abbrev_die_table_allocated + ABBREV_DIE_TABLE_INCREMENT; - abbrev_die_table = ggc_realloc (abbrev_die_table, - sizeof (dw_die_ref) * n_alloc); + abbrev_die_table = GGC_RESIZEVEC (dw_die_ref, abbrev_die_table, + n_alloc); memset (&abbrev_die_table[abbrev_die_table_allocated], 0, (n_alloc - abbrev_die_table_allocated) * sizeof (dw_die_ref)); @@ -7128,7 +7131,7 @@ static inline dw_loc_list_ref new_loc_list (dw_loc_descr_ref expr, const char *begin, const char *end, const char *section, unsigned int gensym) { - dw_loc_list_ref retlist = ggc_alloc_cleared (sizeof (dw_loc_list_node)); + dw_loc_list_ref retlist = GGC_CNEW (dw_loc_list_node); retlist->begin = begin; retlist->end = end; @@ -7458,7 +7461,7 @@ output_comp_unit (dw_die_ref die, int output_if_empty) oldsym = die->die_symbol; if (oldsym) { - tmp = alloca (strlen (oldsym) + 24); + tmp = XALLOCAVEC (char, strlen (oldsym) + 24); sprintf (tmp, ".gnu.linkonce.wi.%s", oldsym); secname = tmp; @@ -7602,9 +7605,8 @@ add_arange (tree decl, dw_die_ref die) if (arange_table_in_use == arange_table_allocated) { arange_table_allocated += ARANGE_TABLE_INCREMENT; - arange_table = ggc_realloc (arange_table, - (arange_table_allocated - * sizeof (dw_die_ref))); + arange_table = GGC_RESIZEVEC (dw_die_ref, arange_table, + arange_table_allocated); memset (arange_table + arange_table_in_use, 0, ARANGE_TABLE_INCREMENT * sizeof (dw_die_ref)); } @@ -7715,9 +7717,8 @@ add_ranges_num (int num) if (in_use == ranges_table_allocated) { ranges_table_allocated += RANGES_TABLE_INCREMENT; - ranges_table - = ggc_realloc (ranges_table, (ranges_table_allocated - * sizeof (struct dw_ranges_struct))); + ranges_table = GGC_RESIZEVEC (struct dw_ranges_struct, ranges_table, + ranges_table_allocated); memset (ranges_table + ranges_table_in_use, 0, RANGES_TABLE_INCREMENT * sizeof (struct dw_ranges_struct)); } @@ -7748,10 +7749,9 @@ add_ranges_by_labels (const char *begin, const char *end) if (in_use == ranges_by_label_allocated) { ranges_by_label_allocated += RANGES_TABLE_INCREMENT; - ranges_by_label - = ggc_realloc (ranges_by_label, - (ranges_by_label_allocated - * sizeof (struct dw_ranges_by_label_struct))); + ranges_by_label = GGC_RESIZEVEC (struct dw_ranges_by_label_struct, + ranges_by_label, + ranges_by_label_allocated); memset (ranges_by_label + ranges_by_label_in_use, 0, RANGES_TABLE_INCREMENT * sizeof (struct dw_ranges_by_label_struct)); @@ -7876,8 +7876,8 @@ struct dir_info static int file_info_cmp (const void *p1, const void *p2) { - const struct file_info *s1 = p1; - const struct file_info *s2 = p2; + const struct file_info *const s1 = (const struct file_info *) p1; + const struct file_info *const s2 = (const struct file_info *) p2; const unsigned char *cp1; const unsigned char *cp2; @@ -7920,8 +7920,8 @@ struct file_name_acquire_data static int file_name_acquire (void ** slot, void *data) { - struct file_name_acquire_data *fnad = data; - struct dwarf_file_data *d = *slot; + struct file_name_acquire_data *fnad = (struct file_name_acquire_data *) data; + struct dwarf_file_data *d = (struct dwarf_file_data *) *slot; struct file_info *fi; const char *f; @@ -7991,8 +7991,8 @@ output_file_names (void) numfiles = last_emitted_file->emitted_number; /* Allocate the various arrays we need. */ - files = alloca (numfiles * sizeof (struct file_info)); - dirs = alloca (numfiles * sizeof (struct dir_info)); + files = XALLOCAVEC (struct file_info, numfiles); + dirs = XALLOCAVEC (struct dir_info, numfiles); fnad.files = files; fnad.used_files = 0; @@ -8050,8 +8050,8 @@ output_file_names (void) where we would have to check out every combination of every single possible prefix. Instead we use a heuristic which provides nearly optimal results in most cases and never is much off. */ - saved = alloca (ndirs * sizeof (int)); - savehere = alloca (ndirs * sizeof (int)); + saved = XALLOCAVEC (int, ndirs); + savehere = XALLOCAVEC (int, ndirs); memset (saved, '\0', ndirs * sizeof (saved[0])); for (i = 0; i < ndirs; i++) @@ -8117,7 +8117,7 @@ output_file_names (void) /* We have to emit them in the order of emitted_number since that's used in the debug info generation. To do this efficiently we generate a back-mapping of the indices first. */ - backmap = alloca (numfiles * sizeof (int)); + backmap = XALLOCAVEC (int, numfiles); for (i = 0; i < numfiles; i++) backmap[files[i].file_idx->emitted_number - 1] = i; @@ -10293,7 +10293,7 @@ add_const_value_attribute (dw_die_ref die, rtx rtl) if (SCALAR_FLOAT_MODE_P (mode)) { unsigned int length = GET_MODE_SIZE (mode); - unsigned char *array = ggc_alloc (length); + unsigned char *array = GGC_NEWVEC (unsigned char, length); insert_float (rtl, array); add_AT_vec (die, DW_AT_const_value, length / 4, 4, array); @@ -10314,7 +10314,7 @@ add_const_value_attribute (dw_die_ref die, rtx rtl) enum machine_mode mode = GET_MODE (rtl); unsigned int elt_size = GET_MODE_UNIT_SIZE (mode); unsigned int length = CONST_VECTOR_NUNITS (rtl); - unsigned char *array = ggc_alloc (length * elt_size); + unsigned char *array = GGC_NEWVEC (unsigned char, length * elt_size); unsigned int i; unsigned char *p; @@ -12359,7 +12359,7 @@ premark_used_types_helper (void **slot, void *data ATTRIBUTE_UNUSED) tree type; dw_die_ref die; - type = *slot; + type = (tree) *slot; die = lookup_type_die (type); if (die != NULL) die->die_perennial_p = 1; @@ -14423,15 +14423,16 @@ dwarf2out_ignore_block (const_tree block) static int file_table_eq (const void *p1_p, const void *p2_p) { - const struct dwarf_file_data * p1 = p1_p; - const char * p2 = p2_p; + const struct dwarf_file_data *const p1 = + (const struct dwarf_file_data *) p1_p; + const char *const p2 = (const char *) p2_p; return strcmp (p1->filename, p2) == 0; } static hashval_t file_table_hash (const void *p_p) { - const struct dwarf_file_data * p = p_p; + const struct dwarf_file_data *const p = (const struct dwarf_file_data *) p_p; return htab_hash_string (p->filename); } @@ -14463,9 +14464,9 @@ lookup_filename (const char *file_name) slot = htab_find_slot_with_hash (file_table, file_name, htab_hash_string (file_name), INSERT); if (*slot) - return *slot; + return (struct dwarf_file_data *) *slot; - created = ggc_alloc (sizeof (struct dwarf_file_data)); + created = GGC_NEW (struct dwarf_file_data); created->filename = file_name; created->emitted_number = 0; *slot = created; @@ -14519,7 +14520,7 @@ dwarf2out_var_location (rtx loc_note) return; prev_insn = PREV_INSN (loc_note); - newloc = ggc_alloc_cleared (sizeof (struct var_loc_node)); + newloc = GGC_CNEW (struct var_loc_node); /* If the insn we processed last time is the previous insn and it is also a var location note, use the label we emitted last time. */ @@ -14607,9 +14608,9 @@ dwarf2out_source_line (unsigned int line, const char *filename) { separate_line_info_table_allocated += LINE_INFO_TABLE_INCREMENT; separate_line_info_table - = ggc_realloc (separate_line_info_table, - separate_line_info_table_allocated - * sizeof (dw_separate_line_info_entry)); + = GGC_RESIZEVEC (dw_separate_line_info_entry, + separate_line_info_table, + separate_line_info_table_allocated); memset (separate_line_info_table + separate_line_info_table_in_use, 0, @@ -14636,9 +14637,8 @@ dwarf2out_source_line (unsigned int line, const char *filename) { line_info_table_allocated += LINE_INFO_TABLE_INCREMENT; line_info_table - = ggc_realloc (line_info_table, - (line_info_table_allocated - * sizeof (dw_line_info_entry))); + = GGC_RESIZEVEC (dw_line_info_entry, line_info_table, + line_info_table_allocated); memset (line_info_table + line_info_table_in_use, 0, LINE_INFO_TABLE_INCREMENT * sizeof (dw_line_info_entry)); } @@ -14749,15 +14749,13 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED) decl_scope_table = VEC_alloc (tree, gc, 256); /* Allocate the initial hunk of the abbrev_die_table. */ - abbrev_die_table = ggc_alloc_cleared (ABBREV_DIE_TABLE_INCREMENT - * sizeof (dw_die_ref)); + abbrev_die_table = GGC_CNEWVEC (dw_die_ref, ABBREV_DIE_TABLE_INCREMENT); abbrev_die_table_allocated = ABBREV_DIE_TABLE_INCREMENT; /* Zero-th entry is allocated, but unused. */ abbrev_die_table_in_use = 1; /* Allocate the initial hunk of the line_info_table. */ - line_info_table = ggc_alloc_cleared (LINE_INFO_TABLE_INCREMENT - * sizeof (dw_line_info_entry)); + line_info_table = GGC_CNEWVEC (dw_line_info_entry, LINE_INFO_TABLE_INCREMENT); line_info_table_allocated = LINE_INFO_TABLE_INCREMENT; /* Zero-th entry is allocated, but unused. */ @@ -15121,8 +15119,8 @@ prune_unused_types (void) static int file_table_relative_p (void ** slot, void *param) { - bool *p = param; - struct dwarf_file_data *d = *slot; + bool *p = (bool *) param; + struct dwarf_file_data *d = (struct dwarf_file_data *) *slot; if (!IS_ABSOLUTE_PATH (d->filename)) { *p = true; diff --git a/gcc/ebitmap.c b/gcc/ebitmap.c index 8a7c7cb7542..d25a163ff14 100644 --- a/gcc/ebitmap.c +++ b/gcc/ebitmap.c @@ -118,7 +118,7 @@ ebitmap_array_grow (ebitmap map, unsigned int newsize) newsize += newsize / 4; map->n_elts = newsize; - map->elts = xrealloc (map->elts, sizeof (EBITMAP_ELT_TYPE) * newsize); + map->elts = XRESIZEVEC (EBITMAP_ELT_TYPE, map->elts, newsize); } /* Grow the internal word array for MAP so it is at least SIZE @@ -161,7 +161,7 @@ ebitmap_array_init (ebitmap map, unsigned int size) { if (size > 0) { - map->elts = xmalloc (sizeof (EBITMAP_ELT_TYPE) * size); + map->elts = XNEWVEC (EBITMAP_ELT_TYPE, size); map->n_elts = size; } else @@ -202,7 +202,7 @@ ebitmap_clear (ebitmap map) ebitmap ebitmap_alloc (unsigned int size) { - ebitmap ret = xmalloc (sizeof (struct ebitmap_def)); + ebitmap ret = XNEW (struct ebitmap_def); if (size == 0) size = EBITMAP_ELT_BITS; ebitmap_array_init (ret, (size + EBITMAP_ELT_BITS - 1) / EBITMAP_ELT_BITS); @@ -595,7 +595,7 @@ ebitmap_ior_into (ebitmap dst, ebitmap src) } } newarraysize = src->numwords + dst->numwords; - newarray = xmalloc (newarraysize * sizeof (EBITMAP_ELT_TYPE)); + newarray = XNEWVEC (EBITMAP_ELT_TYPE, newarraysize); EXECUTE_IF_SET_IN_SBITMAP (tempmask, 0, i, sbi) { @@ -704,7 +704,7 @@ ebitmap_ior (ebitmap dst, ebitmap src1, ebitmap src2) } } newarraysize = src1->numwords + src2->numwords; - newarray = xmalloc (newarraysize * sizeof (EBITMAP_ELT_TYPE)); + newarray = XNEWVEC (EBITMAP_ELT_TYPE, newarraysize); EXECUTE_IF_SET_IN_SBITMAP (tempmask, 0, i, sbi) { @@ -883,7 +883,7 @@ ebitmap_and_compl (ebitmap dst, ebitmap src1, ebitmap src2) sbitmap_copy (tempmask, src1->wordmask); newarraysize = src1->numwords; - newarray = xmalloc (newarraysize * sizeof (EBITMAP_ELT_TYPE)); + newarray = XNEWVEC (EBITMAP_ELT_TYPE, newarraysize); EXECUTE_IF_SET_IN_SBITMAP (src1->wordmask, 0, i, sbi) { diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index fa2b78a4d95..899679cd296 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -349,7 +349,7 @@ get_mem_attrs (alias_set_type alias, tree expr, rtx offset, rtx size, memcpy (*slot, &attrs, sizeof (mem_attrs)); } - return *slot; + return (mem_attrs *) *slot; } /* Returns a hash code for X (which is a really a reg_attrs *). */ @@ -398,7 +398,7 @@ get_reg_attrs (tree decl, int offset) memcpy (*slot, &attrs, sizeof (reg_attrs)); } - return *slot; + return (reg_attrs *) *slot; } @@ -812,7 +812,7 @@ gen_rtvec (int n, ...) if (n == 0) return NULL_RTVEC; /* Don't allocate an empty rtvec... */ - vector = alloca (n * sizeof (rtx)); + vector = XALLOCAVEC (rtx, n); for (i = 0; i < n; i++) vector[i] = va_arg (p, rtx); @@ -893,12 +893,11 @@ gen_reg_rtx (enum machine_mode mode) char *new; rtx *new1; - new = xrealloc (crtl->emit.regno_pointer_align, old_size * 2); + new = XRESIZEVEC (char, crtl->emit.regno_pointer_align, old_size * 2); memset (new + old_size, 0, old_size); crtl->emit.regno_pointer_align = (unsigned char *) new; - new1 = ggc_realloc (regno_reg_rtx, - old_size * 2 * sizeof (rtx)); + new1 = GGC_RESIZEVEC (rtx, regno_reg_rtx, old_size * 2); memset (new1 + old_size, 0, old_size * sizeof (rtx)); regno_reg_rtx = new1; @@ -4741,7 +4740,7 @@ start_sequence (void) free_sequence_stack = tem->next; } else - tem = ggc_alloc (sizeof (struct sequence_stack)); + tem = GGC_NEW (struct sequence_stack); tem->next = seq_stack; tem->first = first_insn; @@ -5047,11 +5046,10 @@ init_emit (void) crtl->emit.regno_pointer_align_length = LAST_VIRTUAL_REGISTER + 101; crtl->emit.regno_pointer_align - = xcalloc (crtl->emit.regno_pointer_align_length - * sizeof (unsigned char), 1); + = XCNEWVEC (unsigned char, crtl->emit.regno_pointer_align_length); regno_reg_rtx - = ggc_alloc (crtl->emit.regno_pointer_align_length * sizeof (rtx)); + = GGC_NEWVEC (rtx, crtl->emit.regno_pointer_align_length); /* Put copies of all the hard registers into regno_reg_rtx. */ memcpy (regno_reg_rtx, diff --git a/gcc/et-forest.c b/gcc/et-forest.c index 02cbcc16402..e87322c6428 100644 --- a/gcc/et-forest.c +++ b/gcc/et-forest.c @@ -447,7 +447,7 @@ et_new_occ (struct et_node *node) if (!et_occurrences) et_occurrences = create_alloc_pool ("et_occ pool", sizeof (struct et_occ), 300); - nw = pool_alloc (et_occurrences); + nw = (struct et_occ *) pool_alloc (et_occurrences); nw->of = node; nw->parent = NULL; @@ -470,7 +470,7 @@ et_new_tree (void *data) if (!et_nodes) et_nodes = create_alloc_pool ("et_node pool", sizeof (struct et_node), 300); - nw = pool_alloc (et_nodes); + nw = (struct et_node *) pool_alloc (et_nodes); nw->data = data; nw->father = NULL; diff --git a/gcc/except.c b/gcc/except.c index e6a16507cdb..1d9a73639b6 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -409,7 +409,7 @@ init_eh (void) void init_eh_for_function (void) { - cfun->eh = ggc_alloc_cleared (sizeof (struct eh_status)); + cfun->eh = GGC_CNEW (struct eh_status); } /* Routines to generate the exception tree somewhat directly. @@ -426,7 +426,7 @@ gen_eh_region (enum eh_region_type type, struct eh_region *outer) #endif /* Insert a new blank region as a leaf in the tree. */ - new = ggc_alloc_cleared (sizeof (*new)); + new = GGC_CNEW (struct eh_region); new->type = type; new->outer = outer; if (outer) @@ -632,8 +632,8 @@ remove_unreachable_regions (rtx insns) struct eh_region *r; rtx insn; - uid_region_num = xcalloc (get_max_uid (), sizeof(int)); - reachable = xcalloc (cfun->eh->last_region_number + 1, sizeof(bool)); + uid_region_num = XCNEWVEC (int, get_max_uid ()); + reachable = XCNEWVEC (bool, cfun->eh->last_region_number + 1); for (i = cfun->eh->last_region_number; i > 0; --i) { @@ -736,7 +736,7 @@ add_ehl_entry (rtx label, struct eh_region *region) LABEL_PRESERVE_P (label) = 1; - entry = ggc_alloc (sizeof (*entry)); + entry = GGC_NEW (struct ehl_map_entry); entry->label = label; entry->region = region; @@ -847,7 +847,7 @@ duplicate_eh_regions_1 (eh_region old, eh_region outer, int eh_offset) { eh_region ret, n; - ret = n = ggc_alloc (sizeof (struct eh_region)); + ret = n = GGC_NEW (struct eh_region); *n = *old; n->outer = outer; @@ -2587,7 +2587,7 @@ foreach_reachable_handler (int region_number, bool is_resx, static void arh_to_landing_pad (struct eh_region *region, void *data) { - rtx *p_handlers = data; + rtx *p_handlers = (rtx *) data; if (! *p_handlers) *p_handlers = alloc_INSN_LIST (region->landing_pad, NULL_RTX); } @@ -2595,7 +2595,7 @@ arh_to_landing_pad (struct eh_region *region, void *data) static void arh_to_label (struct eh_region *region, void *data) { - rtx *p_handlers = data; + rtx *p_handlers = (rtx *) data; *p_handlers = alloc_INSN_LIST (region->label, *p_handlers); } @@ -3055,7 +3055,7 @@ add_action_record (htab_t ar_hash, int filter, int next) if ((new = *slot) == NULL) { - new = xmalloc (sizeof (*new)); + new = XNEW (struct action_record); new->offset = VARRAY_ACTIVE_SIZE (crtl->eh.action_record_data) + 1; new->filter = filter; new->next = next; @@ -3191,7 +3191,7 @@ add_call_site (rtx landing_pad, int action) { call_site_record record; - record = ggc_alloc (sizeof (struct call_site_record)); + record = GGC_NEW (struct call_site_record); record->landing_pad = landing_pad; record->action = action; @@ -3522,7 +3522,7 @@ switch_to_exception_section (const char * ARG_UNUSED (fnname)) #ifdef HAVE_LD_EH_GC_SECTIONS if (flag_function_sections) { - char *section_name = xmalloc (strlen (fnname) + 32); + char *section_name = XNEWVEC (char, strlen (fnname) + 32); sprintf (section_name, ".gcc_except_table.%s", fnname); s = get_section (section_name, flags, NULL); free (section_name); diff --git a/gcc/expmed.c b/gcc/expmed.c index 27ff0c063cf..bf045fee360 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -2381,8 +2381,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, /* We'll be needing a couple extra algorithm structures now. */ - alg_in = alloca (sizeof (struct algorithm)); - best_alg = alloca (sizeof (struct algorithm)); + alg_in = XALLOCA (struct algorithm); + best_alg = XALLOCA (struct algorithm); best_cost = *cost_limit; /* Compute the hash index. */ diff --git a/gcc/expr.c b/gcc/expr.c index 2357170dd16..6d6278a7bc7 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -1614,7 +1614,7 @@ gen_group_rtx (rtx orig) gcc_assert (GET_CODE (orig) == PARALLEL); length = XVECLEN (orig, 0); - tmps = alloca (sizeof (rtx) * length); + tmps = XALLOCAVEC (rtx, length); /* Skip a NULL entry in first slot. */ i = XEXP (XVECEXP (orig, 0, 0), 0) ? 0 : 1; @@ -1819,7 +1819,7 @@ emit_group_load (rtx dst, rtx src, tree type, int ssize) rtx *tmps; int i; - tmps = alloca (sizeof (rtx) * XVECLEN (dst, 0)); + tmps = XALLOCAVEC (rtx, XVECLEN (dst, 0)); emit_group_load_1 (tmps, dst, src, type, ssize); /* Copy the extracted pieces into the proper (probable) hard regs. */ @@ -1939,7 +1939,7 @@ emit_group_store (rtx orig_dst, rtx src, tree type ATTRIBUTE_UNUSED, int ssize) start = 1; finish = XVECLEN (src, 0); - tmps = alloca (sizeof (rtx) * finish); + tmps = XALLOCAVEC (rtx, finish); /* Copy the (probable) hard regs into pseudos. */ for (i = start; i < finish; i++) @@ -4555,7 +4555,7 @@ store_expr (tree exp, rtx target, int call_param_p, bool nontemporal) } str_copy_len = MIN (str_copy_len, exp_len); if (!can_store_by_pieces (str_copy_len, builtin_strncpy_read_str, - (void *) TREE_STRING_POINTER (exp), + CONST_CAST(char *, TREE_STRING_POINTER (exp)), MEM_ALIGN (target), false)) goto normal_expr; @@ -4563,7 +4563,7 @@ store_expr (tree exp, rtx target, int call_param_p, bool nontemporal) dest_mem = store_by_pieces (dest_mem, str_copy_len, builtin_strncpy_read_str, - (void *) TREE_STRING_POINTER (exp), + CONST_CAST(char *, TREE_STRING_POINTER (exp)), MEM_ALIGN (target), false, exp_len > str_copy_len ? 1 : 0); if (exp_len > str_copy_len) diff --git a/gcc/final.c b/gcc/final.c index 5d19e2d2aba..1f673fb7858 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -858,8 +858,7 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED) n_labels = max_labelno - min_labelno + 1; n_old_labels = old - min_labelno + 1; - label_align = xrealloc (label_align, - n_labels * sizeof (struct label_alignment)); + label_align = XRESIZEVEC (struct label_alignment, label_align, n_labels); /* Range of labels grows monotonically in the function. Failing here means that the initialization of array got lost. */ @@ -2181,7 +2180,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, if (asm_noperands (body) >= 0) { unsigned int noperands = asm_noperands (body); - rtx *ops = alloca (noperands * sizeof (rtx)); + rtx *ops = XALLOCAVEC (rtx, noperands); const char *string; location_t loc; expanded_location expanded; @@ -4056,8 +4055,7 @@ debug_queue_symbol (tree decl) if (symbol_queue_index >= symbol_queue_size) { symbol_queue_size += 10; - symbol_queue = xrealloc (symbol_queue, - symbol_queue_size * sizeof (tree)); + symbol_queue = XRESIZEVEC (tree, symbol_queue, symbol_queue_size); } symbol_queue[symbol_queue_index++] = decl; diff --git a/gcc/function.c b/gcc/function.c index 928107e35c2..c8d5e77daaa 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -598,7 +598,7 @@ assign_stack_temp_for_type (enum machine_mode mode, HOST_WIDE_INT size, if (best_p->size - rounded_size >= alignment) { - p = ggc_alloc (sizeof (struct temp_slot)); + p = GGC_NEW (struct temp_slot); p->in_use = p->addr_taken = 0; p->size = best_p->size - rounded_size; p->base_offset = best_p->base_offset + rounded_size; @@ -623,7 +623,7 @@ assign_stack_temp_for_type (enum machine_mode mode, HOST_WIDE_INT size, { HOST_WIDE_INT frame_offset_old = frame_offset; - p = ggc_alloc (sizeof (struct temp_slot)); + p = GGC_NEW (struct temp_slot); /* We are passing an explicit alignment request to assign_stack_local. One side effect of that is assign_stack_local will not round SIZE @@ -3841,7 +3841,7 @@ allocate_struct_function (tree fndecl, bool abstract_p) tree result; tree fntype = fndecl ? TREE_TYPE (fndecl) : NULL_TREE; - cfun = ggc_alloc_cleared (sizeof (struct function)); + cfun = GGC_CNEW (struct function); current_function_funcdef_no = get_next_funcdef_no (); @@ -5251,7 +5251,7 @@ match_asm_constraints_1 (rtx insn, rtx *p_sets, int noutputs) rtx op = SET_SRC (p_sets[0]); int ninputs = ASM_OPERANDS_INPUT_LENGTH (op); rtvec inputs = ASM_OPERANDS_INPUT_VEC (op); - bool *output_matched = alloca (noutputs * sizeof (bool)); + bool *output_matched = XALLOCAVEC (bool, noutputs); memset (output_matched, 0, noutputs * sizeof (bool)); for (i = 0; i < ninputs; i++) diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c index 665b98681c2..98a9287debd 100644 --- a/gcc/gcov-io.c +++ b/gcc/gcov-io.c @@ -196,7 +196,7 @@ gcov_allocate (unsigned length) new_size *= 2; gcov_var.alloc = new_size; - gcov_var.buffer = xrealloc (gcov_var.buffer, new_size << 2); + gcov_var.buffer = XRESIZEVAR (gcov_unsigned_t, gcov_var.buffer, new_size << 2); } #endif diff --git a/gcc/gcse.c b/gcc/gcse.c index f7e42fb0641..771df43a321 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -638,6 +638,20 @@ static void local_cprop_find_used_regs (rtx *, void *); static bool do_local_cprop (rtx, rtx, bool); static void local_cprop_pass (bool); static bool is_too_expensive (const char *); + +#define GNEW(T) ((T *) gmalloc (sizeof (T))) +#define GCNEW(T) ((T *) gcalloc (1, sizeof (T))) + +#define GNEWVEC(T, N) ((T *) gmalloc (sizeof (T) * (N))) +#define GCNEWVEC(T, N) ((T *) gcalloc ((N), sizeof (T))) +#define GRESIZEVEC(T, P, N) ((T *) grealloc ((void *) (P), sizeof (T) * (N))) + +#define GNEWVAR(T, S) ((T *) gmalloc ((S))) +#define GCNEWVAR(T, S) ((T *) gcalloc (1, (S))) +#define GRESIZEVAR(T, P, S) ((T *) grealloc ((P), (S))) + +#define GOBNEW(T) ((T *) gcse_alloc (sizeof (T))) +#define GOBNEWVAR(T, S) ((T *) gcse_alloc ((S))) /* Entry point for global common subexpression elimination. @@ -698,7 +712,7 @@ gcse_main (rtx f ATTRIBUTE_UNUSED) pass = 0; initial_bytes_used = bytes_used; max_pass_bytes = 0; - gcse_obstack_bottom = gcse_alloc (1); + gcse_obstack_bottom = GOBNEWVAR (char, 1); changed = 1; while (changed && pass < MAX_GCSE_PASSES) { @@ -736,8 +750,8 @@ gcse_main (rtx f ATTRIBUTE_UNUSED) if (changed) { free_modify_mem_tables (); - modify_mem_list = gcalloc (last_basic_block, sizeof (rtx)); - canon_modify_mem_list = gcalloc (last_basic_block, sizeof (rtx)); + modify_mem_list = GCNEWVEC (rtx, last_basic_block); + canon_modify_mem_list = GCNEWVEC (rtx, last_basic_block); } free_reg_set_mem (); alloc_reg_set_mem (max_reg_num ()); @@ -931,7 +945,7 @@ alloc_gcse_mem (void) but we should never see those anyway, so this is OK.) */ max_uid = get_max_uid (); - uid_cuid = gcalloc (max_uid + 1, sizeof (int)); + uid_cuid = GCNEWVEC (int, max_uid + 1); i = 0; FOR_EACH_BB (bb) FOR_BB_INSNS (bb, insn) @@ -951,8 +965,8 @@ alloc_gcse_mem (void) reg_set_in_block = sbitmap_vector_alloc (last_basic_block, max_gcse_regno); /* Allocate array to keep a list of insns which modify memory in each basic block. */ - modify_mem_list = gcalloc (last_basic_block, sizeof (rtx)); - canon_modify_mem_list = gcalloc (last_basic_block, sizeof (rtx)); + modify_mem_list = GCNEWVEC (rtx, last_basic_block); + canon_modify_mem_list = GCNEWVEC (rtx, last_basic_block); modify_mem_list_set = BITMAP_ALLOC (NULL); blocks_with_calls = BITMAP_ALLOC (NULL); } @@ -1076,7 +1090,7 @@ static void alloc_reg_set_mem (int n_regs) { reg_set_table_size = n_regs + REG_SET_TABLE_SLOP; - reg_set_table = gcalloc (reg_set_table_size, sizeof (struct reg_set *)); + reg_set_table = GCNEWVEC (struct reg_set *, reg_set_table_size); gcc_obstack_init (®_set_obstack); } @@ -1101,14 +1115,13 @@ record_one_set (int regno, rtx insn) { int new_size = regno + REG_SET_TABLE_SLOP; - reg_set_table = grealloc (reg_set_table, - new_size * sizeof (struct reg_set *)); + reg_set_table = GRESIZEVEC (struct reg_set *, reg_set_table, new_size); memset (reg_set_table + reg_set_table_size, 0, (new_size - reg_set_table_size) * sizeof (struct reg_set *)); reg_set_table_size = new_size; } - new_reg_info = obstack_alloc (®_set_obstack, sizeof (struct reg_set)); + new_reg_info = XOBNEW (®_set_obstack, struct reg_set); bytes_used += sizeof (struct reg_set); new_reg_info->bb_index = BLOCK_NUM (insn); new_reg_info->next = reg_set_table[regno]; @@ -1509,7 +1522,7 @@ insert_expr_in_table (rtx x, enum machine_mode mode, rtx insn, int antic_p, if (! found) { - cur_expr = gcse_alloc (sizeof (struct expr)); + cur_expr = GOBNEW (struct expr); bytes_used += sizeof (struct expr); if (table->table[hash] == NULL) /* This is the first pattern that hashed to this index. */ @@ -1542,7 +1555,7 @@ insert_expr_in_table (rtx x, enum machine_mode mode, rtx insn, int antic_p, else { /* First occurrence of this expression in this basic block. */ - antic_occr = gcse_alloc (sizeof (struct occr)); + antic_occr = GOBNEW (struct occr); bytes_used += sizeof (struct occr); antic_occr->insn = insn; antic_occr->next = cur_expr->antic_occr; @@ -1566,7 +1579,7 @@ insert_expr_in_table (rtx x, enum machine_mode mode, rtx insn, int antic_p, else { /* First occurrence of this expression in this basic block. */ - avail_occr = gcse_alloc (sizeof (struct occr)); + avail_occr = GOBNEW (struct occr); bytes_used += sizeof (struct occr); avail_occr->insn = insn; avail_occr->next = cur_expr->avail_occr; @@ -1606,7 +1619,7 @@ insert_set_in_table (rtx x, rtx insn, struct hash_table *table) if (! found) { - cur_expr = gcse_alloc (sizeof (struct expr)); + cur_expr = GOBNEW (struct expr); bytes_used += sizeof (struct expr); if (table->table[hash] == NULL) /* This is the first pattern that hashed to this index. */ @@ -1639,7 +1652,7 @@ insert_set_in_table (rtx x, rtx insn, struct hash_table *table) else { /* First occurrence of this expression in this basic block. */ - cur_occr = gcse_alloc (sizeof (struct occr)); + cur_occr = GOBNEW (struct occr); bytes_used += sizeof (struct occr); cur_occr->insn = insn; @@ -1878,8 +1891,8 @@ dump_hash_table (FILE *file, const char *name, struct hash_table *table) unsigned int *hash_val; struct expr *expr; - flat_table = xcalloc (table->n_elems, sizeof (struct expr *)); - hash_val = xmalloc (table->n_elems * sizeof (unsigned int)); + flat_table = XCNEWVEC (struct expr *, table->n_elems); + hash_val = XNEWVEC (unsigned int, table->n_elems); for (i = 0; i < (int) table->size; i++) for (expr = table->table[i]; expr != NULL; expr = expr->next_same_hash) @@ -2048,7 +2061,7 @@ compute_hash_table_work (struct hash_table *table) /* re-Cache any INSN_LIST nodes we have allocated. */ clear_modify_mem_tables (); /* Some working arrays used to track first and last set in each block. */ - reg_avail_info = gmalloc (max_gcse_regno * sizeof (struct reg_avail_info)); + reg_avail_info = GNEWVEC (struct reg_avail_info, max_gcse_regno); for (i = 0; i < max_gcse_regno; ++i) reg_avail_info[i].last_bb = NULL; @@ -2116,7 +2129,7 @@ alloc_hash_table (int n_insns, struct hash_table *table, int set_p) ??? Later take some measurements. */ table->size |= 1; n = table->size * sizeof (struct expr *); - table->table = gmalloc (n); + table->table = GNEWVAR (struct expr *, n); table->set_p = set_p; } @@ -4988,14 +5001,15 @@ static hashval_t pre_ldst_expr_hash (const void *p) { int do_not_record_p = 0; - const struct ls_expr *x = p; + const struct ls_expr *const x = (const struct ls_expr *) p; return hash_rtx (x->pattern, GET_MODE (x->pattern), &do_not_record_p, NULL, false); } static int pre_ldst_expr_eq (const void *p1, const void *p2) { - const struct ls_expr *ptr1 = p1, *ptr2 = p2; + const struct ls_expr *const ptr1 = (const struct ls_expr *) p1, + *const ptr2 = (const struct ls_expr *) p2; return expr_equiv_p (ptr1->pattern, ptr2->pattern); } @@ -5117,7 +5131,7 @@ find_rtx_in_ldst (rtx x) slot = htab_find_slot (pre_ldst_table, &e, NO_INSERT); if (!slot || ((struct ls_expr *)*slot)->invalid) return NULL; - return *slot; + return (struct ls_expr *) *slot; } /* Assign each element of the list of mems a monotonically increasing value. */ @@ -5425,7 +5439,7 @@ static void reg_set_info (rtx dest, const_rtx setter ATTRIBUTE_UNUSED, void *data) { - sbitmap bb_reg = data; + sbitmap bb_reg = (sbitmap) data; if (GET_CODE (dest) == SUBREG) dest = SUBREG_REG (dest); @@ -5445,7 +5459,7 @@ static void reg_clear_last_set (rtx dest, const_rtx setter ATTRIBUTE_UNUSED, void *data) { - int *dead_vec = data; + int *dead_vec = (int *) data; if (GET_CODE (dest) == SUBREG) dest = SUBREG_REG (dest);