From patchwork Tue Sep 29 23:08:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rong Xu X-Patchwork-Id: 524064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C4DB8140180 for ; Wed, 30 Sep 2015 09:08:32 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=kQTKHJ7R; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=eZgS/6iBWtY4Sb9TJs ukJm/EywBa+wcHc8lE/GRNp2wIiiEOEQhYnc8vLweQlOK73JHNdOC7vlxahIexCH v+TZ3QVkRU5ftHpbQEeAL6tEhiBQiAXeYkb3xy2QV1PtKhuoMdIzMMi0+80O/uy7 cG7RXOADJIVE/B1AbzsbjQo5c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=zoDBUiURt0An/rvXNSbHCe+L 7rE=; b=kQTKHJ7RhJu4V9XOveIBo+NuYwFKXShwMUq7qJd/XYQ9o0JOl699bWzA Kx+0r3f66c4divRidtuUltwngNAeHgbMATa8vZ1Z4a4EEp+dmKPP4D207Vol8AgF IQJQ0V5dmQFaZS++Dvz8ocSaSAfAUpk7RHyDc1WAahXSmn6+KdM= Received: (qmail 7087 invoked by alias); 29 Sep 2015 23:08:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 7075 invoked by uid 89); 29 Sep 2015 23:08:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-yk0-f177.google.com Received: from mail-yk0-f177.google.com (HELO mail-yk0-f177.google.com) (209.85.160.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 29 Sep 2015 23:08:22 +0000 Received: by ykft14 with SMTP id t14so23007048ykf.0 for ; Tue, 29 Sep 2015 16:08:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=2hGRrzJashjxx97gferu3+oiGJBmcBOI2MnIdpXqpnE=; b=QLqYUJlH4lAnLFaqiSxUCLXEuP74YFQVO9rD4vljVZiXgWe66yR+CpP0A2KVJLTbeY qzvcVYBPVWVHMkUpqX2e8MJgSfLL4Y5hHEnauk6tNX7/2YHaQQibLcmRZ/byqnO+Y29x 93t2NSOauq3cCEf3bnY4GN3Fojkr2s+ONkv8PCU/Bo+XhMHTJTHtWV9im7UNBa0Jzx0I UrtIe4YrOoASAAQiRheRflE3L/ayhFGbDJTFsFEFoJAH7Kuj8icORlWD6MUkhlwT/3AQ Jkr8R/n4pAot+VXfrkOO+F5/9TL5IAyEVCOeyUxnb99SZAQM25Ct8o7YDyn9f0yKVQDu DB/w== X-Gm-Message-State: ALoCoQn/xeAP5jW4iUaN54pH3PDJrvVw1iDSDqeFeJQE1ONDO1eK4ra9JhhH955XRuhJUHITWbqk MIME-Version: 1.0 X-Received: by 10.170.81.5 with SMTP id x5mr488497ykx.82.1443568100271; Tue, 29 Sep 2015 16:08:20 -0700 (PDT) Received: by 10.37.224.2 with HTTP; Tue, 29 Sep 2015 16:08:20 -0700 (PDT) In-Reply-To: References: Date: Tue, 29 Sep 2015 16:08:20 -0700 Message-ID: Subject: Re: [google][gcc-4_9] Remove unused key field in gcov_fn_info From: Rong Xu To: Xinliang David Li Cc: GCC Patches X-IsSubscribed: yes You are right. I attached the updated patch to this email. On Tue, Sep 29, 2015 at 3:10 PM, Xinliang David Li 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 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 * 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 *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 *v1 = NULL; vec *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 * coverage_obj_fn (vec *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 */