You are right. I attached the updated patch to this email. On Tue, Sep 29, 2015 at 3:10 PM, Xinliang David Li <davi...@google.com> wrote: > else > { > gfi_ptr = gi_ptr->functions[f_ix]; > - if (gfi_ptr && gfi_ptr->key == gi_ptr) > + if (gfi_ptr) > length = GCOV_TAG_FUNCTION_LENGTH; > - else > - length = 0; > } > > The removal of 'else' path seems wrong. > > David > > > On Tue, Sep 29, 2015 at 1:46 PM, Rong Xu <x...@google.com> wrote: >> Hi, >> >> This patch is for google/gcc-4_9 branch. >> >> The 'key' field in gcov_fn_info is designed to allow gcov function >> data to be COMDATTed, but the comdat elimination never works. This >> patch removes this field to reduce the instrumented object size. >> >> Thanks, >> >> -Rong
Removed the unused 'key' field in gcov_fn_info to reduce the instrumented objects size.
2015-09-29 Rong Xu <x...@google.com> * gcc/coverage.c (build_fn_info_type): Remove 'key' field. (build_fn_info): Ditto. (coverage_obj_fn): Ditto. * libgcc/libgcov.h (struct gcov_fn_info): Ditto. * libgcc/libgcov-driver.c (gcov_compute_histogram): Ditto. (gcov_exit_compute_summary): Ditto. (gcov_exit_merge_gcda): Ditto. (gcov_write_func_counters): Ditto. (gcov_clear): Ditto. * libgcc/libgcov-util.c (tag_function): Ditto. (gcov_merge): Ditto. (gcov_profile_scale): Ditto. (gcov_profile_normalize): Ditto. (compute_one_gcov): Ditto. (gcov_info_count_all_cold): Ditto. Index: gcc/coverage.c =================================================================== --- gcc/coverage.c (revision 228223) +++ gcc/coverage.c (working copy) @@ -189,7 +189,7 @@ static void read_counts_file (const char *, unsign static tree build_var (tree, tree, int); static void build_fn_info_type (tree, unsigned, tree); static void build_info_type (tree, tree); -static tree build_fn_info (const struct coverage_data *, tree, tree); +static tree build_fn_info (const struct coverage_data *, tree); static tree build_info (tree, tree); static bool coverage_obj_init (void); static vec<constructor_elt, va_gc> *coverage_obj_fn @@ -1668,16 +1668,9 @@ build_fn_info_type (tree type, unsigned counters, finish_builtin_struct (ctr_info, "__gcov_ctr_info", fields, NULL_TREE); - /* key */ - field = build_decl (BUILTINS_LOCATION, FIELD_DECL, NULL_TREE, - build_pointer_type (build_qualified_type - (gcov_info_type, TYPE_QUAL_CONST))); - fields = field; - /* ident */ field = build_decl (BUILTINS_LOCATION, FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ()); - DECL_CHAIN (field) = fields; fields = field; /* lineno_checksum */ @@ -1705,10 +1698,10 @@ build_fn_info_type (tree type, unsigned counters, /* Returns a CONSTRUCTOR for a gcov_fn_info. DATA is the coverage data for the function and TYPE is the gcov_fn_info - RECORD_TYPE. KEY is the object file key. */ + RECORD_TYPE. */ static tree -build_fn_info (const struct coverage_data *data, tree type, tree key) +build_fn_info (const struct coverage_data *data, tree type) { tree fields = TYPE_FIELDS (type); tree ctr_type; @@ -1716,11 +1709,6 @@ static tree vec<constructor_elt, va_gc> *v1 = NULL; vec<constructor_elt, va_gc> *v2 = NULL; - /* key */ - CONSTRUCTOR_APPEND_ELT (v1, fields, - build1 (ADDR_EXPR, TREE_TYPE (fields), key)); - fields = DECL_CHAIN (fields); - /* ident */ CONSTRUCTOR_APPEND_ELT (v1, fields, build_int_cstu (get_gcov_unsigned_t (), @@ -2556,7 +2544,7 @@ static vec<constructor_elt, va_gc> * coverage_obj_fn (vec<constructor_elt, va_gc> *ctor, tree fn, struct coverage_data const *data) { - tree init = build_fn_info (data, gcov_fn_info_type, gcov_info_var); + tree init = build_fn_info (data, gcov_fn_info_type); tree var = build_var (fn, gcov_fn_info_type, -1); DECL_INITIAL (var) = init; Index: libgcc/libgcov-driver.c =================================================================== --- libgcc/libgcov-driver.c (revision 227984) +++ libgcc/libgcov-driver.c (working copy) @@ -380,7 +380,7 @@ gcov_compute_histogram (struct gcov_summary *sum) { gfi_ptr = gi_ptr->functions[f_ix]; - if (!gfi_ptr || gfi_ptr->key != gi_ptr) + if (!gfi_ptr) continue; ci_ptr = &gfi_ptr->ctrs[ctr_info_ix]; @@ -430,9 +430,6 @@ gcov_exit_compute_summary (struct gcov_summary *th { gfi_ptr = gi_ptr->functions[f_ix]; - if (gfi_ptr && gfi_ptr->key != gi_ptr) - gfi_ptr = 0; - crc32 = crc32_unsigned (crc32, gfi_ptr ? gfi_ptr->cfg_checksum : 0); crc32 = crc32_unsigned (crc32, gfi_ptr ? gfi_ptr->lineno_checksum : 0); @@ -688,7 +685,7 @@ gcov_exit_merge_gcda (struct gcov_info *gi_ptr, if (length != GCOV_TAG_FUNCTION_LENGTH) goto read_mismatch; - if (!gfi_ptr || gfi_ptr->key != gi_ptr) + if (!gfi_ptr) { /* This function appears in the other program. We need to buffer the information in order to write @@ -832,7 +829,7 @@ gcov_write_func_counters (struct gcov_info *gi_ptr else { gfi_ptr = gi_ptr->functions[f_ix]; - if (gfi_ptr && gfi_ptr->key == gi_ptr) + if (gfi_ptr) length = GCOV_TAG_FUNCTION_LENGTH; else length = 0; @@ -1474,7 +1471,7 @@ gcov_clear (void) const struct gcov_fn_info *gfi_ptr = gi_ptr->functions[f_ix]; const struct gcov_ctr_info *ci_ptr; - if (!gfi_ptr || gfi_ptr->key != gi_ptr) + if (!gfi_ptr) continue; ci_ptr = gfi_ptr->ctrs; for (t_ix = 0; t_ix != GCOV_COUNTERS; t_ix++) Index: libgcc/libgcov-util.c =================================================================== --- libgcc/libgcov-util.c (revision 227984) +++ libgcc/libgcov-util.c (working copy) @@ -180,7 +180,6 @@ tag_function (unsigned tag ATTRIBUTE_UNUSED, unsig fprintf (stderr, "Function id=%d fixed up\n", curr_fn_info->ident); } - curr_fn_info->key = curr_gcov_info; curr_fn_info->ident = gcov_read_unsigned (); curr_fn_info->lineno_checksum = gcov_read_unsigned (); curr_fn_info->cfg_checksum = gcov_read_unsigned (); @@ -833,9 +832,9 @@ gcov_merge (struct gcov_info *info1, struct gcov_i const struct gcov_fn_info *gfi_ptr2 = info2->functions[f_ix]; const struct gcov_ctr_info *ci_ptr1, *ci_ptr2; - if (!gfi_ptr1 || gfi_ptr1->key != info1) + if (!gfi_ptr1) continue; - if (!gfi_ptr2 || gfi_ptr2->key != info2) + if (!gfi_ptr2) continue; if (gfi_ptr1->cfg_checksum != gfi_ptr2->cfg_checksum) @@ -1136,7 +1135,7 @@ gcov_profile_scale (struct gcov_info *profile, flo const struct gcov_fn_info *gfi_ptr = gi_ptr->functions[f_ix]; const struct gcov_ctr_info *ci_ptr; - if (!gfi_ptr || gfi_ptr->key != gi_ptr) + if (!gfi_ptr) continue; ci_ptr = gfi_ptr->ctrs; @@ -1178,7 +1177,7 @@ gcov_profile_normalize (struct gcov_info *profile, const struct gcov_fn_info *gfi_ptr = gi_ptr->functions[f_ix]; const struct gcov_ctr_info *ci_ptr; - if (!gfi_ptr || gfi_ptr->key != gi_ptr) + if (!gfi_ptr) continue; ci_ptr = gfi_ptr->ctrs; @@ -1264,7 +1263,7 @@ compute_one_gcov (const struct gcov_info *gcov_inf { unsigned t_ix; const struct gcov_fn_info *gfi_ptr = gcov_info->functions[f_ix]; - if (!gfi_ptr || gfi_ptr->key != gcov_info) + if (!gfi_ptr) continue; const struct gcov_ctr_info *ci_ptr = gfi_ptr->ctrs; for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++) @@ -1296,9 +1295,9 @@ compute_one_gcov (const struct gcov_info *gcov_inf const struct gcov_fn_info *gfi_ptr1 = gcov_info1->functions[f_ix]; const struct gcov_fn_info *gfi_ptr2 = gcov_info2->functions[f_ix]; - if (!gfi_ptr1 || gfi_ptr1->key != gcov_info1) + if (!gfi_ptr1) continue; - if (!gfi_ptr2 || gfi_ptr2->key != gcov_info2) + if (!gfi_ptr2) continue; const struct gcov_ctr_info *ci_ptr1 = gfi_ptr1->ctrs; @@ -1358,7 +1357,7 @@ gcov_info_count_all_cold (const struct gcov_info * unsigned t_ix; const struct gcov_fn_info *gfi_ptr = gcov_info->functions[f_ix]; - if (!gfi_ptr || gfi_ptr->key != gcov_info) + if (!gfi_ptr) continue; const struct gcov_ctr_info *ci_ptr = gfi_ptr->ctrs; for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++) Index: libgcc/libgcov.h =================================================================== --- libgcc/libgcov.h (revision 227984) +++ libgcc/libgcov.h (working copy) @@ -224,13 +224,10 @@ struct gcov_ctr_info /* Information about a single function. This uses the trailing array idiom. The number of counters is determined from the merge pointer - array in gcov_info. The key is used to detect which of a set of - comdat functions was selected -- it points to the gcov_info object - of the object file containing the selected comdat function. */ + array in gcov_info. */ struct gcov_fn_info { - const struct gcov_info *key; /* comdat key */ gcov_unsigned_t ident; /* unique ident of function */ gcov_unsigned_t lineno_checksum; /* function lineo_checksum */ gcov_unsigned_t cfg_checksum; /* function cfg checksum */